From: Josh Triplett <josh@freedesktop.org>
To: Josh Triplett <josh@freedesktop.org>
Cc: Russ Cox <rsc@swtch.com>,
linux-sparse@vger.kernel.org, Tom Bergan <tbergan@ucla.edu>
Subject: Re: constness bug in include/linux/compiler.h
Date: Fri, 16 Mar 2007 11:40:18 -0700 [thread overview]
Message-ID: <45FAE492.2040504@freedesktop.org> (raw)
In-Reply-To: <45FAE16A.3080601@freedesktop.org>
[-- Attachment #1: Type: text/plain, Size: 1493 bytes --]
Josh Triplett wrote:
> 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.
This bug appears to come from the following code in compatible_assignment_types:
/* "void *" matches anything as long as the address space is OK */
target_as = t->ctype.as | target->ctype.as;
source_as = s->ctype.as | source->ctype.as;
if (source_as == target_as && (s->type == SYM_PTR || s->type == SYM_ARRAY)) {
s = get_base_type(s);
t = get_base_type(t);
if (s == &void_ctype || t == &void_ctype)
goto Cast;
}
This should almost certainly check more than just address spaces.
- Josh Triplett
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 252 bytes --]
next prev parent reply other threads:[~2007-03-16 18:40 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
2007-03-14 19:10 ` Russ Cox
2007-03-16 18:26 ` Josh Triplett
2007-03-16 18:40 ` Josh Triplett [this message]
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=45FAE492.2040504@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