From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932105AbbFDOLb (ORCPT ); Thu, 4 Jun 2015 10:11:31 -0400 Received: from terminus.zytor.com ([198.137.202.10]:46932 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752998AbbFDOL1 (ORCPT ); Thu, 4 Jun 2015 10:11:27 -0400 Date: Thu, 4 Jun 2015 07:10:41 -0700 From: tip-bot for Madhavan Srinivasan Message-ID: Cc: jolsa@redhat.com, tglx@linutronix.de, acme@redhat.com, sukadev@linux.vnet.ibm.com, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, maddy@linux.vnet.ibm.com, hpa@zytor.com, mpe@ellerman.id.au Reply-To: mpe@ellerman.id.au, hpa@zytor.com, peterz@infradead.org, mingo@kernel.org, maddy@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, sukadev@linux.vnet.ibm.com, acme@redhat.com, tglx@linutronix.de, jolsa@redhat.com In-Reply-To: <1433052383-21802-1-git-send-email-maddy@linux.vnet.ibm.com> References: <1433052383-21802-1-git-send-email-maddy@linux.vnet.ibm.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Remove newline char when reading event scale and unit Git-Commit-ID: 9ecae065f3295d7ea5e1c5492170a848ca255a46 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 Commit-ID: 9ecae065f3295d7ea5e1c5492170a848ca255a46 Gitweb: http://git.kernel.org/tip/9ecae065f3295d7ea5e1c5492170a848ca255a46 Author: Madhavan Srinivasan AuthorDate: Sun, 31 May 2015 11:36:23 +0530 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 1 Jun 2015 10:26:19 -0300 perf tools: Remove newline char when reading event scale and unit The commit intruduced the perf_event_sysfs_show function to display the event_str value of an attr in kernel/event/core.c. But the function returns the value with a newline char. So, if a event also carries a event.unit file, when printing the counter data perf tool formatting goes for a spin. That is, because of the event unit, event name is printed in the newline because of perf_event_sysfs_show returns with a newline char. Now fixing perf core will break API, hencing proposing a fix in the perf tool. Signed-off-by: Madhavan Srinivasan Cc: Jiri Olsa Cc: Michael Ellerman Cc: Peter Zijlstra Cc: Sukadev Bhattiprolu Link: http://lkml.kernel.org/r/1433052383-21802-1-git-send-email-maddy@linux.vnet.ibm.com [ Add spaces around operators ] Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/pmu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c index 5d3ab7c..0fcc624 100644 --- a/tools/perf/util/pmu.c +++ b/tools/perf/util/pmu.c @@ -112,7 +112,11 @@ static int perf_pmu__parse_scale(struct perf_pmu_alias *alias, char *dir, char * if (sret < 0) goto error; - scale[sret] = '\0'; + if (scale[sret - 1] == '\n') + scale[sret - 1] = '\0'; + else + scale[sret] = '\0'; + /* * save current locale */ @@ -154,7 +158,10 @@ static int perf_pmu__parse_unit(struct perf_pmu_alias *alias, char *dir, char *n close(fd); - alias->unit[sret] = '\0'; + if (alias->unit[sret - 1] == '\n') + alias->unit[sret - 1] = '\0'; + else + alias->unit[sret] = '\0'; return 0; error: