From: Alexander Popov Date: Fri, 17 May 2019 19:42:22 +0000 (+0300) Subject: kconfig: Terminate menu blocks with a comment in the generated config X-Git-Url: https://jxself.org/git/?p=carl9170fw.git;a=commitdiff_plain;h=7b1214ae732be753158ec3c004d232c3c2dfc592 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 ... Signed-off-by: Alexander Popov Reviewed-by: Kees Cook Signed-off-by: Masahiro Yamada Signed-off-by: Christian Lamparter --- diff --git a/config/confdata.c b/config/confdata.c index 24b7e46..695253e 100644 --- a/config/confdata.c +++ b/config/confdata.c @@ -913,6 +913,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(); @@ -958,12 +959,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); } @@ -975,6 +980,12 @@ next: 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;