Linux SPARSE checker discussions
 help / color / mirror / Atom feed
From: Josh Triplett <josh@freedesktop.org>
To: Russ Cox <rsc@swtch.com>
Cc: linux-sparse@vger.kernel.org, Tom Bergan <tbergan@ucla.edu>
Subject: Re: constness bug in include/linux/compiler.h
Date: Wed, 14 Mar 2007 09:18:54 -0700	[thread overview]
Message-ID: <45F8206E.8030706@freedesktop.org> (raw)
In-Reply-To: <ee9e417a0703131523x2cc701f7l7938624175bf1fe0@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 964 bytes --]

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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]

  reply	other threads:[~2007-03-14 16:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-13 22:23 constness bug in include/linux/compiler.h Russ Cox
2007-03-14 16:18 ` Josh Triplett [this message]
2007-03-14 19:10   ` Russ Cox
2007-03-16 18:26     ` Josh Triplett
2007-03-16 18:40       ` Josh Triplett
2007-03-17  2:30       ` Linus Torvalds

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45F8206E.8030706@freedesktop.org \
    --to=josh@freedesktop.org \
    --cc=linux-sparse@vger.kernel.org \
    --cc=rsc@swtch.com \
    --cc=tbergan@ucla.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox