Skip to contentSkip to conversation

perf machine: Assign boolean values to a bool variable

PATCH Applied Jiapeng Chong 3 participants 3 messages Mar 9, 2021 – Mar 10, 2021

Subsystems (4)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf machine: Assign boolean values to a bool variable

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.

---
 tools/perf/util/machine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/machine.c +2 -2
index b5c2d8b..435771e 100644
@@ -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,
Signature · 1 line
1.8.3.1
maintainer Applied
#1 lore raw

Em Tue, Mar 09, 2021 at 06:11:09PM +0800, Jiapeng Chong escreveu:

Quoted 4 lines

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.

Thanks, applied.

- Arnaldo

Quoted 24 lines
---
 tools/perf/util/machine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/machine.c +2 -2
index b5c2d8b..435771e 100644
@@ -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,
Signature · 1 line
1.8.3.1
Signature · 1 line
- Arnaldo
#2 lore raw
In reply to Jiapeng Chong

From: Jiapeng Chong

Quoted 18 lines

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.

---
 tools/perf/util/machine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/machine.c +0 -0
index b5c2d8b..435771e 100644

tools/perf/util/machine.c int machine__process_event(struct machine *machine, union perf_event *event, · line 2042

Quoted 7 lines
tools/perf/util/machine.c +2 -2
@@ -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)