Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1168637AbdDXLhd (ORCPT ); Mon, 24 Apr 2017 07:37:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51720 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1168584AbdDXLhY (ORCPT ); Mon, 24 Apr 2017 07:37:24 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com ADB043DBC1 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jolsa@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com ADB043DBC1 Date: Mon, 24 Apr 2017 13:37:20 +0200 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , 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: <20170424113720.GA4455@krava> 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> User-Agent: Mutt/1.8.0 (2017-02-23) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 24 Apr 2017 11:37:24 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1583 Lines: 52 Arnaldo, could you please take this one? thanks, jirka On Thu, Apr 20, 2017 at 11:24:30AM +0200, Jiri Olsa wrote: > 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. > > Fixes: bdd97ca63faa ("perf tools: Refactor the code to strip command name with {l,r}trim()") > 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 >