aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-09-13 08:52:18 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-01-03 02:52:20 +0100
commitf4de73d6094288e6e41e9121fd11622f75a19c6a (patch)
treeca8fdcd00360c80ab6c1791c7e8f5b02d7589855
parent1e1a172fe5c7156f683b88c04466f0312525e6a0 (diff)
downloadsparse-dev-f4de73d6094288e6e41e9121fd11622f75a19c6a.tar.gz
teach sparse about '-fmax-warnings'
Currently, sparse stops to emit warnings after the 100th. This is, of course, to avoid to throw lots of warnings if the source file has lots of problems but sometimes we want to see all warnings & errors. For example, it's useful when testing a new version of sparse on the kernel since it has a few files with more than 100 warnings (and so a bad change will be undetected if it affects warnings only after the 100th). Let parse the '-fmax-warnings=N' option and limit the number of warnings accordingly. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--lib.c14
-rw-r--r--lib.h1
-rw-r--r--sparse.16
3 files changed, 18 insertions, 3 deletions
diff --git a/lib.c b/lib.c
index e4bb639e..4094f907 100644
--- a/lib.c
+++ b/lib.c
@@ -115,7 +115,7 @@ static void do_warn(const char *type, struct position pos, const char * fmt, va_
name, pos.line, pos.pos, type, buffer);
}
-static int max_warnings = 100;
+unsigned int fmax_warnings = 100;
static int show_info = 1;
void info(struct position pos, const char * fmt, ...)
@@ -160,12 +160,12 @@ void warning(struct position pos, const char * fmt, ...)
return;
}
- if (!max_warnings || has_error) {
+ if (!fmax_warnings || has_error) {
show_info = 0;
return;
}
- if (!--max_warnings) {
+ if (!--fmax_warnings) {
show_info = 0;
fmt = "too many warnings";
}
@@ -611,6 +611,7 @@ static int opt_##NAME(const char *arg, const char *opt, TYPE *ptr, int flag) \
}
OPT_NUMERIC(ullong, unsigned long long, strtoull)
+OPT_NUMERIC(uint, unsigned int, strtoul)
static char **handle_switch_o(char *arg, char **next)
@@ -869,8 +870,15 @@ static int handle_fmemcpy_max_count(const char *arg, const char *opt, const stru
return 1;
}
+static int handle_fmax_warnings(const char *arg, const char *opt, const struct flag *flag, int options)
+{
+ opt_uint(arg, opt, &fmax_warnings, OPTNUM_UNLIMITED);
+ return 1;
+}
+
static struct flag fflags[] = {
{ "dump-ir", NULL, handle_fdump_ir },
+ { "max-warnings=", NULL, handle_fmax_warnings },
{ "mem-report", &fmem_report },
{ "memcpy-max-count=", NULL, handle_fmemcpy_max_count },
{ "tabstop=", NULL, handle_ftabstop },
diff --git a/lib.h b/lib.h
index b0f34265..72685934 100644
--- a/lib.h
+++ b/lib.h
@@ -167,6 +167,7 @@ extern int dump_macro_defs;
extern int dbg_entry;
extern int dbg_dead;
+extern unsigned int fmax_warnings;
extern int fmem_report;
extern unsigned long fdump_ir;
extern unsigned long long fmemcpy_max_count;
diff --git a/sparse.1 b/sparse.1
index 5b2bcd9c..2d3011a1 100644
--- a/sparse.1
+++ b/sparse.1
@@ -20,6 +20,12 @@ off those warnings, pass the negation of the associated warning option,
.
.SH WARNING OPTIONS
.TP
+.B \-fmax-warnings=COUNT
+Set the maximum number of displayed warnings to COUNT, which should be
+a numerical value or 'unlimited'.
+The default limit is 100.
+.
+.TP
.B \-Wsparse\-all
Turn on all sparse warnings, except for those explicitly disabled via
\fB\-Wno\-something\fR.