mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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: f5a1a536fa ("lib: introduce copy_struct_from_user() helper")
Link: https://github.com/ClangBuiltLinux/linux/issues/731
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Acked-by: Aleksa Sarai <cyphar@cyphar.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20191003171121.2723619-1-natechancellor@gmail.com
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
			
			
This commit is contained in:
		
							parent
							
								
									c2ba8f41ad
								
							
						
					
					
						commit
						341115822f
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
					@ -93,11 +93,11 @@ static int test_copy_struct_from_user(char *kmem, char __user *umem,
 | 
				
			||||||
	size_t ksize, usize;
 | 
						size_t ksize, usize;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	umem_src = kmalloc(size, GFP_KERNEL);
 | 
						umem_src = kmalloc(size, GFP_KERNEL);
 | 
				
			||||||
	if (ret |= test(umem_src == NULL, "kmalloc failed"))
 | 
						if ((ret |= test(umem_src == NULL, "kmalloc failed")))
 | 
				
			||||||
		goto out_free;
 | 
							goto out_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	expected = kmalloc(size, GFP_KERNEL);
 | 
						expected = kmalloc(size, GFP_KERNEL);
 | 
				
			||||||
	if (ret |= test(expected == NULL, "kmalloc failed"))
 | 
						if ((ret |= test(expected == NULL, "kmalloc failed")))
 | 
				
			||||||
		goto out_free;
 | 
							goto out_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Fill umem with a fixed byte pattern. */
 | 
						/* Fill umem with a fixed byte pattern. */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue