Signed-off-by: John Levon <levon@xxxxxxxxxxxxxxxxx> --- lib.c | 11 +++++++---- lib.h | 2 ++ smatch.c | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib.c b/lib.c index 0f3a05a..985178f 100644 --- a/lib.c +++ b/lib.c @@ -45,6 +45,9 @@ #include "target.h" #include "version.h" +int sparse_errors = 0; +int sparse_warnings = 0; + int verbose, optimize, optimize_size, preprocessing; int die_if_error = 0; int parse_error; @@ -131,14 +134,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; - parse_error = 1; die_if_error = 1; show_info = 1; /* Shut up warnings after an error */ has_error |= ERROR_CURR_PHASE; - if (errors > 100) { + if (sparse_errors > 100) { static int once = 0; show_info = 0; if (once) @@ -148,7 +149,7 @@ static void do_error(struct position pos, const char * fmt, va_list args) } do_warn("error: ", pos, fmt, args); - errors++; + sparse_errors++; } void warning(struct position pos, const char * fmt, ...) @@ -167,6 +168,8 @@ void warning(struct position pos, const char * fmt, ...) return; } + sparse_warnings++; + if (!--max_warnings) { show_info = 0; fmt = "too many warnings"; diff --git a/lib.h b/lib.h index d5693ed..8509dbb 100644 --- a/lib.h +++ b/lib.h @@ -45,6 +45,8 @@ extern int die_if_error; extern int parse_error; extern int repeat_phase, merge_phi_sources; extern int gcc_major, gcc_minor, gcc_patchlevel; +extern int sparse_warnings; +extern int sparse_errors; extern unsigned int hexval(unsigned int c); diff --git a/smatch.c b/smatch.c index 8ec103d..7a96e0f 100644 --- a/smatch.c +++ b/smatch.c @@ -337,7 +337,7 @@ int main(int argc, char **argv) smatch(argc, argv); free_string(data_dir); - if (sm_nr_errors > 0) + if (sm_nr_errors > 0 || sparse_errors > 0) return 1; if (sm_nr_checks > 0 && option_fatal_checks) return 1; -- 1.8.3.1