Skip to content

Commit

Permalink
kconfig: use linked list in get_symbol_str() to iterate over menus
Browse files Browse the repository at this point in the history
Currently, get_symbol_str() uses a tricky approach to traverse the
associated menus.

With relevant menus now linked to the symbol using a linked list,
use list_for_each_entry() for iterating on the menus.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
  • Loading branch information
Masahiro Yamada committed Mar 9, 2024
1 parent e049221 commit bedf923
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions scripts/kconfig/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
struct list_head *head)
{
struct property *prop;
struct menu *menu;

if (sym && sym->name) {
str_printf(r, "Symbol: %s [=%s]\n", sym->name,
Expand All @@ -787,17 +788,17 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym,
}

/* Print the definitions with prompts before the ones without */
for_all_properties(sym, prop, P_SYMBOL) {
if (prop->menu->prompt) {
get_def_str(r, prop->menu);
get_prompt_str(r, prop->menu->prompt, head);
list_for_each_entry(menu, &sym->menus, link) {
if (menu->prompt) {
get_def_str(r, menu);
get_prompt_str(r, menu->prompt, head);
}
}

for_all_properties(sym, prop, P_SYMBOL) {
if (!prop->menu->prompt) {
get_def_str(r, prop->menu);
get_dep_str(r, prop->menu->dep, " Depends on: ");
list_for_each_entry(menu, &sym->menus, link) {
if (!menu->prompt) {
get_def_str(r, menu);
get_dep_str(r, menu->dep, " Depends on: ");
}
}

Expand Down

0 comments on commit bedf923

Please sign in to comment.