aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorYann E. MORIN <yann.morin.1998@free.fr>2013-03-10 11:34:10 -0400
committerYann E. MORIN <yann.morin.1998@free.fr>2013-04-24 18:16:12 -0400
commit422c809f03f043d0950d8362214818e956a9daee (patch)
tree0fdc061b77665f185b117e32a36c9f678e6d97e6 /scripts
parentcfa98f2e0ae956feca935573e977d7661a9561b9 (diff)
kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG
Currently, randconfig does randomise choice entries, unless KCONFIG_ALLCONFIG is specified. For example, given those two files (Thomas' test-case): ---8<--- Config.test.in config OPTIONA bool "Option A" choice prompt "This is a choice" config CHOICE_OPTIONA bool "Choice Option A" config CHOICE_OPTIONB bool "Choice Option B" endchoice config OPTIONB bool "Option B" ---8<--- Config.test.in ---8<--- config.defaults CONFIG_OPTIONA=y ---8<--- config.defaults And running: ./scripts/kconfig/conf --randconfig Config.test.in does properly randomise the two choice symbols (and the two booleans). However, running: KCONFIG_ALLCONFIG=config.defaults \ ./scripts/kconfig/conf --randconfig Config.test.in does *not* reandomise the two choice entries, and only CHOICE_OPTIONA will ever be selected. (OPTIONA will always be set (expected), and OPTIONB will be be properly randomised (expected).) This patch defers setting that a choice has a value until a symbol for that choice is indeed set, so that choices are properly randomised when KCONFIG_ALLCONFIG is set, but not if a symbol for that choice is set. Also, as a side-efect, this patch fixes the following case: ---8<--- choice config OPTION_A bool "Option A" config OPTION_B bool "Option B" config OPTION_C bool "Option C" endchoice ---8<--- which could previously generate such .config files: ---8<--- ---8<--- CONFIG_OPTION_A=y CONFIG_OPTION_A=y CONFIG_OPTION_B=y # CONFIG_OPTION_B is not set # CONFIG_OPTION_C is not set CONFIG_OPTION_C=y ---8<--- ---8<--- Ie., the first entry in a choice is always set, plus zero or one of the other options may be set. This patch ensures that only one option may be set for a choice. Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Cc: Michal Marek <mmarek@suse.cz> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Arnaud Lacombe <lacombar@gmail.com> --- Changes v2 -> v3 - ensure only one symbol is set in a choice Changes v1 -> v2: - further postpone setting that a choice has a value until one is indeed set - do not print symbols that are part of an invisible choice
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/confdata.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 2e35d4b2bbfd..89274809a826 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -288,8 +288,6 @@ load:
288 for_all_symbols(i, sym) { 288 for_all_symbols(i, sym) {
289 sym->flags |= SYMBOL_CHANGED; 289 sym->flags |= SYMBOL_CHANGED;
290 sym->flags &= ~(def_flags|SYMBOL_VALID); 290 sym->flags &= ~(def_flags|SYMBOL_VALID);
291 if (sym_is_choice(sym))
292 sym->flags |= def_flags;
293 switch (sym->type) { 291 switch (sym->type) {
294 case S_INT: 292 case S_INT:
295 case S_HEX: 293 case S_HEX:
@@ -379,13 +377,13 @@ setsym:
379 case mod: 377 case mod:
380 if (cs->def[def].tri == yes) { 378 if (cs->def[def].tri == yes) {
381 conf_warning("%s creates inconsistent choice state", sym->name); 379 conf_warning("%s creates inconsistent choice state", sym->name);
382 cs->flags &= ~def_flags;
383 } 380 }
384 break; 381 break;
385 case yes: 382 case yes:
386 if (cs->def[def].tri != no) 383 if (cs->def[def].tri != no)
387 conf_warning("override: %s changes choice state", sym->name); 384 conf_warning("override: %s changes choice state", sym->name);
388 cs->def[def].val = sym; 385 cs->def[def].val = sym;
386 cs->flags |= def_flags;
389 break; 387 break;
390 } 388 }
391 cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); 389 cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
@@ -791,6 +789,8 @@ int conf_write(const char *name)
791 sym_calc_value(sym); 789 sym_calc_value(sym);
792 if (!(sym->flags & SYMBOL_WRITE)) 790 if (!(sym->flags & SYMBOL_WRITE))
793 goto next; 791 goto next;
792 if (sym_is_choice_value(sym) && !menu_is_visible(menu->parent))
793 goto next;
794 sym->flags &= ~SYMBOL_WRITE; 794 sym->flags &= ~SYMBOL_WRITE;
795 795
796 conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); 796 conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
@@ -1077,6 +1077,7 @@ static void randomize_choice_values(struct symbol *csym)
1077 else { 1077 else {
1078 sym->def[S_DEF_USER].tri = no; 1078 sym->def[S_DEF_USER].tri = no;
1079 } 1079 }
1080 sym->flags &= ~(SYMBOL_VALID);
1080 } 1081 }
1081 csym->flags |= SYMBOL_DEF_USER; 1082 csym->flags |= SYMBOL_DEF_USER;
1082 /* clear VALID to get value calculated */ 1083 /* clear VALID to get value calculated */