Skip to content

Commit 8357b48

Browse files
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. Reported-by: Thomas Petazzoni <[email protected]> Signed-off-by: "Yann E. MORIN" <[email protected]> Cc: Thomas Petazzoni <[email protected]> Cc: Michal Marek <[email protected]> Cc: Sam Ravnborg <[email protected]> Cc: Sedat Dilek <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Stephen Rothwell <[email protected]> --- Changes v3 -> v4 - fix previous issue where some choices would not be set, which would cause silentoldconfig to ask for them and was then breaking this workflow (as reported by Arnd and Sedat): KCONFIG_ALLCONFIG=foo.defconfig make randconfig make silentoldconfig </dev/nullo which I have tested (3h28min!) with: touch defconfig for(( i=0; i<10000; i++ )); do KCONFIG_ALLCONFIG=$(pwd)/defconfig make randconfig >/dev/null 2>&1 make silentoldconfig </dev/null >/dev/null 2>&1 || break done which did not break at all. - change done in v3 (below) is already fixed by a previous patch 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
1 parent 3b9a19e commit 8357b48

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/kconfig/confdata.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ int conf_read_simple(const char *name, int def)
288288
for_all_symbols(i, sym) {
289289
sym->flags |= SYMBOL_CHANGED;
290290
sym->flags &= ~(def_flags|SYMBOL_VALID);
291-
if (sym_is_choice(sym))
292-
sym->flags |= def_flags;
293291
switch (sym->type) {
294292
case S_INT:
295293
case S_HEX:
@@ -379,13 +377,13 @@ int conf_read_simple(const char *name, int def)
379377
case mod:
380378
if (cs->def[def].tri == yes) {
381379
conf_warning("%s creates inconsistent choice state", sym->name);
382-
cs->flags &= ~def_flags;
383380
}
384381
break;
385382
case yes:
386383
if (cs->def[def].tri != no)
387384
conf_warning("override: %s changes choice state", sym->name);
388385
cs->def[def].val = sym;
386+
cs->flags |= def_flags;
389387
break;
390388
}
391389
cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
@@ -791,6 +789,8 @@ int conf_write(const char *name)
791789
sym_calc_value(sym);
792790
if (!(sym->flags & SYMBOL_WRITE))
793791
goto next;
792+
if (sym_is_choice_value(sym) && !menu_is_visible(menu->parent))
793+
goto next;
794794
sym->flags &= ~SYMBOL_WRITE;
795795

796796
conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);

0 commit comments

Comments
 (0)