From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756207AbbEaGGs (ORCPT ); Sun, 31 May 2015 02:06:48 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:56533 "EHLO e28smtp07.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751604AbbEaGGj (ORCPT ); Sun, 31 May 2015 02:06:39 -0400 From: Madhavan Srinivasan To: linux-kernel@vger.kernel.org Cc: Madhavan Srinivasan , Arnaldo Carvalho de Melo , Peter Zijlstra , Ingo Molnar , Jiri Olsa , Sukadev Bhattiprolu , Michael Ellerman Subject: [PATCH] perf/tool: remove newline char when reading event scale and unit Date: Sun, 31 May 2015 11:36:23 +0530 Message-Id: <1433052383-21802-1-git-send-email-maddy@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15053106-0025-0000-0000-0000051A9F2E Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit intruduced perf_event_sysfs_show function to display 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. Cc: Arnaldo Carvalho de Melo Cc: Peter Zijlstra Cc: Ingo Molnar Cc: Jiri Olsa Cc: Sukadev Bhattiprolu Cc: Michael Ellerman Signed-off-by: Madhavan Srinivasan --- 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 4841167..cf2cb34 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: -- 1.9.1