lkml.org 
[lkml]   [2008]   [Aug]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] cred: remove const qualifiers
Date
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.

> -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.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2008-08-10 13:01    [W:0.083 / U:0.036 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site