]> git.itanic.dy.fi Git - linux-stable/commitdiff
kconfig: do not clear SYMBOL_DEF_USER when the value is out of range
authorMasahiro Yamada <masahiroy@kernel.org>
Sun, 5 Nov 2023 18:10:47 +0000 (03:10 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Tue, 28 Nov 2023 02:22:50 +0000 (11:22 +0900)
When a user-supplied value is out of range, (NEW) and an incorrect default
value are shown.

[Test Kconfig]

  config FOO
          int "foo"
          range 10 20

[Test .config]

  CONFIG_FOO=30

[Result without this fix]

  $ make config
  *
  * Main menu
  *
  foo (FOO) [10] (NEW)

[Result with this fix]

  $ make config
  *
  * Main menu
  *
  foo (FOO) [20]

Currently, the SYMBOL_DEF_USER is cleared if the user input does not
reside within the range. Kconfig forgets the initial value 30, and
prints (NEW) and an incorrect default [10].

Kconfig should remember the user's input. The default should be [20]
because the user's input, 30, is closer to the upper limit of the range.

Please note it will not show up in "make oldconfig" because it is no
longer considered as a new symbol. It also fixes the inconsistent
behavior in listnewconfig/helpnewconfig.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/confdata.c

index 4a6811d77d182964d1ec73c34a87c28670dec692..7fca9cc3ae748911eff76677421d744e079278fa 100644 (file)
@@ -594,7 +594,7 @@ int conf_read(const char *name)
                                /* Reset a string value if it's out of range */
                                if (sym_string_within_range(sym, sym->def[S_DEF_USER].val))
                                        break;
-                               sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER);
+                               sym->flags &= ~SYMBOL_VALID;
                                conf_unsaved++;
                                break;
                        default: