Skip to content

Commit

Permalink
kconfig: fix savedefconfig with choice marked optional
Browse files Browse the repository at this point in the history
savedefconfig failed to save the correct minimal config
when it encountered a choice marked optional.

Consider following minimal configuration:
$cat Kconfig
choice
	prompt "choice"
	optional

config A
	bool "a"

config B
	bool "b"

endchoice

$cat .config | grep -v ^#
CONFIG_A=y

$conf --savedefconfig=defconfig Kconfig

would before this fix result in an empty file, because
kconfig would assume that CONFIG_A=y is a default value.
But because the choice is optional the default is that
both A and B are =n.

Fix so we handle optional choices correct.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
  • Loading branch information
Sam Ravnborg authored and Michal Marek committed Aug 14, 2010
1 parent 4418a2b commit 84062dd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -497,15 +497,17 @@ int conf_write_defconfig(const char *filename)
/*
* If symbol is a choice value and equals to the
* default for a choice - skip.
* But only if value is bool and equal to "y" .
* But only if value is bool and equal to "y" and
* choice is not "optional".
* (If choice is "optional" then all values can be "n")
*/
if (sym_is_choice_value(sym)) {
struct symbol *cs;
struct symbol *ds;

cs = prop_get_symbol(sym_get_choice_prop(sym));
ds = sym_choice_default(cs);
if (sym == ds) {
if (!sym_is_optional(cs) && sym == ds) {
if ((sym->type == S_BOOLEAN) &&
sym_get_tristate_value(sym) == yes)
goto next_menu;
Expand Down

0 comments on commit 84062dd

Please sign in to comment.