[PATCH 1/8] need to strip SYM_NODE before comparing types

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

 



Every variable has a 'symbol type' of SYM_NODE which needs to
be stripped before comparing with builtin types like int_ctype.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx>
---
 validation/varargs-format-dyn-prec.c | 11 +++++++++++
 verify-format.c                      |  3 +++
 2 files changed, 14 insertions(+)
 create mode 100644 validation/varargs-format-dyn-prec.c

diff --git a/validation/varargs-format-dyn-prec.c b/validation/varargs-format-dyn-prec.c
new file mode 100644
index 000000000000..a143f1661c84
--- /dev/null
+++ b/validation/varargs-format-dyn-prec.c
@@ -0,0 +1,11 @@
+extern void pf(const char *msg, ...) __attribute__((format(printf, 1, 2)));
+
+static void test(int prec)
+{
+	pf("%*s\n", prec, "xyz");
+}
+
+/*
+ * check-name: variadic formatting test dynamic precision
+ * check-command: sparse -Wformat $file
+ */
diff --git a/verify-format.c b/verify-format.c
index 2da9d2069121..ba6cb5646dba 100644
--- a/verify-format.c
+++ b/verify-format.c
@@ -325,6 +325,9 @@ static int parse_format_printf_argfield(const char **fmtptr,
 	if (ctype) {
 		struct symbol *target = &int_ctype;
 
+		if (ctype->type == SYM_NODE)
+			ctype = ctype->ctype.base_type;
+
 		if (ctype != &int_ctype && ctype != &uint_ctype) {
 			warning(expr->pos, "incorrect type for %s argument %d", which, argpos);
 			info(expr->pos, "   expected %s", show_typename(target));
-- 
2.28.0




[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