From: Pavel Roskin <proski@xxxxxxx> If -Wall is specified, enable all warnings except those explicitly disabled by -Wno-* switches. Signed-off-by: Pavel Roskin <proski@xxxxxxx> --- lib.c | 30 +++++++++++++++++++++++++++--- 1 files changed, 27 insertions(+), 3 deletions(-) diff --git a/lib.c b/lib.c index feb755a..faafdf8 100644 --- a/lib.c +++ b/lib.c @@ -325,24 +325,37 @@ static const struct warning { { "shadow", &Wshadow }, }; +enum { + WARNING_OFF, + WARNING_ON, + WARNING_FORCE_OFF +}; + static char **handle_switch_W(char *arg, char **next) { - int no = 0; + int flag = WARNING_ON; char *p = arg + 1; unsigned i; + if (!strcmp(p, "all")) { + for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) { + if (*warnings[i].flag != WARNING_FORCE_OFF) + *warnings[i].flag = WARNING_ON; + } + } + // Prefixes "no" and "no-" mean to turn warning off. if (p[0] == 'n' && p[1] == 'o') { p += 2; if (p[0] == '-') p++; - no = 1; + flag = WARNING_FORCE_OFF; } for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) { if (!strcmp(p,warnings[i].name)) { - *warnings[i].flag = !no; + *warnings[i].flag = flag; return next; } } @@ -351,6 +364,16 @@ static char **handle_switch_W(char *arg, return next; } +static void handle_switch_W_finalize(void) +{ + unsigned i; + + for (i = 0; i < sizeof(warnings) / sizeof(warnings[0]); i++) { + if (*warnings[i].flag == WARNING_FORCE_OFF) + *warnings[i].flag = WARNING_OFF; + } +} + static char **handle_switch_U(char *arg, char **next) { const char *name = arg + 1; @@ -608,6 +631,7 @@ struct symbol_list *sparse_initialize(in */ argv[files++] = arg; } + handle_switch_W_finalize(); list = NULL; argv[files] = NULL; - To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html