Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753246AbdDLFkn (ORCPT ); Wed, 12 Apr 2017 01:40:43 -0400 Received: from terminus.zytor.com ([65.50.211.136]:33213 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753180AbdDLFki (ORCPT ); Wed, 12 Apr 2017 01:40:38 -0400 Date: Tue, 11 Apr 2017 22:36:56 -0700 From: tip-bot for Taeung Song Message-ID: Cc: hpa@zytor.com, dzickus@redhat.com, tglx@linutronix.de, wangnan0@huawei.com, mhiramat@kernel.org, acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, peterz@infradead.org, dsahern@gmail.com, namhyung@kernel.org, jolsa@kernel.org, treeze.taeung@gmail.com Reply-To: mhiramat@kernel.org, acme@redhat.com, tglx@linutronix.de, dzickus@redhat.com, hpa@zytor.com, wangnan0@huawei.com, namhyung@kernel.org, treeze.taeung@gmail.com, jolsa@kernel.org, peterz@infradead.org, dsahern@gmail.com, mingo@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1491575061-704-6-git-send-email-treeze.taeung@gmail.com> References: <1491575061-704-6-git-send-email-treeze.taeung@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Refactor the code to strip command name with {l,r}trim() Git-Commit-ID: bdd97ca63faa374c98314d53c0bcaedb473c5a33 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: 1833 Lines: 56 Commit-ID: bdd97ca63faa374c98314d53c0bcaedb473c5a33 Gitweb: http://git.kernel.org/tip/bdd97ca63faa374c98314d53c0bcaedb473c5a33 Author: Taeung Song AuthorDate: Fri, 7 Apr 2017 23:24:21 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 11 Apr 2017 15:23:26 -0300 perf tools: Refactor the code to strip command name with {l,r}trim() After reading command name from /proc//status, use ltrim() and rtrim() to strip command name, not using just while loop, isspace() and etc. Signed-off-by: Taeung Song Acked-by: David Ahern Cc: Don Zickus Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1491575061-704-6-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/event.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 76b9c6b..8255a26 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -106,7 +106,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, int fd; size_t size = 0; ssize_t n; - char *nl, *name, *tgids, *ppids; + char *name, *tgids, *ppids; *tgid = -1; *ppid = -1; @@ -134,14 +134,7 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len, if (name) { name += 5; /* strlen("Name:") */ - - while (*name && isspace(*name)) - ++name; - - nl = strchr(name, '\n'); - if (nl) - *nl = '\0'; - + name = rtrim(ltrim(name)); size = strlen(name); if (size >= len) size = len - 1;