linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [v3 1/1] kconfig: Terminate menu blocks with a comment in the generated config
@ 2019-05-17 19:42 Alexander Popov
  2019-05-18  6:30 ` Masahiro Yamada
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Popov @ 2019-05-17 19:42 UTC (permalink / raw)
  To: Masahiro Yamada, Kees Cook, Michal Marek, linux-kbuild,
	linux-kernel, 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
...

Signed-off-by: Alexander Popov <alex.popov@linux.com>
---

v3 changes:
 - rebase onto the recent rc;
 - don't print the end comment for the rootmenu to avoid breaking
   'make testconfig' (thanks to Masahiro Yamada).

---
 scripts/kconfig/confdata.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 492ac34..6006154 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -867,6 +867,7 @@ int conf_write(const char *name)
 	const char *str;
 	char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
 	char *env;
+	bool need_newline = false;
 
 	if (!name)
 		name = conf_get_configname();
@@ -912,12 +913,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);
 		}
 
@@ -929,6 +934,12 @@ int conf_write(const char *name)
 		if (menu->next)
 			menu = menu->next;
 		else while ((menu = menu->parent)) {
+			if (!menu->sym && menu_is_visible(menu) &&
+			    menu != &rootmenu) {
+				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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [v3 1/1] kconfig: Terminate menu blocks with a comment in the generated config
  2019-05-17 19:42 [v3 1/1] kconfig: Terminate menu blocks with a comment in the generated config Alexander Popov
@ 2019-05-18  6:30 ` Masahiro Yamada
  0 siblings, 0 replies; 2+ messages in thread
From: Masahiro Yamada @ 2019-05-18  6:30 UTC (permalink / raw)
  To: Alexander Popov
  Cc: Kees Cook, Michal Marek, Linux Kbuild mailing list,
	Linux Kernel Mailing List

On Sat, May 18, 2019 at 4:42 AM Alexander Popov <alex.popov@linux.com> wrote:
>
> 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
> ...
>
> Signed-off-by: Alexander Popov <alex.popov@linux.com>


Applied to linux-kbuild. Thanks.



> ---
>
> v3 changes:
>  - rebase onto the recent rc;
>  - don't print the end comment for the rootmenu to avoid breaking
>    'make testconfig' (thanks to Masahiro Yamada).
>
> ---
>  scripts/kconfig/confdata.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 492ac34..6006154 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -867,6 +867,7 @@ int conf_write(const char *name)
>         const char *str;
>         char tmpname[PATH_MAX + 1], oldname[PATH_MAX + 1];
>         char *env;
> +       bool need_newline = false;
>
>         if (!name)
>                 name = conf_get_configname();
> @@ -912,12 +913,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);
>                 }
>
> @@ -929,6 +934,12 @@ int conf_write(const char *name)
>                 if (menu->next)
>                         menu = menu->next;
>                 else while ((menu = menu->parent)) {
> +                       if (!menu->sym && menu_is_visible(menu) &&
> +                           menu != &rootmenu) {
> +                               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
>


-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-05-18  6:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 19:42 [v3 1/1] kconfig: Terminate menu blocks with a comment in the generated config Alexander Popov
2019-05-18  6:30 ` Masahiro Yamada

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).