Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932290AbbFCWl4 (ORCPT ); Wed, 3 Jun 2015 18:41:56 -0400 Received: from casper.infradead.org ([85.118.1.10]:40371 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932196AbbFCWlr (ORCPT ); Wed, 3 Jun 2015 18:41:47 -0400 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Madhavan Srinivasan , Jiri Olsa , Michael Ellerman , Peter Zijlstra , Sukadev Bhattiprolu , Arnaldo Carvalho de Melo Subject: [PATCH 2/6] perf tools: Remove newline char when reading event scale and unit Date: Wed, 3 Jun 2015 19:40:34 -0300 Message-Id: <1433371238-14572-3-git-send-email-acme@kernel.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1433371238-14572-1-git-send-email-acme@kernel.org> References: <1433371238-14572-1-git-send-email-acme@kernel.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2057 Lines: 63 From: Madhavan Srinivasan 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 5d3ab7c8ceaf..0fcc624eb767 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: -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/