Skip to contentSkip to conversation

perf machine: Use true and false for bool variable

PATCH In review Jiapeng Chong 2 participants 2 messages Feb 18, 2021 – Feb 19, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf machine: Use true and false for bool variable

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.

---
 tools/perf/util/machine.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/perf/util/machine.c +2 -2
index 1e9d3f9..f7ee29b 100644
@@ -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,
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 16 lines · 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.

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

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

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

Quoted 2 lines
tools/perf/util/machine.c +0 -0
 static void ip__resolve_ams(struct thread *thread,