From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-sparse@vger.kernel.org, sparse@chrisli.org
Cc: Ben Dooks <ben.dooks@codethink.co.uk>
Subject: [PATCH v3 2/4] add -Wformat
Date: Fri, 16 Jan 2026 17:58:07 +0000 [thread overview]
Message-ID: <20260116175809.6849-3-ben.dooks@codethink.co.uk> (raw)
In-Reply-To: <20260116175809.6849-1-ben.dooks@codethink.co.uk>
Add option to enable/disable format checking (and default it to off)
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
---
options.c | 2 ++
options.h | 1 +
sparse.1 | 8 ++++++++
3 files changed, 11 insertions(+)
diff --git a/options.c b/options.c
index 6ee4d878..54ac00b4 100644
--- a/options.c
+++ b/options.c
@@ -106,6 +106,7 @@ int Wflexible_array_array = 1;
int Wflexible_array_nested = 0;
int Wflexible_array_sizeof = 0;
int Wflexible_array_union = 0;
+int Wformat = 0;
int Wimplicit_int = 1;
int Winit_cstring = 0;
int Wint_to_pointer_cast = 1;
@@ -865,6 +866,7 @@ static const struct flag warnings[] = {
{ "flexible-array-nested", &Wflexible_array_nested },
{ "flexible-array-sizeof", &Wflexible_array_sizeof },
{ "flexible-array-union", &Wflexible_array_union },
+ { "format", &Wformat },
{ "implicit-int", &Wimplicit_int },
{ "init-cstring", &Winit_cstring },
{ "int-to-pointer-cast", &Wint_to_pointer_cast },
diff --git a/options.h b/options.h
index c2a9551a..105c45d0 100644
--- a/options.h
+++ b/options.h
@@ -106,6 +106,7 @@ extern int Wflexible_array_array;
extern int Wflexible_array_nested;
extern int Wflexible_array_sizeof;
extern int Wflexible_array_union;
+extern int Wformat;
extern int Wimplicit_int;
extern int Winit_cstring;
extern int Wint_to_pointer_cast;
diff --git a/sparse.1 b/sparse.1
index 2fba7e7a..64b0571e 100644
--- a/sparse.1
+++ b/sparse.1
@@ -285,6 +285,14 @@ To have any effect, at least one of \fB-Wflexible-array-array\fR,
be enabled.
Sparse does issue these warnings by default.
+.B \-Wformat
+Warn about parameter mismatch to any variadic function which specifies
+where the format string is specified with the
+.BI __attribute__((format( type, message, va_start )))
+attribute.
+
+Sparse does not issue these warnings by default. To turn them on, use
+\fB\-W-format\fR.
.
.TP
.B \-Winit\-cstring
--
2.37.2.352.g3c44437643
next prev parent reply other threads:[~2026-01-16 17:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-16 17:58 add variadic format checking Ben Dooks
2026-01-16 17:58 ` [PATCH v3 1/4] parse: initial parsing of __attribute__((format)) Ben Dooks
2026-01-16 17:58 ` Ben Dooks [this message]
2026-01-16 17:58 ` [PATCH v3 3/4] evaluate: check variadic argument types against formatting info Ben Dooks
2026-01-16 17:58 ` [PATCH v3 4/4] tests: add varargs printf format tests Ben Dooks
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=20260116175809.6849-3-ben.dooks@codethink.co.uk \
--to=ben.dooks@codethink.co.uk \
--cc=linux-sparse@vger.kernel.org \
--cc=sparse@chrisli.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