Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752060AbbFAN2P (ORCPT ); Mon, 1 Jun 2015 09:28:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43520 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751332AbbFAN2H (ORCPT ); Mon, 1 Jun 2015 09:28:07 -0400 Date: Mon, 1 Jun 2015 10:28:03 -0300 From: Arnaldo Carvalho de Melo To: Madhavan Srinivasan Cc: linux-kernel@vger.kernel.org, Peter Zijlstra , Ingo Molnar , Jiri Olsa , Sukadev Bhattiprolu , Michael Ellerman Subject: Re: [PATCH] perf/tool: remove newline char when reading event scale and unit Message-ID: <20150601132803.GA2348@redhat.com> References: <1433052383-21802-1-git-send-email-maddy@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1433052383-21802-1-git-send-email-maddy@linux.vnet.ibm.com> X-Url: http://acmel.wordpress.com User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1451 Lines: 48 Em Sun, May 31, 2015 at 11:36:23AM +0530, Madhavan Srinivasan escreveu: > 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. Looks sensible, but please next time add spaces around operators, doing it this time. I.e., it should be: scale[sret - 1] = '\0'; Thanks, - Arnaldo > + 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 -- 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/