From: John Levon <levon@movementarian.org>
Subject: [PATCH 14/18] Track sparse-level warnings and errors too, and respect them in smatch's exit code.
Date: Thu, 22 Nov 2018 14:56:56 +0000 [thread overview]
Message-ID: <E1gQCRX-00068a-6I@movementarian.org> (raw)
Signed-off-by: John Levon <levon@movementarian.org>
---
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 a82408e8..54d10723 100644
--- a/lib.c
+++ b/lib.c
@@ -47,6 +47,9 @@
static const char *progname;
+int sparse_errors = 0;
+int sparse_warnings = 0;
+
int verbose, optimize, optimize_size, preprocessing;
int die_if_error = 0;
int parse_error;
@@ -133,14 +136,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)
@@ -150,7 +151,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, ...)
@@ -169,6 +170,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 bfb35466..cc87da3a 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 2ccf8d76..c00e75d9 100644
--- a/smatch.c
+++ b/smatch.c
@@ -359,7 +359,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;
--
2.14.1
reply other threads:[~2018-11-24 1:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1gQCRX-00068a-6I@movementarian.org \
--to=levon@movementarian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).