netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: [PATCH v4 iproute2-next 11/11] json_print: suppress clang format warning
Date: Thu, 20 Jan 2022 13:11:53 -0800	[thread overview]
Message-ID: <20220120211153.189476-12-stephen@networkplumber.org> (raw)
In-Reply-To: <20220120211153.189476-1-stephen@networkplumber.org>

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@networkplumber.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


  parent reply	other threads:[~2022-01-20 21:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20 21:11 [PATCH v4 iproute2-next 00/11] fix clang warnings Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 01/11] tc: add format attribute to tc_print_rate Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 02/11] utils: add format attribute Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 03/11] netem: fix clang warnings Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 04/11] flower: " Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 05/11] tc_util: fix clang warning in print_masked_type Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 06/11] ipl2tp: fix clang warning Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 07/11] can: " Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 08/11] tipc: fix clang warning about empty format string Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 09/11] tunnel: fix clang warning Stephen Hemminger
2022-01-20 21:11 ` [PATCH v4 iproute2-next 10/11] libbpf: fix clang warning about format non-literal Stephen Hemminger
2022-01-20 21:11 ` Stephen Hemminger [this message]
2022-01-26 17:30 ` [PATCH v4 iproute2-next 00/11] fix clang warnings patchwork-bot+netdevbpf

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=20220120211153.189476-12-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=netdev@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
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;
as well as URLs for NNTP newsgroup(s).