diff options
| author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-02-05 19:34:42 -0500 |
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2018-02-08 14:08:05 -0500 |
| commit | cb67ab2cd2b8abd9650292c986c79901e3073a59 (patch) | |
| tree | 6f0f2968c93697b981b195a08fd0c830a13c89d5 /scripts | |
| parent | a2b0fe7435faee6f6fbb27409878013bc4727e98 (diff) | |
kconfig: do not write choice values when their dependency becomes n
"# CONFIG_... is not set" for choice values are wrongly written into
the .config file if they are once visible, then become invisible later.
Test case
---------
---------------------------(Kconfig)----------------------------
config A
bool "A"
choice
prompt "Choice ?"
depends on A
config CHOICE_B
bool "Choice B"
config CHOICE_C
bool "Choice C"
endchoice
----------------------------------------------------------------
---------------------------(.config)----------------------------
CONFIG_A=y
----------------------------------------------------------------
With the Kconfig and .config above,
$ make config
scripts/kconfig/conf --oldaskconfig Kconfig
*
* Linux Kernel Configuration
*
A (A) [Y/n] n
#
# configuration written to .config
#
$ cat .config
#
# Automatically generated file; DO NOT EDIT.
# Linux Kernel Configuration
#
# CONFIG_A is not set
# CONFIG_CHOICE_B is not set
# CONFIG_CHOICE_C is not set
Here,
# CONFIG_CHOICE_B is not set
# CONFIG_CHOICE_C is not set
should not be written into the .config file because their dependency
"depends on A" is unmet.
Currently, there is no code that clears SYMBOL_WRITE of choice values.
Clear SYMBOL_WRITE for all symbols in sym_calc_value(), then set it
again after calculating visibility. To simplify the logic, set the
flag if they have non-n visibility, regardless of types, and regardless
of whether they are choice values or not.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/kconfig/symbol.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index c9123ed2b791..13f7fdfe328d 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
| @@ -371,11 +371,13 @@ void sym_calc_value(struct symbol *sym) | |||
| 371 | sym->curr.tri = no; | 371 | sym->curr.tri = no; |
| 372 | return; | 372 | return; |
| 373 | } | 373 | } |
| 374 | if (!sym_is_choice_value(sym)) | 374 | sym->flags &= ~SYMBOL_WRITE; |
| 375 | sym->flags &= ~SYMBOL_WRITE; | ||
| 376 | 375 | ||
| 377 | sym_calc_visibility(sym); | 376 | sym_calc_visibility(sym); |
| 378 | 377 | ||
| 378 | if (sym->visible != no) | ||
| 379 | sym->flags |= SYMBOL_WRITE; | ||
| 380 | |||
| 379 | /* set default if recursively called */ | 381 | /* set default if recursively called */ |
| 380 | sym->curr = newval; | 382 | sym->curr = newval; |
| 381 | 383 | ||
| @@ -390,7 +392,6 @@ void sym_calc_value(struct symbol *sym) | |||
| 390 | /* if the symbol is visible use the user value | 392 | /* if the symbol is visible use the user value |
| 391 | * if available, otherwise try the default value | 393 | * if available, otherwise try the default value |
| 392 | */ | 394 | */ |
| 393 | sym->flags |= SYMBOL_WRITE; | ||
| 394 | if (sym_has_value(sym)) { | 395 | if (sym_has_value(sym)) { |
| 395 | newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, | 396 | newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri, |
| 396 | sym->visible); | 397 | sym->visible); |
| @@ -433,12 +434,9 @@ void sym_calc_value(struct symbol *sym) | |||
| 433 | case S_STRING: | 434 | case S_STRING: |
| 434 | case S_HEX: | 435 | case S_HEX: |
| 435 | case S_INT: | 436 | case S_INT: |
| 436 | if (sym->visible != no) { | 437 | if (sym->visible != no && sym_has_value(sym)) { |
| 437 | sym->flags |= SYMBOL_WRITE; | 438 | newval.val = sym->def[S_DEF_USER].val; |
| 438 | if (sym_has_value(sym)) { | 439 | break; |
| 439 | newval.val = sym->def[S_DEF_USER].val; | ||
| 440 | break; | ||
| 441 | } | ||
| 442 | } | 440 | } |
| 443 | prop = sym_get_default_prop(sym); | 441 | prop = sym_get_default_prop(sym); |
| 444 | if (prop) { | 442 | if (prop) { |
