[PATCH 3/5] add -Wformat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add option to enable/disable format checking (and default it to on)

Signed-off-by: Ben Dooks <ben.dooks@xxxxxxxxxxxxxxx>
---
 evaluate.c | 2 +-
 lib.c      | 2 ++
 lib.h      | 1 +
 sparse.1   | 9 +++++++++
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/evaluate.c b/evaluate.c
index ffb4af6..9868e9c 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2544,7 +2544,7 @@ static int evaluate_arguments(struct symbol *fn, struct expression_list *head)
 	/* do this first, otherwise the arugment info may get lost or changed
 	 * later on in the evaluation loop.
 	 */
-	if (fn->ctype.printf_va_start)
+	if (Wformat && fn->ctype.printf_va_start)
 		evaluate_format_printf(fn, head);
 
 	PREPARE_PTR_LIST(argument_types, argtype);
diff --git a/lib.c b/lib.c
index 645132a..47b4f05 100644
--- a/lib.c
+++ b/lib.c
@@ -232,6 +232,7 @@ int Wdesignated_init = 1;
 int Wdo_while = 0;
 int Winit_cstring = 0;
 int Wenum_mismatch = 1;
+int Wformat = 1;
 int Wsparse_error = 0;
 int Wmemcpy_max_count = 1;
 int Wnon_pointer_null = 1;
@@ -525,6 +526,7 @@ static const struct warning {
 	{ "do-while", &Wdo_while },
 	{ "enum-mismatch", &Wenum_mismatch },
 	{ "init-cstring", &Winit_cstring },
+	{ "format", &Wformat },
 	{ "memcpy-max-count", &Wmemcpy_max_count },
 	{ "non-pointer-null", &Wnon_pointer_null },
 	{ "old-initializer", &Wold_initializer },
diff --git a/lib.h b/lib.h
index a9b70b0..6434329 100644
--- a/lib.h
+++ b/lib.h
@@ -124,6 +124,7 @@ extern int Wdefault_bitfield_sign;
 extern int Wdesignated_init;
 extern int Wdo_while;
 extern int Wenum_mismatch;
+extern int Wformat;
 extern int Wsparse_error;
 extern int Winit_cstring;
 extern int Wmemcpy_max_count;
diff --git a/sparse.1 b/sparse.1
index e183204..4e81bdc 100644
--- a/sparse.1
+++ b/sparse.1
@@ -219,6 +219,15 @@ trouble.
 Sparse does not issue these warnings by default.
 .
 .TP
+.B \-Wformat
+Warn about parameter mis-match to any variadic function which specifies
+where the format string is with the 
+.BI __attribute__((format( type, message, va_start )))
+attribute.
+
+Sparse issues these warnings by default. To turn them off, use
+\fB\-Wno\-format\fR
+.TP
 .B \-Wmemcpy\-max\-count
 Warn about call of \fBmemcpy()\fR, \fBmemset()\fR, \fBcopy_from_user()\fR, or
 \fBcopy_to_user()\fR with a large compile-time byte count.
-- 
2.19.1




[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux