From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752119AbbCKA6b (ORCPT ); Tue, 10 Mar 2015 20:58:31 -0400 Received: from LGEMRELSE6Q.lge.com ([156.147.1.121]:57041 "EHLO lgemrelse6q.lge.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750967AbbCKA63 (ORCPT ); Tue, 10 Mar 2015 20:58:29 -0400 X-Original-SENDERIP: 10.177.220.203 X-Original-MAILFROM: namhyung@kernel.org Date: Wed, 11 Mar 2015 09:52:41 +0900 From: Namhyung Kim To: Andi Kleen Cc: Andi Kleen , acme@kernel.org, jolsa@redhat.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/4] perf, tools: Output running time and run/enabled ratio in CSV mode Message-ID: <20150311005241.GI943@sejong> References: <1425858924-31414-1-git-send-email-andi@firstfloor.org> <1425858924-31414-2-git-send-email-andi@firstfloor.org> <20150310071518.GF943@sejong> <20150310153704.GH31334@tassilo.jf.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150310153704.GH31334@tassilo.jf.intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 10, 2015 at 08:37:04AM -0700, Andi Kleen wrote: > > Why not handle both cases here? > > > > static void print_running(u64 run, u64 ena) > > { > > if (csv_output) > > fprintf(output, ...); > > else if (run != ena) > > fprintf(output, ...); > > } > > print_running has 6 callers. run != ena is only needed > for two of them. So I don't think it makes sense to do. Those 6 are from print_aggr(), print_counter_aggr() and print_counter(). They all have two branch - one is for no-scaling or not-supported counter (I guess run or ena being 0 goes to this case), another is scaling case - so IMHO print_counter_aggr() should check the run and the ena in this case too. The former can call print_running() to print empty column to CSV and discard normal (scaling) output. The latter also can call print_running() to print for both output. So by using print_running(), we can enforce same check to all cases and reduce code duplication also IMHO. Thanks, Namhyung > > -Andi > -- > 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/