]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf tools: Remove a trailing newline in the event terms
authorNamhyung Kim <namhyung@kernel.org>
Tue, 2 Dec 2025 23:01:31 +0000 (15:01 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 3 Dec 2025 00:02:33 +0000 (16:02 -0800)
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>
tools/perf/util/pmu.c

index 1b7c712d8f9902bb672f09889c942a864a38c1dd..956ea273c2c7805c0cb504fb7dcf996f79f5588d 100644 (file)
@@ -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;