Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S972167AbdDXPpu (ORCPT ); Mon, 24 Apr 2017 11:45:50 -0400 Received: from mail.kernel.org ([198.145.29.136]:35006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S972116AbdDXPpO (ORCPT ); Mon, 24 Apr 2017 11:45:14 -0400 Date: Mon, 24 Apr 2017 12:44:50 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: David Ahern , Namhyung Kim , Peter Zijlstra , Taeung Song , Jin Yao , lkml , Ingo Molnar Subject: Re: [PATCH perf/urgent] perf tools: Fix the code to strip command name Message-ID: <20170424154450.GB2742@kernel.org> References: <20170420092430.29657-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170420092430.29657-1-jolsa@kernel.org> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1830 Lines: 60 Em Thu, Apr 20, 2017 at 11:24:30AM +0200, Jiri Olsa escreveu: > 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. perf/urgent? > Fixes: bdd97ca63faa ("perf tools: Refactor the code to strip command name with {l,r}trim()") [acme@jouet linux]$ git tag --contains bdd97ca63faa perf-core-for-mingo-4.12-20170411 perf-core-for-mingo-4.12-20170413 perf-core-for-mingo-4.12-20170419 [acme@jouet linux]$ It is just in tip/perf/core, will put in acme/perf/core and push to Ingo in my next pull req. Thanks, - Arnaldo > Signed-off-by: Jiri Olsa > Cc: David Ahern > Cc: Namhyung Kim > Cc: Peter Zijlstra > Cc: Taeung Song > Cc: Jin Yao > Link: http://lkml.kernel.org/n/tip-51mt8hxaig74zlu42s3rv0i7@git.kernel.org > --- > 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 cf457ef534da..1a9164a816d9 100644 > --- a/tools/perf/util/event.c > +++ b/tools/perf/util/event.c > @@ -138,8 +138,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