1

kconfig: refactor conf_set_all_new_symbols() to reduce indentation level

The outer switch statement can be avoided by continue'ing earlier the
loop when the symbol type is neither S_BOOLEAN nor S_TRISTATE.

Remove it to reduce the indentation level by one. In addition, avoid
the repetition of sym->def[S_DEF_USER].tri.

No functional change intended.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
This commit is contained in:
Masahiro Yamada 2024-06-02 21:54:15 +09:00
parent fde192511b
commit 826ee96dd4

View File

@ -218,43 +218,42 @@ static bool conf_set_all_new_symbols(enum conf_def_mode mode)
} }
for_all_symbols(sym) { for_all_symbols(sym) {
if (sym_has_value(sym) || sym->flags & SYMBOL_VALID) tristate val;
if (sym_has_value(sym) || sym->flags & SYMBOL_VALID ||
(sym->type != S_BOOLEAN && sym->type != S_TRISTATE))
continue; continue;
switch (sym_get_type(sym)) {
case S_BOOLEAN: has_changed = true;
case S_TRISTATE: switch (mode) {
has_changed = true; case def_yes:
switch (mode) { val = yes;
case def_yes: break;
sym->def[S_DEF_USER].tri = yes; case def_mod:
break; val = mod;
case def_mod: break;
sym->def[S_DEF_USER].tri = mod; case def_no:
break; val = no;
case def_no: break;
sym->def[S_DEF_USER].tri = no; case def_random:
break; val = no;
case def_random: cnt = rand() % 100;
sym->def[S_DEF_USER].tri = no; if (sym->type == S_TRISTATE) {
cnt = rand() % 100; if (cnt < pty)
if (sym->type == S_TRISTATE) { val = yes;
if (cnt < pty) else if (cnt < pty + ptm)
sym->def[S_DEF_USER].tri = yes; val = mod;
else if (cnt < pty + ptm) } else if (cnt < pby) {
sym->def[S_DEF_USER].tri = mod; val = yes;
} else if (cnt < pby)
sym->def[S_DEF_USER].tri = yes;
break;
default:
continue;
} }
if (!(sym_is_choice(sym) && mode == def_random))
sym->flags |= SYMBOL_DEF_USER;
break; break;
default: default:
break; continue;
} }
sym->def[S_DEF_USER].tri = val;
if (!(sym_is_choice(sym) && mode == def_random))
sym->flags |= SYMBOL_DEF_USER;
} }
sym_clear_all_valid(); sym_clear_all_valid();