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] [day] [month] [year] [list]
Message-ID: <5adcb143681690619b109d79ff601309586588a4.1761078778.git.aclaudi@redhat.com>
Date: Tue, 21 Oct 2025 22:39:18 +0200
From: Andrea Claudi <aclaudi@...hat.com>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <stephen@...workplumber.org>,
	David Ahern <dsahern@...nel.org>
Subject: [PATCH iproute2-next 3/3] lnstat: convert to high-level json_print API

Replace the low-level json_writer API calls with the high-level
json_print API to maintain consistency with the rest of the iproute2
codebase.

Signed-off-by: Andrea Claudi <aclaudi@...hat.com>
---
 misc/lnstat.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/misc/lnstat.c b/misc/lnstat.c
index f802a0f3..8f359578 100644
--- a/misc/lnstat.c
+++ b/misc/lnstat.c
@@ -30,8 +30,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <getopt.h>
+#include <linux/types.h>
 
-#include <json_writer.h>
+#include "json_print.h"
 #include "lnstat.h"
 #include "version.h"
 
@@ -109,21 +110,17 @@ static void print_line(FILE *of, const struct lnstat_file *lnstat_files,
 static void print_json(FILE *of, const struct lnstat_file *lnstat_files,
 		       const struct field_params *fp)
 {
-	json_writer_t *jw = jsonw_new(of);
 	int i;
 
-	if (jw == NULL) {
-		fprintf(stderr, "Failed to create JSON writer\n");
-		exit(1);
-	}
-	jsonw_start_object(jw);
+	new_json_obj_plain(1);
+	open_json_object(NULL);
 	for (i = 0; i < fp->num; i++) {
 		const struct lnstat_field *lf = fp->params[i].lf;
 
-		jsonw_uint_field(jw, lf->name, lf->result);
+		print_luint(PRINT_JSON, lf->name, NULL, lf->result);
 	}
-	jsonw_end_object(jw);
-	jsonw_destroy(&jw);
+	close_json_object();
+	delete_json_obj_plain();
 }
 
 /* find lnstat_field according to user specification */
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ