Skip to content

Commit a7d4f58

Browse files
committed
kconfig: fix missing '# end of' for empty menu
Currently, "# end of ..." is inserted when the menu goes back to its parent. Hence, an empty menu: menu "Foo" endmenu ... ends up with unbalanced menu comments, like this: # # Foo # Let's close the menu comments properly: # # Foo # # end of Foo Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
1 parent 868653f commit a7d4f58

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

scripts/kconfig/confdata.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -903,19 +903,20 @@ int conf_write(const char *name)
903903
menu = menu->list;
904904
continue;
905905
}
906-
if (menu->next)
906+
907+
end_check:
908+
if (!menu->sym && menu_is_visible(menu) && menu != &rootmenu &&
909+
menu->prompt->type == P_MENU) {
910+
fprintf(out, "# end of %s\n", menu_get_prompt(menu));
911+
need_newline = true;
912+
}
913+
914+
if (menu->next) {
907915
menu = menu->next;
908-
else while ((menu = menu->parent)) {
909-
if (!menu->sym && menu_is_visible(menu) &&
910-
menu != &rootmenu) {
911-
str = menu_get_prompt(menu);
912-
fprintf(out, "# end of %s\n", str);
913-
need_newline = true;
914-
}
915-
if (menu->next) {
916-
menu = menu->next;
917-
break;
918-
}
916+
} else {
917+
menu = menu->parent;
918+
if (menu)
919+
goto end_check;
919920
}
920921
}
921922
fclose(out);

0 commit comments

Comments
 (0)