lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220120211153.189476-12-stephen@networkplumber.org>
Date:   Thu, 20 Jan 2022 13:11:53 -0800
From:   Stephen Hemminger <stephen@...workplumber.org>
To:     netdev@...r.kernel.org
Cc:     Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH v4 iproute2-next 11/11] json_print: suppress clang format warning

Clang complains about using non-format string in print_color_tv.
The ideal fix would be to put format attribute on all the print_XXX functions
in json_print.h. But that leads to further complications because the existing
code may pass a NULL as format if the format is unused since the print
is being done only for JSON output.

The compromise is to just disable the warning for the one place
it shows up.

Signed-off-by: Stephen Hemminger <stephen@...workplumber.org>
---
 lib/json_print.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/json_print.c b/lib/json_print.c
index e3a88375fe7c..741acdcff990 100644
--- a/lib/json_print.c
+++ b/lib/json_print.c
@@ -299,6 +299,13 @@ int print_color_null(enum output_type type,
 	return ret;
 }
 
+/*
+ * This function does take printf style argument but applying
+ * format attribute to causes more warnings since the print_XXX
+ * functions are used with NULL for format if unused.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 int print_color_tv(enum output_type type,
 		   enum color_attr color,
 		   const char *key,
@@ -311,6 +318,7 @@ int print_color_tv(enum output_type type,
 
 	return print_color_float(type, color, key, fmt, time);
 }
+#pragma GCC diagnostic pop
 
 /* Print line separator (if not in JSON mode) */
 void print_nl(void)
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ