Skip to content

Commit 3411158

Browse files
nathanchanceChristian Brauner
authored andcommitted
usercopy: Add parentheses around assignment in test_copy_struct_from_user
Clang warns: lib/test_user_copy.c:96:10: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] if (ret |= test(umem_src == NULL, "kmalloc failed")) ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/test_user_copy.c:96:10: note: place parentheses around the assignment to silence this warning if (ret |= test(umem_src == NULL, "kmalloc failed")) ^ ( ) lib/test_user_copy.c:96:10: note: use '!=' to turn this compound assignment into an inequality comparison if (ret |= test(umem_src == NULL, "kmalloc failed")) ^~ != Add the parentheses as it suggests because this is intentional. Fixes: f5a1a53 ("lib: introduce copy_struct_from_user() helper") Link: ClangBuiltLinux#731 Signed-off-by: Nathan Chancellor <[email protected]> Acked-by: Aleksa Sarai <[email protected]> Acked-by: Christian Brauner <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent c2ba8f4 commit 3411158

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/test_user_copy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,11 @@ static int test_copy_struct_from_user(char *kmem, char __user *umem,
9393
size_t ksize, usize;
9494

9595
umem_src = kmalloc(size, GFP_KERNEL);
96-
if (ret |= test(umem_src == NULL, "kmalloc failed"))
96+
if ((ret |= test(umem_src == NULL, "kmalloc failed")))
9797
goto out_free;
9898

9999
expected = kmalloc(size, GFP_KERNEL);
100-
if (ret |= test(expected == NULL, "kmalloc failed"))
100+
if ((ret |= test(expected == NULL, "kmalloc failed")))
101101
goto out_free;
102102

103103
/* Fill umem with a fixed byte pattern. */

0 commit comments

Comments
 (0)