2.5.9 remove warnings
PATCH 1/1 2.5.9 remove warnings
exit.c:40: warning: passing arg 1 of `__builtin_expect' makes integer from pointer without a cast
Index: 9.2/kernel/exit.c
kernel/exit.c Tue, 23 Apr 2002 13:37:06 +1000 kaos (linux-2.5/w/d/25_exit.c 1.11.1.4 644) renamed from kernel/exit.c Tue, 23 Apr 2002 11:21:19 +1000 kaos (linux-2.5/w/d/25_exit.c 1.11.1.4 644) +2 -2
@@ -37,7 +37,7 @@ static inline void __unhash_process(stru list_del(&p->thread_group); p->pid = 0; proc_dentry = p->proc_dentry; - if (unlikely(proc_dentry)) { + if (unlikely(proc_dentry != NULL)) { spin_lock(&dcache_lock); if (!list_empty(&proc_dentry->d_hash)) { dget_locked(proc_dentry);
@@ -47,7 +47,7 @@ static inline void __unhash_process(stru spin_unlock(&dcache_lock); } write_unlock_irq(&tasklist_lock); - if (unlikely(proc_dentry)) { + if (unlikely(proc_dentry != NULL)) { shrink_dcache_parent(proc_dentry); dput(proc_dentry); }
Review static inline void __unhash_process(stru · line 53
Quoted 11 lines · Keith Owens
...
(quoted diff) +1
-1@@ -47,7 +47,7 @@ static inline void __unhash_process(stru spin_unlock(&dcache_lock); } write_unlock_irq(&tasklist_lock); - if (unlikely(proc_dentry)) { + if (unlikely(proc_dentry != NULL)) { shrink_dcache_parent(proc_dentry); dput(proc_dentry); }
Is it not possible to fix it for all time?
include/linux/compiler.h +2 -2
@@ -10,8 +10,8 @@#define __builtin_expect (x, expected_value) (x)#endif -#define likely (x) __builtin_expect((x),1) -#define unlikely (x) __builtin_expect((x),0) +#define likely (x) __builtin_expect((x) != 0, 1) +#define unlikely (x) __builtin_expect((x) != 0, 0)/* This macro obfuscates arithmetic on a variable address so that gcc shouldn't recognize the original var, and make assumptions about it */
(Interestingly, this patch shrinks my kernel by 32 bytes. hmm.)
BTW, it would be very useful if someone could invert the sense of likely' and unlikely', so they always say the *wrong* thing, and then actually demonstrate some real-world slowdown. coz if this can't be done, why are we putting up with the visual clutter?
-
Quoted 6 lines · Andrew Morton
Is it not possible to fix it for all time?
include/linux/compiler.h Tue Apr 23 11:27:37 2002 line 17
Quoted 10 lines
include/linux/compiler.h Tue Apr 23 11:27:37 2002 renamed from include/linux/compiler.h Sun Apr 14 15:45:08 2002 +2
-2@@ -10,8 +10,8 @@ #define __builtin_expect(x, expected_value) (x) #endif -#define likely(x) __builtin_expect((x),1) -#define unlikely(x) __builtin_expect((x),0) +#define likely(x) __builtin_expect((x) != 0, 1) +#define unlikely(x) __builtin_expect((x) != 0, 0) /* This macro obfuscates arithmetic on a variable address so that gcc shouldn't recognize the original var, and make assumptions about it */
Wouldn't "!!(x)" make more sense here than "(x) != 0"? (I don't like comparing pointers with integers.)
Signature · 2 lines
Kasper Dupont -- der bruger for meget tid på usenet. For sending spam use mailto:[email protected]
Review
Quoted 4 lines · Keith Owens
exit.c:40: warning: passing arg 1 of `__builtin_expect' makes integer from pointer without a cast
(quoted diff) +1
-1- if (unlikely(proc_dentry)) { + if (unlikely(proc_dentry != NULL)) {
Have you checked to see if this produces the same code? To be on the safe side:
+ if (unlikely((ulong) proc_dentry)) {
Signature · 1 line
Daniel
Quoted 2 lines · Kasper Dupont
Wouldn't "!!(x)" make more sense here than "(x) != 0"? (I don't like comparing pointers with integers.)
No, == 0 means, that the pointer is invalid, so != 0 means, the pointer is valid. You can find this in the C99-Standard at least.
So, this is perfectly normal ;-)
Regards
Ingo Oeser
Signature · 1 line
Science is what we can tell a computer. Art is everything else. --- D.E.Knuth