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: Fri, 16 Mar 2007 11:26:50 -0700	[thread overview]
Message-ID: <45FAE16A.3080601@freedesktop.org> (raw)
In-Reply-To: <ee9e417a0703141210n7d8e8834j56c17b69ce68ff2c@mail.gmail.com>

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

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

  reply	other threads:[~2007-03-16 18:27 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 [this message]
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=45FAE16A.3080601@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