Messages in this thread | | | Date | Fri, 17 Nov 2023 07:19:12 -0800 | Subject | Re: [PATCH] x86: Fixes warning: cast removes address space '__user' of expression in uaccess_64.h | From | Dave Hansen <> |
| |
On 11/16/23 09:38, Dipendra Khadka wrote: > Sparse has identified a warning as follows: > > ./arch/x86/include/asm/uaccess_64.h:88:24: warning: cast removes address space '__user' of expression. > > Since the valid_user_address(x) macro implicitly casts the argument > to long and compares the converted value of x to zero, casting ptr > to unsigned long has no functional impact and does not trigger a > Sparse warning either.
Why does sparse complain about a cast to 'long' but not 'unsigned long'? Both remove the '__user' address space from the expression. Were there just so many __user pointers being cast to 'unsigned long' that there's an exception in sparse for 'void __user *' => 'unsigned long'?
Either way, if we're going to fix it it seems like it would be better to valid_user_address() actually handle, well, __user addresses rather than expecting callers to do it.
| |