Skip to content

Commit

Permalink
kconfig: clean up nested if-conditionals in check_conf()
Browse files Browse the repository at this point in the history
Unify the outer two if-conditionals into one. This decreases the
indent level by one.

Also, change the if-else blocks:

    if (input_mode == listnewconfig) {
            ...
    } else if (input_mode == helpnewconfig) {
            ...
    } else {
            ...
    }

into the switch statement.

Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
masahir0y committed Feb 24, 2021
1 parent f82bd80 commit a4cff32
Showing 1 changed file with 29 additions and 26 deletions.
55 changes: 29 additions & 26 deletions scripts/kconfig/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,34 +419,37 @@ static void check_conf(struct menu *menu)
return;

sym = menu->sym;
if (sym && !sym_has_value(sym)) {
if (sym_is_changeable(sym) ||
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) {
if (input_mode == listnewconfig) {
if (sym->name) {
const char *str;

if (sym->type == S_STRING) {
str = sym_get_string_value(sym);
str = sym_escape_string_value(str);
printf("%s%s=%s\n", CONFIG_, sym->name, str);
free((void *)str);
} else {
str = sym_get_string_value(sym);
printf("%s%s=%s\n", CONFIG_, sym->name, str);
}
}
} else if (input_mode == helpnewconfig) {
printf("-----\n");
print_help(menu);
printf("-----\n");
if (sym && !sym_has_value(sym) &&
(sym_is_changeable(sym) ||
(sym_is_choice(sym) && sym_get_tristate_value(sym) == yes))) {

} else {
if (!conf_cnt++)
printf("*\n* Restart config...\n*\n");
rootEntry = menu_get_parent_menu(menu);
conf(rootEntry);
switch (input_mode) {
case listnewconfig:
if (sym->name) {
const char *str;

if (sym->type == S_STRING) {
str = sym_get_string_value(sym);
str = sym_escape_string_value(str);
printf("%s%s=%s\n", CONFIG_, sym->name, str);
free((void *)str);
} else {
str = sym_get_string_value(sym);
printf("%s%s=%s\n", CONFIG_, sym->name, str);
}
}
break;
case helpnewconfig:
printf("-----\n");
print_help(menu);
printf("-----\n");
break;
default:
if (!conf_cnt++)
printf("*\n* Restart config...\n*\n");
rootEntry = menu_get_parent_menu(menu);
conf(rootEntry);
break;
}
}

Expand Down

0 comments on commit a4cff32

Please sign in to comment.