linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools-perf: Change -1 by false
@ 2015-09-17 10:08 Peter Senna Tschudin
  2015-09-17 18:33 ` Arnaldo Carvalho de Melo
  2015-09-18  5:49 ` [tip:perf/urgent] perf tools: Bool functions shouldn't return -1 tip-bot for Peter Senna Tschudin
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Senna Tschudin @ 2015-09-17 10:08 UTC (permalink / raw)
  To: a.p.zijlstra, mingo, acme, jolsa, matt.fleming, namhyung, milos,
	kan.liang, rostedt, linux-kernel
  Cc: Peter Senna Tschudin

Returning a negative value for a boolean function seem to have the
undesired effect of returning true. Replace -1 by false in a
bool-returning function.

The diff of the .s file before and after the change (for x86_64):
3907c3907
< 	movl	$1, %ebx
---
> 	xorl	%ebx, %ebx

while if -1 is replaced by true, the diff is empty.

This issue was found by the following Coccinelle semantic patch:
<smpl>
@@
identifier f;
constant C;
typedef bool;
@@
bool f (...){
<+...
* return -C;
...+>
}
</smpl>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
 tools/perf/util/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 49a5c6a..ce465b2 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -639,7 +639,7 @@ bool find_process(const char *name)
 
 	dir = opendir(procfs__mountpoint());
 	if (!dir)
-		return -1;
+		return false;
 
 	/* Walk through the directory. */
 	while (ret && (d = readdir(dir)) != NULL) {
-- 
2.1.0


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

end of thread, other threads:[~2015-09-18  5:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-17 10:08 [PATCH] tools-perf: Change -1 by false Peter Senna Tschudin
2015-09-17 18:33 ` Arnaldo Carvalho de Melo
2015-09-18  5:49 ` [tip:perf/urgent] perf tools: Bool functions shouldn't return -1 tip-bot for Peter Senna Tschudin

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).