Commit 9d43f5e8df6804ae271407500af9062e9278167a

Authored by Jiri Olsa
Committed by Arnaldo Carvalho de Melo
1 parent fb7b756196

perf tools: Fix the code to strip command name

Recent commit broke command name strip in perf_event__get_comm_ids
function. It replaced left to right search for '\n' with rtrim, which
actually does right to left search. It occasionally caught earlier '\n'
and kept trash in the command name.

Keeping the ltrim, but moving back the left to right '\n' search
instead of the rtrim.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Acked-by: Taeung Song <treeze.taeung@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Yao Jin <yao.jin@linux.intel.com>
Fixes: bdd97ca63faa ("perf tools: Refactor the code to strip command name with {l,r}trim()")
Link: http://lkml.kernel.org/r/20170420092430.29657-1-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

Showing 1 changed file with 8 additions and 1 deletions Side-by-side Diff

tools/perf/util/event.c
... ... @@ -141,8 +141,15 @@
141 141 ppids = strstr(bf, "PPid:");
142 142  
143 143 if (name) {
  144 + char *nl;
  145 +
144 146 name += 5; /* strlen("Name:") */
145   - name = rtrim(ltrim(name));
  147 + name = ltrim(name);
  148 +
  149 + nl = strchr(name, '\n');
  150 + if (nl)
  151 + *nl = '\0';
  152 +
146 153 size = strlen(name);
147 154 if (size >= len)
148 155 size = len - 1;