diff mbox

[v2,1/2] kconfig: Document 'if' flattening logic

Message ID 20180114144926.29162-1-ulfalizer@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ulf Magnusson Jan. 14, 2018, 2:49 p.m. UTC
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 <ulfalizer@gmail.com>
---
Changelog

v2:
I forgot to mention that this code also undoes automatic submenus created below
promptless symbols.

 scripts/kconfig/menu.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

Comments

Masahiro Yamada Jan. 21, 2018, 4:47 p.m. UTC | #1
2018-01-14 23:49 GMT+09:00 Ulf Magnusson <ulfalizer@gmail.com>:
> 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 <ulfalizer@gmail.com>
> ---
> Changelog
>
> v2:
> I forgot to mention that this code also undoes automatic submenus created below
> promptless symbols.
>
>  scripts/kconfig/menu.c | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
>

Applied to linux-kbuild/kconfig.  Thanks!
diff mbox

Patch

diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 53964d911708..a8af08aabfd6 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -531,6 +531,35 @@  void menu_finalize(struct menu *parent)
 			*ep = expr_alloc_one(E_LIST, NULL);
 			(*ep)->right.sym = menu->sym;
 		}
+
+		/*
+		 * This code serves two purposes:
+		 *
+		 * (1) Flattening 'if' blocks, which do not specify a submenu
+		 *     and only add dependencies.
+		 *
+		 *     (Automatic submenu creation might still create a submenu
+		 *     from an 'if' before this code runs.)
+		 *
+		 * (2) "Undoing" any automatic submenus created earlier below
+		 *     promptless symbols.
+		 *
+		 * Before:
+		 *
+		 *	A
+		 *	if ... (or promptless symbol)
+		 *	 +-B
+		 *	 +-C
+		 *	D
+		 *
+		 * After:
+		 *
+		 *	A
+		 *	if ... (or promptless symbol)
+		 *	B
+		 *	C
+		 *	D
+		 */
 		if (menu->list && (!menu->prompt || !menu->prompt->text)) {
 			for (last_menu = menu->list; ; last_menu = last_menu->next) {
 				last_menu->parent = parent;