Stefan Reinauer (stefan.reinauer@coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11291
-gerrit
commit 0b13cbe24dd1c9a39d782829a2b4240b25ca22b9 Author: Stefan Reinauer reinauer@chromium.org Date: Thu Aug 20 11:19:34 2015 -0700
kconfig: Allow KCONFIG_STRICT outside of confdata.c
To catch dependency errors in symbol.c (such as the ones fixed by I51b4ee326f082c6a656a813ee5772e9c34f5c343) we need to check for global kconfig warnings before saving config files.
This patch will produce errors for wrong dependencies and add catching of errors to conf, nconf and mconf. Sorry, gconf users, you will have to wait.
Change-Id: Idf7ee406ce3869941af319219aea16fab826df84 Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org --- util/kconfig/conf.c | 10 ++++++++++ util/kconfig/confdata.c | 6 +----- util/kconfig/lkc.h | 3 +++ util/kconfig/mconf.c | 8 ++++++++ util/kconfig/nconf.c | 11 +++++++++++ util/kconfig/symbol.c | 1 + 6 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/util/kconfig/conf.c b/util/kconfig/conf.c index fef75fc..c421773 100644 --- a/util/kconfig/conf.c +++ b/util/kconfig/conf.c @@ -17,6 +17,8 @@
#include "lkc.h"
+int kconfig_warnings = 0; + static void conf(struct menu *menu); static void check_conf(struct menu *menu); static void xfgets(char *str, int size, FILE *in); @@ -493,6 +495,7 @@ int main(int ac, char **av) const char *progname = av[0]; int opt; const char *name, *defconfig_file = NULL /* gcc uninit */; + char *env; struct stat tmpstat;
setlocale(LC_ALL, ""); @@ -681,6 +684,13 @@ int main(int ac, char **av) break; }
+ env = getenv("KCONFIG_STRICT"); + if (env && *env && kconfig_warnings) { + fprintf(stderr, _("\n*** ERROR: %d warnings encountered, and " + "warnings are errors.\n\n"), kconfig_warnings); + exit(1); + } + if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config. diff --git a/util/kconfig/confdata.c b/util/kconfig/confdata.c index 5804b29..a39a716 100644 --- a/util/kconfig/confdata.c +++ b/util/kconfig/confdata.c @@ -404,11 +404,7 @@ setsym: if (modules_sym) sym_calc_value(modules_sym);
- name = getenv("KCONFIG_STRICT"); - if (name && *name && conf_warnings) { - fprintf(stderr, "\nERROR: %d warnings encountered, and warnings are errors.\n\n", conf_warnings); - return 1; - } + kconfig_warnings += conf_warnings;
return 0; } diff --git a/util/kconfig/lkc.h b/util/kconfig/lkc.h index 590ed80..a7600bd 100644 --- a/util/kconfig/lkc.h +++ b/util/kconfig/lkc.h @@ -82,6 +82,9 @@ void zconf_nextfiles(const char *name); int zconf_lineno(void); const char *zconf_curname(void);
+/* conf.c */ +extern int kconfig_warnings; + /* confdata.c */ const char *conf_get_configname(void); const char *conf_get_autoconfig_name(void); diff --git a/util/kconfig/mconf.c b/util/kconfig/mconf.c index 1d651c1..b4a0844 100644 --- a/util/kconfig/mconf.c +++ b/util/kconfig/mconf.c @@ -952,6 +952,7 @@ static void conf_save(void) static int handle_exit(void) { int res; + char *env;
save_and_exit = 1; reset_subtitle(); @@ -966,6 +967,13 @@ static int handle_exit(void)
end_dialog(saved_x, saved_y);
+ env = getenv("KCONFIG_STRICT"); + if (env && *env && kconfig_warnings) { + fprintf(stderr, _("\n*** ERROR: %d warnings encountered, and " + "warnings are errors.\n\n"), kconfig_warnings); + res = 2; + } + switch (res) { case 0: if (conf_write(filename)) { diff --git a/util/kconfig/nconf.c b/util/kconfig/nconf.c index 984489e..bc845fc 100644 --- a/util/kconfig/nconf.c +++ b/util/kconfig/nconf.c @@ -646,6 +646,8 @@ static const char *set_config_filename(const char *config_filename) static int do_exit(void) { int res; + char *env; + if (!conf_get_changed()) { global_exit = 1; return 0; @@ -661,6 +663,15 @@ static int do_exit(void) return -1; }
+ env = getenv("KCONFIG_STRICT"); + if (env && *env && kconfig_warnings) { + btn_dialog(main_window, + _("\nWarnings encountered, and warnings are errors.\n\n"), + 1, + "<OK>"); + res = 2; + } + /* if we got here, the user really wants to exit */ switch (res) { case 0: diff --git a/util/kconfig/symbol.c b/util/kconfig/symbol.c index 7caabdb..65ba465 100644 --- a/util/kconfig/symbol.c +++ b/util/kconfig/symbol.c @@ -375,6 +375,7 @@ void sym_calc_value(struct symbol *sym) sym->name); expr_fprint(sym->dir_dep.expr, stderr); fprintf(stderr, ")\n"); + kconfig_warnings++; expr_free(e); } newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri);