summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNamhyung Kim <namhyung@kernel.org>2025-12-03 02:01:31 +0300
committerNamhyung Kim <namhyung@kernel.org>2025-12-03 03:02:33 +0300
commit441863ae3de61dd813049a120e5656df2e210a4b (patch)
treead13653986af5487d8e55d6a7b95d08628fafcee
parent267c2e633af6e9461477bed91e428993f8b36ee8 (diff)
downloadlinux-441863ae3de61dd813049a120e5656df2e210a4b.tar.xz
perf tools: Remove a trailing newline in the event terms
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/" }, ... Reviewed-by: Ian Rogers <irogers@google.com> Suggested-by: Ian Rogers <irogers@google.com> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rw-r--r--tools/perf/util/pmu.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 1b7c712d8f99..956ea273c2c7 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;