* [PATCH RESEND] tools-powerpc: Return false instead of -1
@ 2016-11-09 8:55 Andrew Shadura
2016-11-14 12:17 ` [RESEND] " Michael Ellerman
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Shadura @ 2016-11-09 8:55 UTC (permalink / raw)
To: linuxppc-dev, linux-api, linux-kernel
Cc: Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Shuah Khan, Cyril Bur
From: Peter Senna Tschudin <peter.senna@gmail.com>
Returning a negative value for a boolean function seem to have the
undesired effect of returning true. require_paranoia_below() is a
boolean function, but the variable used to store the return value is an
integer, receiving -1 or 0. This patch convert rc to bool, replace -1
by false, and 0 by true.
This issue was found by the following Coccinelle semantic patch:
<smpl>
@@
identifier f, ret;
constant C;
typedef bool;
@@
bool f (...){
<+...
ret = -C;
...
* return ret;
...+>
}
</smpl>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Andrew Shadura <andrew.shadura@collabora.co.uk>
---
tools/testing/selftests/powerpc/pmu/lib.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/powerpc/pmu/lib.c b/tools/testing/selftests/powerpc/pmu/lib.c
index 8b992fa..5bf5dd4 100644
--- a/tools/testing/selftests/powerpc/pmu/lib.c
+++ b/tools/testing/selftests/powerpc/pmu/lib.c
@@ -193,9 +193,9 @@ bool require_paranoia_below(int level)
long current;
char *end, buf[16];
FILE *f;
- int rc;
+ bool rc;
- rc = -1;
+ rc = false;
f = fopen(PARANOID_PATH, "r");
if (!f) {
@@ -218,7 +218,7 @@ bool require_paranoia_below(int level)
if (current >= level)
goto out_close;
- rc = 0;
+ rc = true;
out_close:
fclose(f);
out:
--
2.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [RESEND] tools-powerpc: Return false instead of -1
2016-11-09 8:55 [PATCH RESEND] tools-powerpc: Return false instead of -1 Andrew Shadura
@ 2016-11-14 12:17 ` Michael Ellerman
0 siblings, 0 replies; 2+ messages in thread
From: Michael Ellerman @ 2016-11-14 12:17 UTC (permalink / raw)
To: Andrew Shadura, linuxppc-dev, linux-api, linux-kernel
Cc: Shuah Khan, Paul Mackerras, Cyril Bur
On Wed, 2016-09-11 at 08:55:04 UTC, Andrew Shadura wrote:
> From: Peter Senna Tschudin <peter.senna@gmail.com>
>
> Returning a negative value for a boolean function seem to have the
> undesired effect of returning true. require_paranoia_below() is a
> boolean function, but the variable used to store the return value is an
> integer, receiving -1 or 0. This patch convert rc to bool, replace -1
> by false, and 0 by true.
>
> This issue was found by the following Coccinelle semantic patch:
> <smpl>
> @@
> identifier f, ret;
> constant C;
> typedef bool;
> @@
> bool f (...){
> <+...
> ret = -C;
> ...
> * return ret;
> ...+>
> }
> </smpl>
>
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
> Signed-off-by: Andrew Shadura <andrew.shadura@collabora.co.uk>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/0e27d27e0d6d92342797e0d37738c2
cheers
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-14 12:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-09 8:55 [PATCH RESEND] tools-powerpc: Return false instead of -1 Andrew Shadura
2016-11-14 12:17 ` [RESEND] " Michael Ellerman
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).