Commit 7cd34300 authored by Sergey Senozhatsky's avatar Sergey Senozhatsky Committed by Masahiro Yamada

kconfig: add warn-unknown-symbols sanity check

Introduce KCONFIG_WARN_UNKNOWN_SYMBOLS environment variable,
which makes Kconfig warn about unknown config symbols.

This is especially useful for continuous kernel uprevs when
some symbols can be either removed or renamed between kernel
releases (which can go unnoticed otherwise).

By default KCONFIG_WARN_UNKNOWN_SYMBOLS generates warnings,
which are non-terminal. There is an additional environment
variable KCONFIG_WERROR that overrides this behaviour and
turns warnings into errors.
Signed-off-by: default avatarSergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent bfb41e46
...@@ -54,6 +54,15 @@ KCONFIG_OVERWRITECONFIG ...@@ -54,6 +54,15 @@ KCONFIG_OVERWRITECONFIG
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
break symlinks when .config is a symlink to somewhere else. break symlinks when .config is a symlink to somewhere else.
KCONFIG_WARN_UNKNOWN_SYMBOLS
----------------------------
This environment variable makes Kconfig warn about all unrecognized
symbols in the config input.
KCONFIG_WERROR
--------------
If set, Kconfig treats warnings as errors.
`CONFIG_` `CONFIG_`
--------- ---------
If you set `CONFIG_` in the environment, Kconfig will prefix all symbols If you set `CONFIG_` in the environment, Kconfig will prefix all symbols
......
...@@ -349,7 +349,11 @@ int conf_read_simple(const char *name, int def) ...@@ -349,7 +349,11 @@ int conf_read_simple(const char *name, int def)
char *p, *p2; char *p, *p2;
struct symbol *sym; struct symbol *sym;
int i, def_flags; int i, def_flags;
const char *warn_unknown;
const char *werror;
warn_unknown = getenv("KCONFIG_WARN_UNKNOWN_SYMBOLS");
werror = getenv("KCONFIG_WERROR");
if (name) { if (name) {
in = zconf_fopen(name); in = zconf_fopen(name);
} else { } else {
...@@ -437,6 +441,10 @@ int conf_read_simple(const char *name, int def) ...@@ -437,6 +441,10 @@ int conf_read_simple(const char *name, int def)
if (def == S_DEF_USER) { if (def == S_DEF_USER) {
sym = sym_find(line + 2 + strlen(CONFIG_)); sym = sym_find(line + 2 + strlen(CONFIG_));
if (!sym) { if (!sym) {
if (warn_unknown)
conf_warning("unknown symbol: %s",
line + 2 + strlen(CONFIG_));
conf_set_changed(true); conf_set_changed(true);
continue; continue;
} }
...@@ -471,7 +479,7 @@ int conf_read_simple(const char *name, int def) ...@@ -471,7 +479,7 @@ int conf_read_simple(const char *name, int def)
sym = sym_find(line + strlen(CONFIG_)); sym = sym_find(line + strlen(CONFIG_));
if (!sym) { if (!sym) {
if (def == S_DEF_AUTO) if (def == S_DEF_AUTO) {
/* /*
* Reading from include/config/auto.conf * Reading from include/config/auto.conf
* If CONFIG_FOO previously existed in * If CONFIG_FOO previously existed in
...@@ -479,8 +487,13 @@ int conf_read_simple(const char *name, int def) ...@@ -479,8 +487,13 @@ int conf_read_simple(const char *name, int def)
* include/config/FOO must be touched. * include/config/FOO must be touched.
*/ */
conf_touch_dep(line + strlen(CONFIG_)); conf_touch_dep(line + strlen(CONFIG_));
else } else {
if (warn_unknown)
conf_warning("unknown symbol: %s",
line + strlen(CONFIG_));
conf_set_changed(true); conf_set_changed(true);
}
continue; continue;
} }
...@@ -519,6 +532,10 @@ int conf_read_simple(const char *name, int def) ...@@ -519,6 +532,10 @@ int conf_read_simple(const char *name, int def)
} }
free(line); free(line);
fclose(in); fclose(in);
if (conf_warnings && werror)
exit(1);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment