aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/config
diff options
context:
space:
mode:
authorNicolas Pitre <nico@linaro.org>2019-06-15 17:07:08 +0200
committerJo-Philipp Wich <jo@mein.io>2019-06-20 14:14:16 +0200
commit75dcaf3d23301da35eb4a6d0efc5ba5a0ed09850 (patch)
treeb82ff9aca4790c646135f336d9304fb3dd106b4b /scripts/config
parent972123f1e056e6d443be1e4a11db09b5d2ef53da (diff)
downloadupstream-75dcaf3d23301da35eb4a6d0efc5ba5a0ed09850.tar.gz
upstream-75dcaf3d23301da35eb4a6d0efc5ba5a0ed09850.tar.bz2
upstream-75dcaf3d23301da35eb4a6d0efc5ba5a0ed09850.zip
config: fix relational operators for bool and tristate symbols
Since commit 31847b67bec0 ("kconfig: allow use of relations other than (in)equality") it is possible to use relational operators in Kconfig statements. However, those operators give unexpected results when applied to bool/tristate values: (n < y) = y (correct) (m < y) = y (correct) (n < m) = n (wrong) This happens because relational operators process bool and tristate symbols as strings and m sorts before n. It makes little sense to do a lexicographical compare on bool and tristate values though. Documentation/kbuild/kconfig-language.txt states that expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 respectively for calculations). Let's make it so for relational comparisons with bool/tristate expressions as well and document them. If at least one symbol is an actual string then the lexicographical compare works just as before. Signed-off-by: Nicolas Pitre <nico@linaro.org> Acked-by: Randy Dunlap <rdunlap@infradead.org> Tested-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> [rebased against OpenWrt kconfig, slightly reword commit message] (backported from upstream 9059a3493efea6492451430c7e2fa0af799a2abb) Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'scripts/config')
-rw-r--r--scripts/config/expr.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/scripts/config/expr.c b/scripts/config/expr.c
index cbf4996dd9..8cee597d33 100644
--- a/scripts/config/expr.c
+++ b/scripts/config/expr.c
@@ -893,7 +893,10 @@ static enum string_value_kind expr_parse_string(const char *str,
switch (type) {
case S_BOOLEAN:
case S_TRISTATE:
- return k_string;
+ val->s = !strcmp(str, "n") ? 0 :
+ !strcmp(str, "m") ? 1 :
+ !strcmp(str, "y") ? 2 : -1;
+ return k_signed;
case S_INT:
val->s = strtoll(str, &tail, 10);
kind = k_signed;