Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
kconfig: fix select in combination with default
Browse files Browse the repository at this point in the history
> The attached .config (with current -git) results in a compile
> error since it contains:
>
> CONFIG_X86=y
> # CONFIG_EMBEDDED is not set
> CONFIG_SERIO=m
> CONFIG_SERIO_I8042=y
>
> Looking at drivers/input/serio/Kconfig I simply don't get how this
> can happen.

You've hit the rather subtle rules of select vs default. What happened is
that SERIO is selected to m, but SERIO_I8042 isn't selected so the default
of y is used instead.
We already had the problem in the past that select and default don't work
well together, so this patch cleans this up and makes the rule hopefully
more straightforward. Basically now the value is calculated like this:

	(value && dependency) || select

where the value is the user choice (if available and the symbol is
visible) or default.

In this case it means SERIO and SERIO_I8042 are both set to y due to their
default and if SERIO didn't had the default, then the SERIO_I8042 value
would be limited to m due to the dependency.

I tested this patch with more 10000 random configs and above case is the
only the difference that showed up, so I hope there is nothing that
depended on the old more complex and subtle rules.

Signed-off-by: Roman Zippel <zippel@linux-m68k.org>
Tested-by: Adrian Bunk <bunk@kernel.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
  • Loading branch information
Roman Zippel authored and sravnborg committed Feb 13, 2008
1 parent 10270d4 commit 587c906
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions scripts/kconfig/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,22 +298,30 @@ void sym_calc_value(struct symbol *sym)
if (sym_is_choice_value(sym) && sym->visible == yes) {
prop = sym_get_choice_prop(sym);
newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
} else if (EXPR_OR(sym->visible, sym->rev_dep.tri) != no) {
sym->flags |= SYMBOL_WRITE;
if (sym_has_value(sym))
newval.tri = sym->def[S_DEF_USER].tri;
else if (!sym_is_choice(sym)) {
prop = sym_get_default_prop(sym);
if (prop)
newval.tri = expr_calc_value(prop->expr);
} else {
if (sym->visible != no) {
/* if the symbol is visible use the user value
* if available, otherwise try the default value
*/
sym->flags |= SYMBOL_WRITE;
if (sym_has_value(sym)) {
newval.tri = EXPR_AND(sym->def[S_DEF_USER].tri,
sym->visible);
goto calc_newval;
}
}
newval.tri = EXPR_OR(EXPR_AND(newval.tri, sym->visible), sym->rev_dep.tri);
} else if (!sym_is_choice(sym)) {
prop = sym_get_default_prop(sym);
if (prop) {
if (sym->rev_dep.tri != no)
sym->flags |= SYMBOL_WRITE;
newval.tri = expr_calc_value(prop->expr);
if (!sym_is_choice(sym)) {
prop = sym_get_default_prop(sym);
if (prop) {
sym->flags |= SYMBOL_WRITE;
newval.tri = EXPR_AND(expr_calc_value(prop->expr),
prop->visible.tri);
}
}
calc_newval:
newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);
}
if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN)
newval.tri = yes;
Expand Down

0 comments on commit 587c906

Please sign in to comment.