Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1626146

Re: [PATCH v5 4/7] perf report: Refactor the branch info printing code

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH v5 4/7] perf report: Refactor the branch info printing code
Date 2017-04-19 16:20 +0200
Message-ID <txYCC-4sd-23@gated-at.bofh.it> (permalink)
References <txSGR-FS-7@gated-at.bofh.it> <txSGS-FS-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Apr 19, 2017 at 11:48:11PM +0800, Jin Yao wrote:

SNIP

>  static int counts_str_build(char *bf, int bfsize,
>  			     u64 branch_count, u64 predicted_count,
>  			     u64 abort_count, u64 cycles_count,
>  			     u64 iter_count, u64 samples_count)
>  {
> -	double predicted_percent = 0.0;
> -	const char *null_str = "";
> -	char iter_str[32];
> -	char cycle_str[32];
> -	char *istr, *cstr;
>  	u64 cycles;
> +	int printed = 0, i = 0;
>  
>  	if (branch_count == 0)
>  		return scnprintf(bf, bfsize, " (calltrace)");
>  
>  	cycles = cycles_count / branch_count;
> +	if (cycles)
> +		printed += count_pri64_printf(i++, "cycles",
> +				cycles,
> +				bf + printed, bfsize - printed);
>  
> -	if (iter_count && samples_count) {
> -		if (cycles > 0)
> -			scnprintf(iter_str, sizeof(iter_str),
> -				 " iterations:%" PRId64 "",
> -				 iter_count / samples_count);
> -		else
> -			scnprintf(iter_str, sizeof(iter_str),
> -				 "iterations:%" PRId64 "",
> -				 iter_count / samples_count);
> -		istr = iter_str;
> -	} else
> -		istr = (char *)null_str;
> -
> -	if (cycles > 0) {
> -		scnprintf(cycle_str, sizeof(cycle_str),
> -			  "cycles:%" PRId64 "", cycles);
> -		cstr = cycle_str;
> -	} else
> -		cstr = (char *)null_str;
> +	if (iter_count && samples_count)
> +		printed += count_pri64_printf(i++, "iterations",
> +				iter_count / samples_count,
> +				bf + printed, bfsize - printed);

please put the multiline condition code into {} brackets
for all of the cases in this function

thanks,
jirka

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH v5 4/7] perf report: Refactor the branch info printing code Jin Yao <yao.jin@linux.intel.com> - 2017-04-19 10:00 +0200
  Re: [PATCH v5 4/7] perf report: Refactor the branch info printing  code Jiri Olsa <jolsa@redhat.com> - 2017-04-19 16:20 +0200
  Re: [PATCH v5 4/7] perf report: Refactor the branch info printing  code Jiri Olsa <jolsa@redhat.com> - 2017-04-19 16:20 +0200

csiph-web