提交 9d43f5e8 编写于 作者: J Jiri Olsa 提交者: Arnaldo Carvalho de Melo

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: NJiri Olsa <jolsa@kernel.org>
Acked-by: NTaeung 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: bdd97ca6 ("perf tools: Refactor the code to strip command name with {l,r}trim()")
Link: http://lkml.kernel.org/r/20170420092430.29657-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 fb7b7561
...@@ -141,8 +141,15 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, ...@@ -141,8 +141,15 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,
ppids = strstr(bf, "PPid:"); ppids = strstr(bf, "PPid:");
if (name) { if (name) {
char *nl;
name += 5; /* strlen("Name:") */ name += 5; /* strlen("Name:") */
name = rtrim(ltrim(name)); name = ltrim(name);
nl = strchr(name, '\n');
if (nl)
*nl = '\0';
size = strlen(name); size = strlen(name);
if (size >= len) if (size >= len)
size = len - 1; size = len - 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册