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>] [day] [month] [year] [list]
Message-ID: <7993322e608a08f85dc12026412ee6ef345dc7f6.1642503727.git.petrm@nvidia.com>
Date:   Tue, 18 Jan 2022 12:09:30 +0100
From:   Petr Machata <petrm@...dia.com>
To:     <netdev@...r.kernel.org>
CC:     David Ahern <dsahern@...il.com>, Petr Machata <petrm@...dia.com>,
        "Stephen Hemminger" <stephen@...workplumber.org>
Subject: [PATCH iproute2-next] dcb: Rewrite array-formatting code to not cause warnings with Clang

Some installation of Clang are unhappy about the use of a hand-rolled
formatting strings, and emit warnings such as this one:

	dcb.c:334:31: warning: format string is not a string literal
	[-Wformat-nonliteral]

Rewrite the impacted code so that it always uses literal format strings.

Reported-by: Stephen Hemminger <stephen@...workplumber.org>
Signed-off-by: Petr Machata <petrm@...dia.com>
---
 dcb/dcb.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/dcb/dcb.c b/dcb/dcb.c
index 696f00e4..b7c2df54 100644
--- a/dcb/dcb.c
+++ b/dcb/dcb.c
@@ -326,51 +326,51 @@ int dcb_set_attribute_bare(struct dcb *dcb, int command, const char *dev,
 
 void dcb_print_array_u8(const __u8 *array, size_t size)
 {
-	SPRINT_BUF(b);
 	size_t i;
 
 	for (i = 0; i < size; i++) {
-		snprintf(b, sizeof(b), "%zd:%%d ", i);
-		print_uint(PRINT_ANY, NULL, b, array[i]);
+		print_uint(PRINT_JSON, NULL, NULL, array[i]);
+		print_uint(PRINT_FP, NULL, "%zd:", i);
+		print_uint(PRINT_FP, NULL, "%d ", array[i]);
 	}
 }
 
 void dcb_print_array_u64(const __u64 *array, size_t size)
 {
-	SPRINT_BUF(b);
 	size_t i;
 
 	for (i = 0; i < size; i++) {
-		snprintf(b, sizeof(b), "%zd:%%" PRIu64 " ", i);
-		print_u64(PRINT_ANY, NULL, b, array[i]);
+		print_u64(PRINT_JSON, NULL, NULL, array[i]);
+		print_uint(PRINT_FP, NULL, "%zd:", i);
+		print_u64(PRINT_FP, NULL, "%" PRIu64 " ", array[i]);
 	}
 }
 
 void dcb_print_array_on_off(const __u8 *array, size_t size)
 {
-	SPRINT_BUF(b);
 	size_t i;
 
 	for (i = 0; i < size; i++) {
-		snprintf(b, sizeof(b), "%zd:%%s ", i);
-		print_on_off(PRINT_ANY, NULL, b, array[i]);
+		print_on_off(PRINT_JSON, NULL, NULL, array[i]);
+		print_uint(PRINT_FP, NULL, "%zd:", i);
+		print_on_off(PRINT_FP, NULL, "%s ", array[i]);
 	}
 }
 
 void dcb_print_array_kw(const __u8 *array, size_t array_size,
 			const char *const kw[], size_t kw_size)
 {
-	SPRINT_BUF(b);
 	size_t i;
 
 	for (i = 0; i < array_size; i++) {
+		const char *str = "???";
 		__u8 emt = array[i];
 
-		snprintf(b, sizeof(b), "%zd:%%s ", i);
 		if (emt < kw_size && kw[emt])
-			print_string(PRINT_ANY, NULL, b, kw[emt]);
-		else
-			print_string(PRINT_ANY, NULL, b, "???");
+			str = kw[emt];
+		print_string(PRINT_JSON, NULL, NULL, str);
+		print_uint(PRINT_FP, NULL, "%zd:", i);
+		print_string(PRINT_FP, NULL, "%s ", str);
 	}
 }
 
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ