Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH] perf tools: Remove a trailing newline in the event terms
@ 2025-12-02 23:01 Namhyung Kim
  2025-12-02 23:03 ` Ian Rogers
  2025-12-03 17:58 ` Namhyung Kim
  0 siblings, 2 replies; 3+ messages in thread
From: Namhyung Kim @ 2025-12-02 23:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ian Rogers, James Clark
  Cc: Jiri Olsa, Adrian Hunter, Peter Zijlstra, Ingo Molnar, LKML,
	linux-perf-users

So that it can show the correct encoding info in the JSON output.

  $ perf list -j hw
  [
  {
          "Unit": "cpu",
          "Topic": "legacy hardware",
          "EventName": "branch-instructions",
          "EventType": "Kernel PMU event",
          "BriefDescription": "Retired branch instructions [This event is an alias of branches]",
          "Encoding": "cpu/event=0xc4/"
  },
  ...

Suggested-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 tools/perf/util/pmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 1b7c712d8f9902bb..956ea273c2c7805c 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -645,6 +645,8 @@ static int perf_pmu__new_alias(struct perf_pmu *pmu, const char *name,
 			pr_err("Failed to read alias %s\n", name);
 			return ret;
 		}
+		if (line_len >= 1 && alias->terms[line_len - 1] == '\n')
+			alias->terms[line_len - 1] = '\0';
 	}
 	alias->name = strdup(name);
 	alias->desc = desc ? strdup(desc) : NULL;
-- 
2.52.0.158.g65b55ccf14-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-03 17:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 23:01 [PATCH] perf tools: Remove a trailing newline in the event terms Namhyung Kim
2025-12-02 23:03 ` Ian Rogers
2025-12-03 17:58 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox