Skip to contentSkip to conversation

capabilities: use logical OR

PATCH In review Min-Hua Chen 2 participants 2 messages May 29, 2023 – May 30, 2023

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

PATCH 1/1 capabilities: use logical OR

Use logical OR to fix the following sparse warnings:

security/commoncap.c:1358:41: sparse: warning: dubious: !x | y

No functional changes intended.

---
 security/commoncap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/commoncap.c +1 -1
index 0b3fc2f3afe7..b8e34f6204b2 100644
@@ -1355,7 +1355,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) {
Signature · 1 line
2.34.1
#1 lore raw

From: Min-Hua Chen <[email protected]>

Quoted 7 lines

Sent: 29 May 2023 23:55

Use logical OR to fix the following sparse warnings:

security/commoncap.c:1358:41: sparse: warning: dubious: !x | y

No functional changes intended.

Except it will run just that teeny, weeny bit slower.

David

Quoted 19 lines
---
 security/commoncap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/commoncap.c +1 -2
index 0b3fc2f3afe7..b8e34f6204b2 100644
@@ -1355,7 +1355,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) {
--
Quoted 1 line

2.34.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)