kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG
authorYann E. MORIN <yann.morin.1998@free.fr>
Tue, 18 Jun 2013 17:35:29 +0000 (19:35 +0200)
committerChristian Lamparter <chunkeey@googlemail.com>
Wed, 23 Oct 2013 20:21:06 +0000 (22:21 +0200)
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:
    ./config/conf --randconfig Config.test.in

does properly randomise the two choice symbols (and the two booleans).

However, running:
    KCONFIG_ALLCONFIG=config.defaults \
    ./config/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 <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: Sedat Dilek <sedat.dilek@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Christian Lamparter <chunkeey@googlemail.com>
config/confdata.c

index 8128254a6265626e1f89efdec27d6ea06b830ea1..192f13c73e8f616433c438e122eceaa6f5c21c15 100644 (file)
@@ -288,8 +288,6 @@ load:
        for_all_symbols(i, sym) {
                sym->flags |= SYMBOL_CHANGED;
                sym->flags &= ~(def_flags|SYMBOL_VALID);
-               if (sym_is_choice(sym))
-                       sym->flags |= def_flags;
                switch (sym->type) {
                case S_INT:
                case S_HEX:
@@ -379,13 +377,13 @@ setsym:
                        case mod:
                                if (cs->def[def].tri == yes) {
                                        conf_warning("%s creates inconsistent choice state", sym->name);
-                                       cs->flags &= ~def_flags;
                                }
                                break;
                        case yes:
                                if (cs->def[def].tri != no)
                                        conf_warning("override: %s changes choice state", sym->name);
                                cs->def[def].val = sym;
+                               cs->flags |= def_flags;
                                break;
                        }
                        cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
@@ -837,6 +835,8 @@ int conf_write(const char *name)
                        sym_calc_value(sym);
                        if (!(sym->flags & SYMBOL_WRITE))
                                goto next;
+                       if (sym_is_choice_value(sym) && !menu_is_visible(menu->parent))
+                               goto next;
                        sym->flags &= ~SYMBOL_WRITE;
 
                        conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);