lkml.org 
[lkml]   [2023]   [Nov]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] x86: Fixes warning: cast removes address space '__user' of expression in uaccess_64.h
From
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.

\
 
 \ /
  Last update: 2023-11-20 14:02    [W:0.105 / U:0.780 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site