Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753117AbdDLFkJ (ORCPT ); Wed, 12 Apr 2017 01:40:09 -0400 Received: from terminus.zytor.com ([65.50.211.136]:60083 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753067AbdDLFkE (ORCPT ); Wed, 12 Apr 2017 01:40:04 -0400 Date: Tue, 11 Apr 2017 22:35:25 -0700 From: tip-bot for Taeung Song Message-ID: Cc: mhiramat@kernel.org, mingo@kernel.org, namhyung@kernel.org, ak@linux.intel.com, hpa@zytor.com, treeze.taeung@gmail.com, tglx@linutronix.de, acme@redhat.com, jolsa@kernel.org, wangnan0@huawei.com, linux-kernel@vger.kernel.org, peterz@infradead.org Reply-To: tglx@linutronix.de, treeze.taeung@gmail.com, mingo@kernel.org, ak@linux.intel.com, hpa@zytor.com, namhyung@kernel.org, mhiramat@kernel.org, peterz@infradead.org, wangnan0@huawei.com, linux-kernel@vger.kernel.org, jolsa@kernel.org, acme@redhat.com In-Reply-To: <1491575061-704-3-git-send-email-treeze.taeung@gmail.com> References: <1491575061-704-3-git-send-email-treeze.taeung@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf stat: Refactor the code to strip csv output with ltrim() Git-Commit-ID: b07c40df1f4e6f937271921cb116d570bb9c4a31 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: 1801 Lines: 53 Commit-ID: b07c40df1f4e6f937271921cb116d570bb9c4a31 Gitweb: http://git.kernel.org/tip/b07c40df1f4e6f937271921cb116d570bb9c4a31 Author: Taeung Song AuthorDate: Fri, 7 Apr 2017 23:24:18 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 11 Apr 2017 08:45:10 -0300 perf stat: Refactor the code to strip csv output with ltrim() To strip csv output, use ltrim() instead of just while loop and isspace() at print_metric_{only}_csv(). Signed-off-by: Taeung Song Cc: Andi Kleen Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1491575061-704-3-git-send-email-treeze.taeung@gmail.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-stat.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index 2158ea1..868e086a 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -875,10 +875,7 @@ static void print_metric_csv(void *ctx, return; } snprintf(buf, sizeof(buf), fmt, val); - vals = buf; - while (isspace(*vals)) - vals++; - ends = vals; + ends = vals = ltrim(buf); while (isdigit(*ends) || *ends == '.') ends++; *ends = 0; @@ -950,10 +947,7 @@ static void print_metric_only_csv(void *ctx, const char *color __maybe_unused, return; unit = fixunit(tbuf, os->evsel, unit); snprintf(buf, sizeof buf, fmt, val); - vals = buf; - while (isspace(*vals)) - vals++; - ends = vals; + ends = vals = ltrim(buf); while (isdigit(*ends) || *ends == '.') ends++; *ends = 0;