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: <20251118063641.517066-2-namhyung@kernel.org>
Date: Mon, 17 Nov 2025 22:36:40 -0800
From: Namhyung Kim <namhyung@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>,
	Ian Rogers <irogers@...gle.com>,
	James Clark <james.clark@...aro.org>
Cc: Jiri Olsa <jolsa@...nel.org>,
	Adrian Hunter <adrian.hunter@...el.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...nel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	linux-perf-users@...r.kernel.org
Subject: [PATCH 2/3] perf list: Get rid of json_print_state

The JSON print state has only one different field (need_sep).  Let's
move it to the default print state and use it.  It would waste a little
bit of more spaces but who cares? :)

Signed-off-by: Namhyung Kim <namhyung@...nel.org>
---
 tools/perf/builtin-list.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/tools/perf/builtin-list.c b/tools/perf/builtin-list.c
index 28bf1fc7f5eeff8f..1ab969ffe371c5cb 100644
--- a/tools/perf/builtin-list.c
+++ b/tools/perf/builtin-list.c
@@ -60,6 +60,8 @@ struct print_state {
 	bool metricgroups;
 	/** @exclude_abi: Exclude PMUs with types less than PERF_TYPE_MAX except PERF_TYPE_RAW. */
 	bool exclude_abi;
+	/** @need_sep: Should a separator be printed prior to the next item? (for JSON) */
+	bool need_sep;
 	/** @last_topic: The last printed event topic. */
 	char *last_topic;
 	/** @last_metricgroups: The last printed metric group. */
@@ -368,7 +370,7 @@ static void json_print_event(void *ps, const char *topic,
 			     const char *desc, const char *long_desc,
 			     const char *encoding_desc)
 {
-	struct json_print_state *print_state = ps;
+	struct print_state *print_state = ps;
 	bool need_sep = false;
 	FILE *fp = print_state->fp;
 	struct strbuf buf;
@@ -444,7 +446,7 @@ static void json_print_metric(void *ps __maybe_unused, const char *group,
 			      const char *threshold, const char *unit,
 			      const char *pmu_name)
 {
-	struct json_print_state *print_state = ps;
+	struct print_state *print_state = ps;
 	bool need_sep = false;
 	FILE *fp = print_state->fp;
 	struct strbuf buf;
@@ -521,9 +523,6 @@ int cmd_list(int argc, const char **argv)
 		.fp = stdout,
 		.desc = true,
 	};
-	struct print_state json_ps = {
-		.fp = stdout,
-	};
 	void *ps = &default_ps;
 	struct print_callbacks print_cb = {
 		.print_start = default_print_start,
@@ -574,7 +573,6 @@ int cmd_list(int argc, const char **argv)
 
 	if (output_path) {
 		default_ps.fp = fopen(output_path, "w");
-		json_ps.fp = default_ps.fp;
 	}
 
 	setup_pager();
@@ -590,7 +588,7 @@ int cmd_list(int argc, const char **argv)
 			.print_metric = json_print_metric,
 			.skip_duplicate_pmus = json_skip_duplicate_pmus,
 		};
-		ps = &json_ps;
+		ps = &default_ps;
 	} else {
 		default_ps.last_topic = strdup("");
 		assert(default_ps.last_topic);
-- 
2.52.0.rc1.455.g30608eb744-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ