All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: David Howells <dhowells@redhat.com>
Cc: Harvey Harrison <harvey.harrison@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] cred: remove const qualifiers
Date: Tue, 19 Aug 2008 00:32:11 -0700	[thread overview]
Message-ID: <20080819003211.ba6b0ac5.akpm@linux-foundation.org> (raw)
In-Reply-To: <12514.1218365916@redhat.com>

On Sun, 10 Aug 2008 11:58:36 +0100 David Howells <dhowells@redhat.com> wrote:

> Harvey Harrison <harvey.harrison@gmail.com> wrote:
> 
> > get_new_cred clearly writes through the pointer, so const isn't
> > appropriate.  Sparse warns thusly:
> > 
> > include/linux/cred.h: In function ___get_cred___:
> > include/linux/cred.h:181: warning: passing argument 1 of ___get_new_cred___ discards qualifiers from pointer target type
> 
> Sparse is wrong in this instance, it failed to note the cast.  I know what I'm
> doing.

Nobody who reads the code will know what you were doing - the code
looks plain wrong.

> > -static inline const struct cred *get_cred(const struct cred *cred)
> > +static inline struct cred *get_cred(struct cred *cred)
> 
> That will break the compilation.  Please don't do that.
> 
> The point of my use of const in this instance is to stop people from trying to
> modify committed credentials directly, especially current->cred.  But we still
> have to be able to take a reference to it.  Unfortunately, C does not provide
> the necessary tools to do what I want.
> 
> Eventually, we can probably ditch the const marks on the pointers but not yet.

That information should have been included in a code comment.

  reply	other threads:[~2008-08-19  7:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-09 23:02 [PATCH] cred: remove const qualifiers Harvey Harrison
2008-08-10 10:58 ` David Howells
2008-08-19  7:32   ` Andrew Morton [this message]
2008-08-21 13:24     ` David Howells

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=20080819003211.ba6b0ac5.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dhowells@redhat.com \
    --cc=harvey.harrison@gmail.com \
    --cc=linux-kernel@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.