Thread (2 messages) 2 messages, 2 authors, 2021-02-19

Re: [PATCH] perf machine: Use true and false for bool variable

From: kajoljain <hidden>
Date: 2021-02-19 06:11:49
Also in: bpf, lkml


On 2/18/21 2:54 PM, Jiapeng Chong wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
Signed-off-by: Jiapeng Chong <redacted>
---
 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,
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help