Skip to content

Commit 03c4eca

Browse files
committed
kconfig: use menu_for_each_entry() to traverse menu tree
Use menu_for_each_entry() to traverse the menu tree instead of implementing similar logic in each function. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 7284b4f commit 03c4eca

2 files changed

Lines changed: 6 additions & 35 deletions

File tree

scripts/kconfig/confdata.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -793,23 +793,19 @@ int conf_write_defconfig(const char *filename)
793793

794794
sym_clear_all_valid();
795795

796-
/* Traverse all menus to find all relevant symbols */
797-
menu = rootmenu.list;
798-
799-
while (menu != NULL)
800-
{
796+
menu_for_each_entry(menu) {
801797
sym = menu->sym;
802798
if (sym && !sym_is_choice(sym)) {
803799
sym_calc_value(sym);
804800
if (!(sym->flags & SYMBOL_WRITE))
805-
goto next_menu;
801+
continue;
806802
sym->flags &= ~SYMBOL_WRITE;
807803
/* If we cannot change the symbol - skip */
808804
if (!sym_is_changeable(sym))
809-
goto next_menu;
805+
continue;
810806
/* If symbol equals to default value - skip */
811807
if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0)
812-
goto next_menu;
808+
continue;
813809

814810
/*
815811
* If symbol is a choice value and equals to the
@@ -827,25 +823,11 @@ int conf_write_defconfig(const char *filename)
827823
if (!sym_is_optional(cs) && sym == ds) {
828824
if ((sym->type == S_BOOLEAN) &&
829825
sym_get_tristate_value(sym) == yes)
830-
goto next_menu;
826+
continue;
831827
}
832828
}
833829
print_symbol_for_dotconfig(out, sym);
834830
}
835-
next_menu:
836-
if (menu->list != NULL) {
837-
menu = menu->list;
838-
}
839-
else if (menu->next != NULL) {
840-
menu = menu->next;
841-
} else {
842-
while ((menu = menu->parent)) {
843-
if (menu->next != NULL) {
844-
menu = menu->next;
845-
break;
846-
}
847-
}
848-
}
849831
}
850832
fclose(out);
851833
return 0;

scripts/kconfig/parser.y

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -517,20 +517,9 @@ void conf_parse(const char *name)
517517

518518
menu_finalize();
519519

520-
menu = &rootmenu;
521-
while (menu) {
520+
menu_for_each_entry(menu) {
522521
if (menu->sym && sym_check_deps(menu->sym))
523522
yynerrs++;
524-
525-
if (menu->list) {
526-
menu = menu->list;
527-
continue;
528-
}
529-
530-
while (!menu->next && menu->parent)
531-
menu = menu->parent;
532-
533-
menu = menu->next;
534523
}
535524

536525
if (yynerrs)

0 commit comments

Comments
 (0)