Message ID | 1438619759-14879-1-git-send-email-tcamuso@redhat.com (mailing list archive) |
---|---|
State | Rejected, archived |
Headers | show |
On Mon, Aug 03, 2015 at 12:35:59PM -0400, Tony Camuso wrote: > Disable all error reporting. Useful when semantic parsing checks are > being done elsewhere or all you need is a tokenizer. > > Signed-off-by: Tony Camuso <tcamuso@redhat.com> > --- > lib.c | 27 +++++++++++++++++++++++---- > lib.h | 1 + > 2 files changed, 24 insertions(+), 4 deletions(-) > > diff --git a/lib.c b/lib.c > index 8dc5bcf..08f6a6b 100644 > --- a/lib.c > +++ b/lib.c ... > @@ -130,6 +135,12 @@ void info(struct position pos, const char * fmt, ...) > static void do_error(struct position pos, const char * fmt, va_list args) > { > static int errors = 0; > + > + if (Wall_off) { > + max_warnings = 0; > + return; > + } > + Is this really needed? The same check in do_warn should be enough to quiet all messages, isn't it? > @@ -479,6 +491,13 @@ static char **handle_onoff_switch(char *arg, char **next, const struct warning w > char *p = arg + 1; > unsigned i; > > + if (!strcmp(p, "all_off")) { > + for (i = 0; i < n; i++) > + *warnings[i].flag = WARNING_FORCE_OFF; > + Wall_off = 1; > + return NULL; > + } > + Can't you simply set max_warnings to 0 already here instead of doing it in do_warn()? > @@ -127,6 +127,7 @@ extern int Wtypesign; > extern int Wundef; > extern int Wuninitialized; > extern int Wvla; > +extern int Wall_off; I think it should be better to use a much more explicit name, something like "ignore_all_warnings" for example. Also it would be nice to document this new option in the man page. Regards, Luc -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 01/04/2016 08:19 PM, Luc Van Oostenryck wrote: > On Mon, Aug 03, 2015 at 12:35:59PM -0400, Tony Camuso wrote: >> Disable all error reporting. Useful when semantic parsing checks are >> being done elsewhere or all you need is a tokenizer. >> >> Signed-off-by: Tony Camuso <tcamuso@redhat.com> >> --- >> lib.c | 27 +++++++++++++++++++++++---- >> lib.h | 1 + >> 2 files changed, 24 insertions(+), 4 deletions(-) >> >> diff --git a/lib.c b/lib.c >> index 8dc5bcf..08f6a6b 100644 >> --- a/lib.c >> +++ b/lib.c > > ... > >> @@ -130,6 +135,12 @@ void info(struct position pos, const char * fmt, ...) >> static void do_error(struct position pos, const char * fmt, va_list args) >> { >> static int errors = 0; >> + >> + if (Wall_off) { >> + max_warnings = 0; >> + return; >> + } >> + > > Is this really needed? > The same check in do_warn should be enough to quiet all messages, isn't it? I'll test again to be certain, but IIRC, I needed it there, too. If I don't need it there, I will drop it in a new version of the patch. > >> @@ -479,6 +491,13 @@ static char **handle_onoff_switch(char *arg, char **next, const struct warning w >> char *p = arg + 1; >> unsigned i; >> >> + if (!strcmp(p, "all_off")) { >> + for (i = 0; i < n; i++) >> + *warnings[i].flag = WARNING_FORCE_OFF; >> + Wall_off = 1; >> + return NULL; >> + } >> + > > Can't you simply set max_warnings to 0 already here > instead of doing it in do_warn()? Yes, I will do that. It does make more sense in that block. >> @@ -127,6 +127,7 @@ extern int Wtypesign; >> extern int Wundef; >> extern int Wuninitialized; >> extern int Wvla; >> +extern int Wall_off; > > I think it should be better to use a much more explicit name, > something like "ignore_all_warnings" for example. Also will do that. > Also it would be nice to document this new option in the man page. I'll add this to the patch. > > Regards, > Luc > Ciao, Tony -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/lib.c b/lib.c index 8dc5bcf..08f6a6b 100644 --- a/lib.c +++ b/lib.c @@ -101,21 +101,26 @@ unsigned int hexval(unsigned int c) return retval; } +static int max_warnings = 100; +static int show_info = 1; + static void do_warn(const char *type, struct position pos, const char * fmt, va_list args) { static char buffer[512]; const char *name; - vsprintf(buffer, fmt, args); + if (Wall_off) { + max_warnings = 0; + return; + } + + vsprintf(buffer, fmt, args); name = stream_name(pos.stream); fprintf(stderr, "%s:%d:%d: %s%s\n", name, pos.line, pos.pos, type, buffer); } -static int max_warnings = 100; -static int show_info = 1; - void info(struct position pos, const char * fmt, ...) { va_list args; @@ -130,6 +135,12 @@ void info(struct position pos, const char * fmt, ...) static void do_error(struct position pos, const char * fmt, va_list args) { static int errors = 0; + + if (Wall_off) { + max_warnings = 0; + return; + } + die_if_error = 1; show_info = 1; /* Shut up warnings after an error */ @@ -241,6 +252,7 @@ int Wtypesign = 0; int Wundef = 0; int Wuninitialized = 1; int Wvla = 1; +int Wall_off = 0; int dbg_entry = 0; int dbg_dead = 0; @@ -479,6 +491,13 @@ static char **handle_onoff_switch(char *arg, char **next, const struct warning w char *p = arg + 1; unsigned i; + if (!strcmp(p, "all_off")) { + for (i = 0; i < n; i++) + *warnings[i].flag = WARNING_FORCE_OFF; + Wall_off = 1; + return NULL; + } + if (!strcmp(p, "sparse-all")) { for (i = 0; i < n; i++) { if (*warnings[i].flag != WARNING_FORCE_OFF && warnings[i].flag != &Wsparse_error) diff --git a/lib.h b/lib.h index 15b69fa..65e4836 100644 --- a/lib.h +++ b/lib.h @@ -127,6 +127,7 @@ extern int Wtypesign; extern int Wundef; extern int Wuninitialized; extern int Wvla; +extern int Wall_off; extern int dbg_entry; extern int dbg_dead;
Disable all error reporting. Useful when semantic parsing checks are being done elsewhere or all you need is a tokenizer. Signed-off-by: Tony Camuso <tcamuso@redhat.com> --- lib.c | 27 +++++++++++++++++++++++---- lib.h | 1 + 2 files changed, 24 insertions(+), 4 deletions(-)