Russ Cox wrote:
>> Yes, that makes sense.  These functions just check for the annotation on 
>> their
>> pointer argument, and having the const annotation would allow them to check
>> const pointers without provoking a warning due to the lack of const.
> 
> They don't provoke a warning now.  Sparse is silent on this program:
> 
>       #define __user __attribute__((noderef, address_space(1)))
> 
>       extern void __chk_user_ptr(void __user *);
> 
>       void
>       f(const void __user *p)
>       {
>               __chk_user_ptr(p);
>       }

Hmmm, odd.  After a few iterations, I managed to discover that Sparse will
warn if you attempt to convert a const int * to an int *, but not if you
attempt to convert a const void * to a void *.  This seems like a bug to me.

> but arguably they should (and then be changed to const void __user*).

Yes.  Please do go ahead and propose the obvious const-adding patch to
include/linux/compiler.h, Cc linux-sparse, and feel free to add a
Signed-off-by from me.

- Josh Triplett

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to