Skip to contentSkip to conversation

kconfig: Terminate menu blocks with a comment in the generated config

PATCH Superseded Alexander Popov 3 participants 5 messages Apr 24, 2019 – May 7, 2019

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 kconfig: Terminate menu blocks with a comment in the generated config

Currently menu blocks start with a pretty header but end with nothing in the generated config. So next config options stick together with the options from the menu block.

Let's terminate menu blocks in the generated config with a comment and a newline if needed. Example:

...
CONFIG_BPF_STREAM_PARSER=y
CONFIG_NET_FLOW_LIMIT=y

#
# Network testing
#
CONFIG_NET_PKTGEN=y
CONFIG_NET_DROP_MONITOR=y

# end of Network testing
# end of Networking options

CONFIG_HAMRADIO=y
...

---
 scripts/kconfig/confdata.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
scripts/kconfig/confdata.c +11 -1
index 08ba146..486b4c7 100644
@@ -819,6 +819,7 @@ int conf_write(const char *name)
 	struct menu *menu;
 	const char *basename;
 	const char *str;
+	bool need_newline = false;
 	char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8];
 	char *env;
 
@@ -871,12 +872,16 @@ int conf_write(const char *name)
 				     "#\n"
 				     "# %s\n"
 				     "#\n", str);
+			need_newline = false;
 		} else if (!(sym->flags & SYMBOL_CHOICE)) {
 			sym_calc_value(sym);
 			if (!(sym->flags & SYMBOL_WRITE))
 				goto next;
+			if (need_newline) {
+				fprintf(out, "\n");
+				need_newline = false;
+			}
 			sym->flags &= ~SYMBOL_WRITE;
-
 			conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
 		}
 
@@ -888,6 +893,11 @@ int conf_write(const char *name)
 		if (menu->next)
 			menu = menu->next;
 		else while ((menu = menu->parent)) {
+			if (!menu->sym && menu_is_visible(menu)) {
+				str = menu_get_prompt(menu);
+				fprintf(out, "# end of %s\n", str);
+				need_newline = true;
+			}
 			if (menu->next) {
 				menu = menu->next;
 				break;
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 17 lines · Alexander Popov

Currently menu blocks start with a pretty header but end with nothing in the generated config. So next config options stick together with the options from the menu block.

Let's terminate menu blocks in the generated config with a comment and a newline if needed. Example:

...
CONFIG_BPF_STREAM_PARSER=y
CONFIG_NET_FLOW_LIMIT=y

#
# Network testing
#
CONFIG_NET_PKTGEN=y
CONFIG_NET_DROP_MONITOR=y

Quoted 7 lines
# end of Network testing
# end of Networking options

CONFIG_HAMRADIO=y
...

-Kees

Quoted 49 lines
---
 scripts/kconfig/confdata.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
scripts/kconfig/confdata.c +11 -2
index 08ba146..486b4c7 100644
@@ -819,6 +819,7 @@ int conf_write(const char *name)
        struct menu *menu;
        const char *basename;
        const char *str;
+       bool need_newline = false;
        char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8];
        char *env;
 
@@ -871,12 +872,16 @@ int conf_write(const char *name)
                                     "#\n"
                                     "# %s\n"
                                     "#\n", str);
+                       need_newline = false;
                } else if (!(sym->flags & SYMBOL_CHOICE)) {
                        sym_calc_value(sym);
                        if (!(sym->flags & SYMBOL_WRITE))
                                goto next;
+                       if (need_newline) {
+                               fprintf(out, "\n");
+                               need_newline = false;
+                       }
                        sym->flags &= ~SYMBOL_WRITE;
-
                        conf_write_symbol(out, sym, &kconfig_printer_cb, NULL);
                }
 
@@ -888,6 +893,11 @@ int conf_write(const char *name)
                if (menu->next)
                        menu = menu->next;
                else while ((menu = menu->parent)) {
+                       if (!menu->sym && menu_is_visible(menu)) {
+                               str = menu_get_prompt(menu);
+                               fprintf(out, "# end of %s\n", str);
+                               need_newline = true;
+                       }
                        if (menu->next) {
                                menu = menu->next;
                                break;
--

2.7.4

Signature · 1 line
Kees Cook
#2 lore raw
In reply to Alexander Popov
Quoted 16 lines · Alexander Popov

Currently menu blocks start with a pretty header but end with nothing in the generated config. So next config options stick together with the options from the menu block.

Let's terminate menu blocks in the generated config with a comment and a newline if needed. Example:

...
CONFIG_BPF_STREAM_PARSER=y
CONFIG_NET_FLOW_LIMIT=y

#
# Network testing
#
CONFIG_NET_PKTGEN=y
CONFIG_NET_DROP_MONITOR=y

Quoted 7 lines
# end of Network testing
# end of Networking options

CONFIG_HAMRADIO=y
...

Hello!

Just a friendly ping.

Would you like to take this patch?
Can I improve anything?

Best regards,
Alexander

#3 lore raw
Quoted 24 lines · Alexander Popov
Quoted 22 lines · Alexander Popov

Currently menu blocks start with a pretty header but end with nothing in the generated config. So next config options stick together with the options from the menu block.

Let's terminate menu blocks in the generated config with a comment and a newline if needed. Example:

...
CONFIG_BPF_STREAM_PARSER=y
CONFIG_NET_FLOW_LIMIT=y

#
# Network testing
#
CONFIG_NET_PKTGEN=y
CONFIG_NET_DROP_MONITOR=y

# end of Network testing
# end of Networking options

CONFIG_HAMRADIO=y
...

Quoted 8 lines
Quoted 1 line

Hello!

Just a friendly ping.

Would you like to take this patch?
Can I improve anything?

This patch breaks "make testconfig".

Please get rid of the "endof" for the rootmenu
at the end of the .config file.

Thanks.

Quoted 2 lines

Best regards,
Alexander

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw
Quoted 4 lines · Masahiro Yamada

This patch breaks "make testconfig".

Please get rid of the "endof" for the rootmenu
at the end of the .config file.

Thanks a lot for having a look!
I'll fix this issue, test it and return with the next version.

Best regards,
Alexander