linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] security: Use || instead of | for boolean expressions
@ 2016-06-01  6:03 Rui Teng
  2016-06-02 14:13 ` Serge E. Hallyn
  0 siblings, 1 reply; 4+ messages in thread
From: Rui Teng @ 2016-06-01  6:03 UTC (permalink / raw)
  To: serge.hallyn, james.l.morris, serge
  Cc: linux-security-module, linux-kernel, Rui Teng

Sparse spits out the following warning:
	security/commoncap.c:989:41: warning: dubious: !x | y

Bitwise and logical are equivalent here, but logical was intended.
Replacing the bit-wise '|' with the boolean '||' silences the sparse warning.
The generated code for both cases is the same.

Signed-off-by: Rui Teng <rui.teng@linux.vnet.ibm.com>
---
 security/commoncap.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/security/commoncap.c b/security/commoncap.c
index e7fadde..8f6fb24 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -976,7 +976,7 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
 
 	case PR_CAP_AMBIENT:
 		if (arg2 == PR_CAP_AMBIENT_CLEAR_ALL) {
-			if (arg3 | arg4 | arg5)
+			if (arg3 || arg4 || arg5)
 				return -EINVAL;
 
 			new = prepare_creds();
@@ -986,7 +986,7 @@ int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,
 			return commit_creds(new);
 		}
 
-		if (((!cap_valid(arg3)) | arg4 | arg5))
+		if (((!cap_valid(arg3)) || arg4 || arg5))
 			return -EINVAL;
 
 		if (arg2 == PR_CAP_AMBIENT_IS_SET) {
-- 
2.7.4

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

end of thread, other threads:[~2016-06-02 17:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-01  6:03 [PATCH] security: Use || instead of | for boolean expressions Rui Teng
2016-06-02 14:13 ` Serge E. Hallyn
2016-06-02 16:53   ` Rui Teng
2016-06-02 17:37     ` Al Viro

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