netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf machine: Use true and false for bool variable
@ 2021-02-18  9:24 Jiapeng Chong
  2021-02-19  6:08 ` kajoljain
  0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-02-18  9:24 UTC (permalink / raw)
  To: peterz
  Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
	ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, linux-kernel, netdev, bpf, Jiapeng Chong

Fix the following coccicheck warnings:

./tools/perf/util/machine.c:2000:9-10: WARNING: return of 0/1 in
function 'symbol__match_regex' with return type bool.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
 tools/perf/util/machine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index 1e9d3f9..f7ee29b 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -1997,8 +1997,8 @@ int machine__process_event(struct machine *machine, union perf_event *event,
 static bool symbol__match_regex(struct symbol *sym, regex_t *regex)
 {
 	if (!regexec(regex, sym->name, 0, NULL, 0))
-		return 1;
-	return 0;
+		return true;
+	return false;
 }
 
 static void ip__resolve_ams(struct thread *thread,
-- 
1.8.3.1


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

* Re: [PATCH] perf machine: Use true and false for bool variable
  2021-02-18  9:24 [PATCH] perf machine: Use true and false for bool variable Jiapeng Chong
@ 2021-02-19  6:08 ` kajoljain
  0 siblings, 0 replies; 2+ messages in thread
From: kajoljain @ 2021-02-19  6:08 UTC (permalink / raw)
  To: Jiapeng Chong, peterz
  Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung,
	ast, daniel, andrii, kafai, songliubraving, yhs, john.fastabend,
	kpsingh, linux-kernel, netdev, bpf



On 2/18/21 2:54 PM, Jiapeng Chong wrote:
> Fix the following coccicheck warnings:
> 
> ./tools/perf/util/machine.c:2000:9-10: WARNING: return of 0/1 in
> function 'symbol__match_regex' with return type bool.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
>  tools/perf/util/machine.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
> index 1e9d3f9..f7ee29b 100644
> --- a/tools/perf/util/machine.c
> +++ b/tools/perf/util/machine.c
> @@ -1997,8 +1997,8 @@ int machine__process_event(struct machine *machine, union perf_event *event,
>  static bool symbol__match_regex(struct symbol *sym, regex_t *regex)
>  {
>  	if (!regexec(regex, sym->name, 0, NULL, 0))
> -		return 1;
> -	return 0;
> +		return true;
> +	return false;
>  }
>  

Hi Jiapeng,
   Just a suggestion, Can we make this check in single line like this:

static bool symbol__match_regex(struct symbol *sym, regex_t *regex)
{
	return regexec(regex, sym->name, 0, NULL, 0) == 0;
}

Thanks,
Kajol Jain

>  static void ip__resolve_ams(struct thread *thread,
> 

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

end of thread, other threads:[~2021-02-19  6:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18  9:24 [PATCH] perf machine: Use true and false for bool variable Jiapeng Chong
2021-02-19  6:08 ` 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).