kconfig: do not write choice values when their dependency becomes n
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Tue, 6 Feb 2018 00:34:42 +0000 (09:34 +0900)
committerChristian Lamparter <chunkeey@gmail.com>
Sun, 10 Feb 2019 20:56:07 +0000 (21:56 +0100)
commitf6f076e32ca549993217b2257ef06c29453e0d62
tree9c1399ef24214ee1281a0cbbe67b3ba51e63246d
parentb472ec1fc1c17fe5f06ff853672b8d1c1d8a190e
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>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
config/symbol.c