* [PATCH] CRED: fix compilation warning in function 'get_cred'
@ 2008-11-20 22:00 ` Hannes Eder
0 siblings, 0 replies; 9+ messages in thread
From: Hannes Eder @ 2008-11-20 22:00 UTC (permalink / raw)
To: David Howells, linux-kernel, kernel-janitors
Fix to following warning by introducing a temporary variable:
include/linux/cred.h: In function 'get_cred':
include/linux/cred.h:187: warning: passing argument 1 of
'get_new_cred' discards qualifiers from pointer target type
Signed-off-by: Hannes Eder <hannes@hanneseder.net>
---
With -O2 the same code as for the original function is generated.
include/linux/cred.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 26c1ab1..2ab8cf7 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -184,7 +184,8 @@ static inline struct cred *get_new_cred(struct cred *cred)
*/
static inline const struct cred *get_cred(const struct cred *cred)
{
- return get_new_cred((struct cred *) cred);
+ struct cred *non_const_cred = (struct cred *) cred;
+ return get_new_cred(non_const_cred);
}
/**
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] CRED: fix compilation warning in function 'get_cred'
@ 2008-11-20 22:00 ` Hannes Eder
0 siblings, 0 replies; 9+ messages in thread
From: Hannes Eder @ 2008-11-20 22:00 UTC (permalink / raw)
To: David Howells, linux-kernel, kernel-janitors
Fix to following warning by introducing a temporary variable:
include/linux/cred.h: In function 'get_cred':
include/linux/cred.h:187: warning: passing argument 1 of
'get_new_cred' discards qualifiers from pointer target type
Signed-off-by: Hannes Eder <hannes@hanneseder.net>
---
With -O2 the same code as for the original function is generated.
include/linux/cred.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/include/linux/cred.h b/include/linux/cred.h
index 26c1ab1..2ab8cf7 100644
--- a/include/linux/cred.h
+++ b/include/linux/cred.h
@@ -184,7 +184,8 @@ static inline struct cred *get_new_cred(struct cred *cred)
*/
static inline const struct cred *get_cred(const struct cred *cred)
{
- return get_new_cred((struct cred *) cred);
+ struct cred *non_const_cred = (struct cred *) cred;
+ return get_new_cred(non_const_cred);
}
/**
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] CRED: fix compilation warning in function 'get_cred'
2008-11-20 22:00 ` Hannes Eder
(?)
@ 2008-11-20 22:19 ` David Howells
2008-11-21 14:54 ` Hannes Eder
-1 siblings, 1 reply; 9+ messages in thread
From: David Howells @ 2008-11-20 22:19 UTC (permalink / raw)
To: Hannes Eder; +Cc: dhowells, linux-kernel, kernel-janitors
Hannes Eder <hannes@hanneseder.net> wrote:
> Fix to following warning by introducing a temporary variable:
>
> include/linux/cred.h: In function 'get_cred':
> include/linux/cred.h:187: warning: passing argument 1 of
> 'get_new_cred' discards qualifiers from pointer target type
Interesting. I believe that's a compiler bug. Explicitly casting away the
const should avoid this warning.
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] CRED: fix compilation warning in function 'get_cred'
2008-11-20 22:19 ` David Howells
@ 2008-11-21 14:54 ` Hannes Eder
0 siblings, 0 replies; 9+ messages in thread
From: Hannes Eder @ 2008-11-21 14:54 UTC (permalink / raw)
To: David Howells; +Cc: linux-kernel, kernel-janitors
On Thu, Nov 20, 2008 at 11:19 PM, David Howells <dhowells@redhat.com> wrote:
> Hannes Eder <hannes@hanneseder.net> wrote:
>
>> Fix to following warning by introducing a temporary variable:
>>
>> include/linux/cred.h: In function 'get_cred':
>> include/linux/cred.h:187: warning: passing argument 1 of
>> 'get_new_cred' discards qualifiers from pointer target type
>
> Interesting. I believe that's a compiler bug. Explicitly casting away the
> const should avoid this warning.
Strange. I think you are right, looks like a compiler bug. I am using
gcc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3). Compiling the following code
snippet does not yield a spurious warning:
struct foo {
int a;
};
static inline struct foo *bar(struct foo *foo)
{
foo->a++;
return foo;
}
static inline const struct foo *bar2(const struct foo *foo)
{
return bar((struct foo*)foo);
}
What do you suggest, report this as a gcc bug?
-Hannes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] CRED: fix compilation warning in function 'get_cred'
@ 2008-11-21 14:54 ` Hannes Eder
0 siblings, 0 replies; 9+ messages in thread
From: Hannes Eder @ 2008-11-21 14:54 UTC (permalink / raw)
To: David Howells; +Cc: linux-kernel, kernel-janitors
On Thu, Nov 20, 2008 at 11:19 PM, David Howells <dhowells@redhat.com> wrote:
> Hannes Eder <hannes@hanneseder.net> wrote:
>
>> Fix to following warning by introducing a temporary variable:
>>
>> include/linux/cred.h: In function 'get_cred':
>> include/linux/cred.h:187: warning: passing argument 1 of
>> 'get_new_cred' discards qualifiers from pointer target type
>
> Interesting. I believe that's a compiler bug. Explicitly casting away the
> const should avoid this warning.
Strange. I think you are right, looks like a compiler bug. I am using
gcc (GCC) 4.2.4 (Ubuntu 4.2.4-1ubuntu3). Compiling the following code
snippet does not yield a spurious warning:
struct foo {
int a;
};
static inline struct foo *bar(struct foo *foo)
{
foo->a++;
return foo;
}
static inline const struct foo *bar2(const struct foo *foo)
{
return bar((struct foo*)foo);
}
What do you suggest, report this as a gcc bug?
-Hannes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] CRED: fix compilation warning in function 'get_cred'
2008-11-21 14:54 ` Hannes Eder
(?)
@ 2008-11-21 16:25 ` David Howells
2008-11-21 20:22 ` Hannes Eder
-1 siblings, 1 reply; 9+ messages in thread
From: David Howells @ 2008-11-21 16:25 UTC (permalink / raw)
To: Hannes Eder; +Cc: dhowells, linux-kernel, kernel-janitors
Hannes Eder <hannes@hanneseder.net> wrote:
> What do you suggest, report this as a gcc bug?
You could do. It might be worth checking to see if it's fixed with a newer
gcc first, though.
David
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] CRED: fix compilation warning in function 'get_cred'
2008-11-21 16:25 ` David Howells
@ 2008-11-21 20:22 ` Hannes Eder
0 siblings, 0 replies; 9+ messages in thread
From: Hannes Eder @ 2008-11-21 20:22 UTC (permalink / raw)
To: David Howells; +Cc: linux-kernel, kernel-janitors
On Fri, Nov 21, 2008 at 5:25 PM, David Howells <dhowells@redhat.com> wrote:
> Hannes Eder <hannes@hanneseder.net> wrote:
>
>> What do you suggest, report this as a gcc bug?
>
> You could do. It might be worth checking to see if it's fixed with a newer
> gcc first, though.
The spurious warning is gone with gcc (Ubuntu 4.3.2-1ubuntu11) 4.3.2.
Hannes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] CRED: fix compilation warning in function 'get_cred'
@ 2008-11-21 20:22 ` Hannes Eder
0 siblings, 0 replies; 9+ messages in thread
From: Hannes Eder @ 2008-11-21 20:22 UTC (permalink / raw)
To: David Howells; +Cc: linux-kernel, kernel-janitors
On Fri, Nov 21, 2008 at 5:25 PM, David Howells <dhowells@redhat.com> wrote:
> Hannes Eder <hannes@hanneseder.net> wrote:
>
>> What do you suggest, report this as a gcc bug?
>
> You could do. It might be worth checking to see if it's fixed with a newer
> gcc first, though.
The spurious warning is gone with gcc (Ubuntu 4.3.2-1ubuntu11) 4.3.2.
Hannes
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] CRED: fix compilation warning in function 'get_cred'
2008-11-21 20:22 ` Hannes Eder
(?)
@ 2008-11-22 0:36 ` David Howells
-1 siblings, 0 replies; 9+ messages in thread
From: David Howells @ 2008-11-22 0:36 UTC (permalink / raw)
To: Hannes Eder; +Cc: dhowells, linux-kernel, kernel-janitors
Hannes Eder <hannes@hanneseder.net> wrote:
> The spurious warning is gone with gcc (Ubuntu 4.3.2-1ubuntu11) 4.3.2.
Then I wouldn't worry about it too much.
David
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-11-22 0:36 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-20 22:00 [PATCH] CRED: fix compilation warning in function 'get_cred' Hannes Eder
2008-11-20 22:00 ` Hannes Eder
2008-11-20 22:19 ` David Howells
2008-11-21 14:54 ` Hannes Eder
2008-11-21 14:54 ` Hannes Eder
2008-11-21 16:25 ` David Howells
2008-11-21 20:22 ` Hannes Eder
2008-11-21 20:22 ` Hannes Eder
2008-11-22 0:36 ` David Howells
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.