kconfig: Warn if choice default is not in choice
authorUlf Magnusson <ulfalizer@gmail.com>
Tue, 3 Oct 2017 23:25:46 +0000 (01:25 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Sun, 10 Feb 2019 20:45:59 +0000 (21:45 +0100)
commitda0117f96d518cf7ba264cdd1a18625d8200667a
tree169c08324258b1fb4ec287bbf534132e20617792
parent6a171454592fdbe35ddc650db99119d510b07bc6
kconfig: Warn if choice default is not in choice

This will catch mistakes like in the following real-world example, where
a "CONFIG_" prefix snuck in, making an undefined symbol the default:

choice
prompt "Compiler optimization level"
default CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE

config CC_OPTIMIZE_FOR_PERFORMANCE
...

config CC_OPTIMIZE_FOR_SIZE
...

endchoice

This now prints the following warning:

init/Kconfig:1036:warning: choice default symbol 'CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE' is not contained in the choice

Cases where the default symbol belongs to the wrong choice are also
detected.

(The mistake is harmless here: Since the default symbol is not visible,
the choice falls back on using the first visible symbol as the default,
which is CC_OPTIMIZE_FOR_PERFORMANCE, as intended.)

Discovered while playing around with Kconfiglib
(https://github.com/ulfalizer/Kconfiglib).

Signed-off-by: Ulf Magnusson <ulfalizer@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
config/menu.c