Russ Cox wrote:
> Probably sparse just doesn't pay attention to const,

Actually, it does:

$ cat /tmp/const.c
void f(int *p)
{
}

void g(void)
{
    int i = 0;
    const int *p = &i;
    f(p);
}
$ ./sparse /tmp/const.c
/tmp/const.c:9:7: warning: incorrect type in argument 1 (different modifiers)
/tmp/const.c:9:7:    expected int *p
/tmp/const.c:9:7:    got int const *p

> but shouldn't the definitions of __chk_user_ptr
> and __chk_io_ptr be
> 
>     extern void __chk_user_ptr(const void __user *);
>     extern void __chk_io_ptr(const void __iomem *);
> 
> instead of
> 
>     extern void __chk_user_ptr(void __user *);
>     extern void __chk_io_ptr(void __iomem *);
> 
> ?

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.

- Josh Triplett

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to