linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools/perf: remove unneeded variable make code cleaner
@ 2021-12-10  2:29 cgel.zte
  2021-12-10  9:11 ` kajoljain
  0 siblings, 1 reply; 4+ messages in thread
From: cgel.zte @ 2021-12-10  2:29 UTC (permalink / raw)
  To: peterz
  Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
	chi.minghao, linux-perf-users, linux-kernel, Zeal Robot

From: Minghao Chi <chi.minghao@zte.com.cn>

return value form directly instead of
taking this in another redundant variable.

Reported-by: Zeal Robot <zealci@zte.com.cm>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
---
 tools/perf/util/callchain.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 8e2777133bd9..ed30da7e14ab 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -1301,24 +1301,16 @@ int callchain_branch_counts(struct callchain_root *root,
 
 static int count_pri64_printf(int idx, const char *str, u64 value, char *bf, int bfsize)
 {
-	int printed;
-
-	printed = scnprintf(bf, bfsize, "%s%s:%" PRId64 "", (idx) ? " " : " (", str, value);
-
-	return printed;
+	return scnprintf(bf, bfsize, "%s%s:%" PRId64 "", (idx) ? " " : " (", str, value);
 }
 
 static int count_float_printf(int idx, const char *str, float value,
 			      char *bf, int bfsize, float threshold)
 {
-	int printed;
-
 	if (threshold != 0.0 && value < threshold)
 		return 0;
 
-	printed = scnprintf(bf, bfsize, "%s%s:%.1f%%", (idx) ? " " : " (", str, value);
-
-	return printed;
+	return scnprintf(bf, bfsize, "%s%s:%.1f%%", (idx) ? " " : " (", str, value);
 }
 
 static int branch_to_str(char *bf, int bfsize,
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/perf: remove unneeded variable make code cleaner
  2021-12-10  2:29 [PATCH] tools/perf: remove unneeded variable make code cleaner cgel.zte
@ 2021-12-10  9:11 ` kajoljain
  2021-12-10 10:42   ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: kajoljain @ 2021-12-10  9:11 UTC (permalink / raw)
  To: cgel.zte, peterz
  Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
	chi.minghao, linux-perf-users, linux-kernel, Zeal Robot



On 12/10/21 7:59 AM, cgel.zte@gmail.com wrote:
> From: Minghao Chi <chi.minghao@zte.com.cn>
> 
> return value form directly instead of
> taking this in another redundant variable.

Can we reword the commit message stating what and
from where we are removing it. Its not too clear.
Other than that patch looks good to me.

Reviewed-By: Kajol Jain<kjain@linux.ibm.com>

Thanks,
Kajol Jain

> 
> Reported-by: Zeal Robot <zealci@zte.com.cm>
> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
> ---
>  tools/perf/util/callchain.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)
> 
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index 8e2777133bd9..ed30da7e14ab 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -1301,24 +1301,16 @@ int callchain_branch_counts(struct callchain_root *root,
>  
>  static int count_pri64_printf(int idx, const char *str, u64 value, char *bf, int bfsize)
>  {
> -	int printed;
> -
> -	printed = scnprintf(bf, bfsize, "%s%s:%" PRId64 "", (idx) ? " " : " (", str, value);
> -
> -	return printed;
> +	return scnprintf(bf, bfsize, "%s%s:%" PRId64 "", (idx) ? " " : " (", str, value);
>  }
>  
>  static int count_float_printf(int idx, const char *str, float value,
>  			      char *bf, int bfsize, float threshold)
>  {
> -	int printed;
> -
>  	if (threshold != 0.0 && value < threshold)
>  		return 0;
>  
> -	printed = scnprintf(bf, bfsize, "%s%s:%.1f%%", (idx) ? " " : " (", str, value);
> -
> -	return printed;
> +	return scnprintf(bf, bfsize, "%s%s:%.1f%%", (idx) ? " " : " (", str, value);
>  }
>  
>  static int branch_to_str(char *bf, int bfsize,
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/perf: remove unneeded variable make code cleaner
  2021-12-10  9:11 ` kajoljain
@ 2021-12-10 10:42   ` Peter Zijlstra
  2021-12-10 12:44     ` kajoljain
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Zijlstra @ 2021-12-10 10:42 UTC (permalink / raw)
  To: kajoljain
  Cc: cgel.zte, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
	namhyung, chi.minghao, linux-perf-users, linux-kernel,
	Zeal Robot

On Fri, Dec 10, 2021 at 02:41:55PM +0530, kajoljain wrote:
> 
> 
> On 12/10/21 7:59 AM, cgel.zte@gmail.com wrote:
> > From: Minghao Chi <chi.minghao@zte.com.cn>
> > 
> > return value form directly instead of
> > taking this in another redundant variable.
> 
> Can we reword the commit message stating what and
> from where we are removing it. Its not too clear.
> Other than that patch looks good to me.
> 
> Reviewed-By: Kajol Jain<kjain@linux.ibm.com>

Never reply or accept email from cgel.zte@gmail.com, there's multiple
people using it to send email, this cannot be right.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] tools/perf: remove unneeded variable make code cleaner
  2021-12-10 10:42   ` Peter Zijlstra
@ 2021-12-10 12:44     ` kajoljain
  0 siblings, 0 replies; 4+ messages in thread
From: kajoljain @ 2021-12-10 12:44 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: cgel.zte, mingo, acme, mark.rutland, alexander.shishkin, jolsa,
	namhyung, chi.minghao, linux-perf-users, linux-kernel,
	Zeal Robot



On 12/10/21 4:12 PM, Peter Zijlstra wrote:
> On Fri, Dec 10, 2021 at 02:41:55PM +0530, kajoljain wrote:
>>
>>
>> On 12/10/21 7:59 AM, cgel.zte@gmail.com wrote:
>>> From: Minghao Chi <chi.minghao@zte.com.cn>
>>>
>>> return value form directly instead of
>>> taking this in another redundant variable.
>>
>> Can we reword the commit message stating what and
>> from where we are removing it. Its not too clear.
>> Other than that patch looks good to me.
>>
>> Reviewed-By: Kajol Jain<kjain@linux.ibm.com>
> 
> Never reply or accept email from cgel.zte@gmail.com, there's multiple
> people using it to send email, this cannot be right.
> 

Sure peter, Thanks for pointing it. Will take care next time.

Thanks,
Kajol Jain

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-12-10 12:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10  2:29 [PATCH] tools/perf: remove unneeded variable make code cleaner cgel.zte
2021-12-10  9:11 ` kajoljain
2021-12-10 10:42   ` Peter Zijlstra
2021-12-10 12:44     ` kajoljain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).