Skip to content

Commit 9d1a9e8

Browse files
ulfalizermasahir0y
authored andcommitted
kconfig: Document 'if' flattening logic
It is not obvious that this might refer to an 'if', making the code pretty cryptic: if (menu->list && (!menu->prompt || !menu->prompt->text)) { Kconfig keeps the 'if' menu nodes even after flattening. Reflect that in the example to be accurate. No functional changes. Only comments added. Signed-off-by: Ulf Magnusson <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent d3465af commit 9d1a9e8

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

scripts/kconfig/menu.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,35 @@ void menu_finalize(struct menu *parent)
532532
*ep = expr_alloc_one(E_LIST, NULL);
533533
(*ep)->right.sym = menu->sym;
534534
}
535+
536+
/*
537+
* This code serves two purposes:
538+
*
539+
* (1) Flattening 'if' blocks, which do not specify a submenu
540+
* and only add dependencies.
541+
*
542+
* (Automatic submenu creation might still create a submenu
543+
* from an 'if' before this code runs.)
544+
*
545+
* (2) "Undoing" any automatic submenus created earlier below
546+
* promptless symbols.
547+
*
548+
* Before:
549+
*
550+
* A
551+
* if ... (or promptless symbol)
552+
* +-B
553+
* +-C
554+
* D
555+
*
556+
* After:
557+
*
558+
* A
559+
* if ... (or promptless symbol)
560+
* B
561+
* C
562+
* D
563+
*/
535564
if (menu->list && (!menu->prompt || !menu->prompt->text)) {
536565
for (last_menu = menu->list; ; last_menu = last_menu->next) {
537566
last_menu->parent = parent;

0 commit comments

Comments
 (0)