aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2017-04-20 05:24:30 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2017-04-24 12:43:37 -0400
commit9d43f5e8df6804ae271407500af9062e9278167a (patch)
tree3564d53e2242beb9616ad050a6142de689cf814a /tools/perf
parentfb7b75619641d778c2b778748ca5cdf2718cc024 (diff)
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>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/util/event.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2e829ac0f615..142835c0ca0a 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -141,8 +141,15 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
141 ppids = strstr(bf, "PPid:"); 141 ppids = strstr(bf, "PPid:");
142 142
143 if (name) { 143 if (name) {
144 char *nl;
145
144 name += 5; /* strlen("Name:") */ 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 size = strlen(name); 153 size = strlen(name);
147 if (size >= len) 154 if (size >= len)
148 size = len - 1; 155 size = len - 1;