Skip to content

Commit

Permalink
kconfig: Terminate menu blocks with a comment in the generated config
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Masahiro Yamada <[email protected]>
  • Loading branch information
a13xp0p0v authored and masahir0y committed May 18, 2019
1 parent 233c741 commit aff11cd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}

Expand All @@ -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;
Expand Down

0 comments on commit aff11cd

Please sign in to comment.