Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1630039

[tip:perf/core] perf tools: Fix the code to strip command name

From tip-bot for Jiri Olsa <tipbot@zytor.com>
Newsgroups linux.kernel
Subject [tip:perf/core] perf tools: Fix the code to strip command name
Date 2017-04-24 23:30 +0200
Message-ID <tzTIt-3OV-7@gated-at.bofh.it> (permalink)
References <tygzw-7a4-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Commit-ID:  9d43f5e8df6804ae271407500af9062e9278167a
Gitweb:     http://git.kernel.org/tip/9d43f5e8df6804ae271407500af9062e9278167a
Author:     Jiri Olsa <jolsa@kernel.org>
AuthorDate: Thu, 20 Apr 2017 11:24:30 +0200
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 24 Apr 2017 13:43:37 -0300

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>
---
 tools/perf/util/event.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index 2e829ac..142835c 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,
 	ppids = strstr(bf, "PPid:");
 
 	if (name) {
+		char *nl;
+
 		name += 5;  /* strlen("Name:") */
-		name = rtrim(ltrim(name));
+		name = ltrim(name);
+
+		nl = strchr(name, '\n');
+		if (nl)
+			*nl = '\0';
+
 		size = strlen(name);
 		if (size >= len)
 			size = len - 1;

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH perf/urgent] perf tools: Fix the code to strip command name Jiri Olsa <jolsa@kernel.org> - 2017-04-20 11:30 +0200
  Re: [PATCH perf/urgent] perf tools: Fix the code to strip command  name Taeung Song <treeze.taeung@gmail.com> - 2017-04-20 12:20 +0200
    Re: [PATCH perf/urgent] perf tools: Fix the code to strip command  name Jiri Olsa <jolsa@redhat.com> - 2017-04-20 12:40 +0200
      Re: [PATCH perf/urgent] perf tools: Fix the code to strip command  name Taeung Song <treeze.taeung@gmail.com> - 2017-04-20 12:50 +0200
        Re: [PATCH perf/urgent] perf tools: Fix the code to strip command  name Jiri Olsa <jolsa@redhat.com> - 2017-04-20 12:50 +0200
  Re: [PATCH perf/urgent] perf tools: Fix the code to strip command  name Jiri Olsa <jolsa@redhat.com> - 2017-04-24 13:40 +0200
  Re: [PATCH perf/urgent] perf tools: Fix the code to strip command  name Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-24 17:50 +0200
    Re: [PATCH perf/urgent] perf tools: Fix the code to strip command  name Jiri Olsa <jolsa@redhat.com> - 2017-04-24 18:10 +0200
      Re: [PATCH perf/urgent] perf tools: Fix the code to strip command  name Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-04-24 18:30 +0200
  [tip:perf/core] perf tools: Fix the code to strip command name tip-bot for Jiri Olsa <tipbot@zytor.com> - 2017-04-24 23:30 +0200

csiph-web