Linux-Sparse Archive on lore.kernel.org
 help / color / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] teach sparse about -fmax-errors
Date: Tue, 14 Jul 2020 23:45:59 +0200
Message-ID: <20200714214559.15137-1-luc.vanoostenryck@gmail.com> (raw)

Currently, the maximum number of displayed errors is 100.
This is nice to not be flooded with error messages when things
are really broken but in some situation, for example testing,
it is desirable to have all error messages.

So, teach sparse about '-fmax-errors=COUNT'.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 lib.c     | 2 +-
 options.c | 8 ++++++++
 options.h | 1 +
 sparse.1  | 6 ++++++
 4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib.c b/lib.c
index d4f4dd3015c8..4e8d7b451747 100644
--- a/lib.c
+++ b/lib.c
@@ -90,7 +90,7 @@ static void do_error(struct position pos, const char * fmt, va_list args)
 		return;
 	/* Shut up warnings after an error */
 	has_error |= ERROR_CURR_PHASE;
-	if (errors > 100) {
+	if (errors > fmax_errors) {
 		static int once = 0;
 		show_info = 0;
 		if (once)
diff --git a/options.c b/options.c
index 9f05bdf9cf4f..c46ad4f52cbb 100644
--- a/options.c
+++ b/options.c
@@ -73,6 +73,7 @@ int dump_macros_only = 0;
 
 unsigned long fdump_ir;
 int fhosted = 1;
+unsigned int fmax_errors = 100;
 unsigned int fmax_warnings = 100;
 int fmem_report = 0;
 unsigned long long fmemcpy_max_count = 100000;
@@ -492,6 +493,12 @@ static int handle_fmemcpy_max_count(const char *arg, const char *opt, const stru
 	return 1;
 }
 
+static int handle_fmax_errors(const char *arg, const char *opt, const struct flag *flag, int options)
+{
+	opt_uint(arg, opt, &fmax_errors, OPTNUM_UNLIMITED);
+	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);
@@ -504,6 +511,7 @@ static struct flag fflags[] = {
 	{ "freestanding",	&fhosted, NULL, OPT_INVERSE },
 	{ "hosted",		&fhosted },
 	{ "linearize",		NULL,	handle_fpasses,	PASS_LINEARIZE },
+	{ "max-errors=",	NULL,	handle_fmax_errors },
 	{ "max-warnings=",	NULL,	handle_fmax_warnings },
 	{ "mem-report",		&fmem_report },
 	{ "memcpy-max-count=",	NULL,	handle_fmemcpy_max_count },
diff --git a/options.h b/options.h
index 7fd01ec6cebe..070c0dd87183 100644
--- a/options.h
+++ b/options.h
@@ -72,6 +72,7 @@ extern int dump_macros_only;
 
 extern unsigned long fdump_ir;
 extern int fhosted;
+extern unsigned int fmax_errors;
 extern unsigned int fmax_warnings;
 extern int fmem_report;
 extern unsigned long long fmemcpy_max_count;
diff --git a/sparse.1 b/sparse.1
index d916ad9ee54e..dbef62682b6e 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-errors=COUNT
+Set the maximum number of displayed errors to COUNT, which should be
+a numerical value or 'unlimited'.
+The default limit is 100.
+.
+.TP
 .B \-fmax-warnings=COUNT
 Set the maximum number of displayed warnings to COUNT, which should be
 a numerical value or 'unlimited'.
-- 
2.27.0


                 reply index

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=20200714214559.15137-1-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.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

Linux-Sparse Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sparse/0 linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ https://lore.kernel.org/linux-sparse \
		linux-sparse@vger.kernel.org
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sparse


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git