diff mbox series

perf machine: Assign boolean values to a bool variable

Message ID 1615284669-82139-1-git-send-email-jiapeng.chong@linux.alibaba.com
State Superseded
Headers show
Series perf machine: Assign boolean values to a bool variable | expand

Commit Message

Jiapeng Chong March 9, 2021, 10:11 a.m. UTC
Fix the following coccicheck warnings:

./tools/perf/util/machine.c:2041: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(-)

Comments

David Laight March 10, 2021, 9:55 a.m. UTC | #1
From: Jiapeng Chong

> Sent: 09 March 2021 10:11

> 

> Fix the following coccicheck warnings:

> 

> ./tools/perf/util/machine.c:2041: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 b5c2d8b..435771e 100644

> --- a/tools/perf/util/machine.c

> +++ b/tools/perf/util/machine.c

> @@ -2038,8 +2038,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;


What's wrong with:
	return !regexec(regex, sym->name, 0, NULL, 0);

    David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
diff mbox series

Patch

diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index b5c2d8b..435771e 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -2038,8 +2038,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,