From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: Christopher Li <sparse@chrisli.org>
Cc: Fengguang Wu <fengguang.wu@intel.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Roman Kagan <rkagan@virtuozzo.com>,
"Denis V. Lunev" <den@openvz.org>,
Andrey Smetanin <asmetanin@virtuozzo.com>,
Linux-Sparse <linux-sparse@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: Re: [PATCH] Do not drop 'nocast' modifier when taking the address.
Date: Wed, 3 Feb 2016 04:43:58 +0100 [thread overview]
Message-ID: <20160203034357.GA3332@macbook.lan> (raw)
In-Reply-To: <CANeU7Q=uxwTPGdxuh9f2=1dSeC3wdQtu+zgP8BzRJnqh5s_HKg@mail.gmail.com>
On Wed, Feb 03, 2016 at 04:25:44AM +0800, Christopher Li wrote:
> On Wed, Jan 6, 2016 at 12:25 AM, Luc Van Oostenryck
> <luc.vanoostenryck@gmail.com> wrote:
> > With the following code:
> > typedef unsigned long __nocast cputime_t;
> >
> > void task_cputime_adjusted(cputime_t *);
> >
> > void current_task_runtime_100ns(void)
> > {
> > cputime_t utime;
> >
> > task_cputime_adjusted(&utime);
> > }
> >
> > sparse emits the following message:
> > x.c:16:32: warning: incorrect type in argument 1 (different modifiers)
> > x.c:16:32: expected unsigned long [nocast] [usertype] *<noident>
> > x.c:16:32: got unsigned long *<noident>
> > x.c:16:32: warning: implicit cast to nocast type
> >
> > In other words, when taking the address of 'utime', sparse drops the 'nocast'
> > modifier and then complains that task_cputime_adjusted() is not given a
> > 'nocast' pointer as expected ...
>
> I think there is a bug some where else. In the above example,
> "cputime_t *" and "&utime" should have the same type regardless
> pointer inherent the nocast attribute or not. I haven't fully understand
> where the nocast attribute get dropped.
The nocast mod is dropped and lost in the function create_pointer().
In the example above, "cputime_t *" has type :
unsigned long [nocast] [usertype] *
while &utime is just:
unsigned long *
So, for sparse and its extended notion of type, the type we get when
taking the address of a [variable of some] type X is not the same as
directly using a pointer to the type X.
Which is very fine, just that MOD_NOCAST is dropped while the example
shows that it should not.
OTOH, MOD_STORAGE is kept but I think should be dropped; but that's
another story.
Regards,
Luc
next prev parent reply other threads:[~2016-02-03 3:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <201509182109.6ccgXDVp%fengguang.wu@intel.com>
[not found] ` <55FC16F4.7060407@openvz.org>
[not found] ` <55FC17B4.9060702@redhat.com>
[not found] ` <20150918144026.GJ3317@rkaganb.sw.ru>
[not found] ` <55FC22B4.9010301@redhat.com>
2015-09-18 15:06 ` [kbuild-all] [kvm:queue 27/38] arch/x86/kvm/hyperv.c:186:41: sparse: incorrect type in argument 2 (different modifiers) Fengguang Wu
2016-01-05 13:51 ` Luc Van Oostenryck
2016-01-05 16:25 ` [PATCH] Do not drop 'nocast' modifier when taking the address Luc Van Oostenryck
2016-02-02 20:25 ` Christopher Li
2016-02-03 3:43 ` Luc Van Oostenryck [this message]
2016-02-03 4:09 ` Christopher Li
2016-02-03 9:15 ` Luc Van Oostenryck
2016-02-22 18:41 ` Christopher Li
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=20160203034357.GA3332@macbook.lan \
--to=luc.vanoostenryck@gmail.com \
--cc=asmetanin@virtuozzo.com \
--cc=den@openvz.org \
--cc=fengguang.wu@intel.com \
--cc=linux-sparse@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkagan@virtuozzo.com \
--cc=schwidefsky@de.ibm.com \
--cc=sparse@chrisli.org \
--cc=torvalds@linux-foundation.org \
/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;
as well as URLs for NNTP newsgroup(s).