Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S978170AbdDXVUM (ORCPT ); Mon, 24 Apr 2017 17:20:12 -0400 Received: from terminus.zytor.com ([65.50.211.136]:50301 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S975248AbdDXVUE (ORCPT ); Mon, 24 Apr 2017 17:20:04 -0400 Date: Mon, 24 Apr 2017 14:17:43 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, jolsa@kernel.org, dsahern@gmail.com, tglx@linutronix.de, a.p.zijlstra@chello.nl, mingo@kernel.org, namhyung@kernel.org, treeze.taeung@gmail.com, yao.jin@linux.intel.com Reply-To: acme@redhat.com, linux-kernel@vger.kernel.org, hpa@zytor.com, dsahern@gmail.com, jolsa@kernel.org, tglx@linutronix.de, a.p.zijlstra@chello.nl, namhyung@kernel.org, mingo@kernel.org, yao.jin@linux.intel.com, treeze.taeung@gmail.com In-Reply-To: <20170420092430.29657-1-jolsa@kernel.org> References: <20170420092430.29657-1-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Fix the code to strip command name Git-Commit-ID: 9d43f5e8df6804ae271407500af9062e9278167a X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1782 Lines: 51 Commit-ID: 9d43f5e8df6804ae271407500af9062e9278167a Gitweb: http://git.kernel.org/tip/9d43f5e8df6804ae271407500af9062e9278167a Author: Jiri Olsa AuthorDate: Thu, 20 Apr 2017 11:24:30 +0200 Committer: Arnaldo Carvalho de Melo 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 Acked-by: Taeung Song Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Yao Jin 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 --- 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;