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]
Date: Mon, 11 Dec 2023 09:07:30 -0500
From: Benjamin Poirier <bpoirier@...dia.com>
To: netdev@...r.kernel.org
Cc: Petr Machata <petrm@...dia.com>,
	Roopa Prabhu <roopa@...dia.com>
Subject: [PATCH iproute2-next 18/20] json_print: Output to temporary buffer in print_range() only as needed

The string that's formatted in the "end" buffer is only needed when
outputting a range so move the snprintf() call within the condition.

Reviewed-by: Petr Machata <petrm@...dia.com>
Tested-by: Petr Machata <petrm@...dia.com>
Signed-off-by: Benjamin Poirier <bpoirier@...dia.com>
---
 lib/json_print.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/json_print.c b/lib/json_print.c
index 072105c0..f38171ff 100644
--- a/lib/json_print.c
+++ b/lib/json_print.c
@@ -377,14 +377,15 @@ int print_color_rate(bool use_iec, enum output_type type, enum color_attr color,
 
 unsigned int print_range(const char *name, __u32 start, __u32 id)
 {
-	char end[64];
 	int width;
 
-	snprintf(end, sizeof(end), "%sEnd", name);
-
 	width = print_uint(PRINT_ANY, name, "%u", start);
-	if (start != id)
+	if (start != id) {
+		char end[64];
+
+		snprintf(end, sizeof(end), "%sEnd", name);
 		width += print_uint(PRINT_ANY, end, "-%u", id);
+	}
 
 	return width;
 }
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ