All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	David Ahern <dsahern@gmail.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Yao Jin <yao.jin@linux.intel.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 22/22] perf tools: Fix the code to strip command name
Date: Mon, 24 Apr 2017 16:54:39 -0300	[thread overview]
Message-ID: <20170424195439.29875-23-acme@kernel.org> (raw)
In-Reply-To: <20170424195439.29875-1-acme@kernel.org>

From: Jiri Olsa <jolsa@kernel.org>

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 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,
 	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;
-- 
2.9.3

  parent reply	other threads:[~2017-04-24 19:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-24 19:54 [GIT PULL 00/22] perf/core improvements and fixes Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 01/22] perf unwind: Provide only forward declarations for pointer types Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 02/22] perf tools: Add signal.h to places using its definitions Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 03/22] perf tools: Move units conversion/formatting routines to separate object Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 04/22] perf tools: Move timestamp routines from util.h to time-utils.h Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 05/22] perf kvm: Make function only used by 'perf kvm' static Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 06/22] perf debug: Move dump_stack() and sighandler_dump_stack() to debug.h Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 07/22] perf mem: Fix display of data source snoop indication Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 08/22] perf tools: Add compress.h for the *_decompress_to_file() headers Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 09/22] perf callchain: Move callchain specific routines from util.[ch] Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 10/22] perf tools: Include sys/param.h where needed Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 11/22] perf tools: Remove a few more needless includes from util.h Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 12/22] perf tools: Remove sys/ioctl.h " Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 13/22] perf tools: Remove string.h " Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 14/22] perf tools: Remove stale prototypes from builtin.h Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 15/22] perf tools: Remove string.h, unistd.h and sys/stat.h from util.h Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 16/22] perf tools: Remove poll.h and wait.h " Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 17/22] perf tools: Add the right header to obtain PERF_ALIGN() Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 18/22] perf tools: Use just forward declarations for struct thread where possible Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 19/22] tools: Update asm-generic/mman-common.h copy from the kernel Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 20/22] tools arch: Sync arch/x86/lib/memcpy_64.S with " Arnaldo Carvalho de Melo
2017-04-24 20:36   ` Luck, Tony
2017-04-25  2:59     ` Joe Perches
2017-04-25 16:18       ` Luck, Tony
2017-04-25 16:28         ` Joe Perches
2017-04-25 14:13     ` Arnaldo Carvalho de Melo
2017-04-24 19:54 ` [PATCH 21/22] tools arch x86: Sync cpufeatures.h Arnaldo Carvalho de Melo
2017-04-24 19:54 ` Arnaldo Carvalho de Melo [this message]
2017-04-24 20:08   ` [PATCH 22/22] perf tools: Fix the code to strip command name David Ahern
2017-04-24 20:40 ` [GIT PULL 00/22] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170424195439.29875-23-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=yao.jin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.