x86: cast cmpxchg and cmpxchg_local result for 386 and 486
authorMathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Thu, 6 Mar 2008 12:45:46 +0000 (13:45 +0100)
committerIngo Molnar <mingo@elte.hu>
Fri, 21 Mar 2008 16:06:15 +0000 (17:06 +0100)
mm/slub.c: In function 'slab_alloc':
mm/slub.c:1637: warning: assignment makes pointer from integer without a cast
mm/slub.c:1637: warning: assignment makes pointer from integer without a cast
mm/slub.c: In function 'slab_free':
mm/slub.c:1796: warning: assignment makes pointer from integer without a cast
mm/slub.c:1796: warning: assignment makes pointer from integer without a cast

A cast is needed in the 386 and 486 code because the type is a pointer.  In
every other integer case the original cmpxchg code (and the cmpxchg_local
which has been copied from it) worked fine, but since we touch a pointer,
the type needs to be casted in the cmpxchg_local and cmpxchg macros.

The more recent code (586+) does not have this problem (the cast is already
there).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Christoph Lameter <clameter@sgi.com>
Cc: Vegard Nossum <vegard.nossum@gmail.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
include/asm-x86/cmpxchg_32.h

index cea1dae288a74b72e567d45ef963f3d5a271eb78..959fad00dff5968c47db0d58386f91c0a430972b 100644 (file)
@@ -269,22 +269,26 @@ static inline unsigned long cmpxchg_386(volatile void *ptr, unsigned long old,
 ({                                                                     \
        __typeof__(*(ptr)) __ret;                                       \
        if (likely(boot_cpu_data.x86 > 3))                              \
-               __ret = __cmpxchg((ptr), (unsigned long)(o),            \
-                                       (unsigned long)(n), sizeof(*(ptr))); \
+               __ret = (__typeof__(*(ptr)))__cmpxchg((ptr),            \
+                               (unsigned long)(o), (unsigned long)(n), \
+                               sizeof(*(ptr)));                        \
        else                                                            \
-               __ret = cmpxchg_386((ptr), (unsigned long)(o),          \
-                                       (unsigned long)(n), sizeof(*(ptr))); \
+               __ret = (__typeof__(*(ptr)))cmpxchg_386((ptr),          \
+                               (unsigned long)(o), (unsigned long)(n), \
+                               sizeof(*(ptr)));                        \
        __ret;                                                          \
 })
 #define cmpxchg_local(ptr, o, n)                                       \
 ({                                                                     \
        __typeof__(*(ptr)) __ret;                                       \
        if (likely(boot_cpu_data.x86 > 3))                              \
-               __ret = __cmpxchg_local((ptr), (unsigned long)(o),      \
-                                       (unsigned long)(n), sizeof(*(ptr))); \
+               __ret = (__typeof__(*(ptr)))__cmpxchg_local((ptr),      \
+                               (unsigned long)(o), (unsigned long)(n), \
+                               sizeof(*(ptr)));                        \
        else                                                            \
-               __ret = cmpxchg_386((ptr), (unsigned long)(o),          \
-                                       (unsigned long)(n), sizeof(*(ptr))); \
+               __ret = (__typeof__(*(ptr)))cmpxchg_386((ptr),          \
+                               (unsigned long)(o), (unsigned long)(n), \
+                               sizeof(*(ptr)));                        \
        __ret;                                                          \
 })
 #endif
@@ -301,10 +305,12 @@ extern unsigned long long cmpxchg_486_u64(volatile void *, u64, u64);
 ({                                                                     \
        __typeof__(*(ptr)) __ret;                                       \
        if (likely(boot_cpu_data.x86 > 4))                              \
-               __ret = __cmpxchg64((ptr), (unsigned long long)(o),     \
+               __ret = (__typeof__(*(ptr)))__cmpxchg64((ptr),          \
+                               (unsigned long long)(o),                \
                                (unsigned long long)(n));               \
        else                                                            \
-               __ret = cmpxchg_486_u64((ptr), (unsigned long long)(o), \
+               __ret = (__typeof__(*(ptr)))cmpxchg_486_u64((ptr),      \
+                               (unsigned long long)(o),                \
                                (unsigned long long)(n));               \
        __ret;                                                          \
 })
@@ -312,10 +318,12 @@ extern unsigned long long cmpxchg_486_u64(volatile void *, u64, u64);
 ({                                                                     \
        __typeof__(*(ptr)) __ret;                                       \
        if (likely(boot_cpu_data.x86 > 4))                              \
-               __ret = __cmpxchg64_local((ptr), (unsigned long long)(o), \
+               __ret = (__typeof__(*(ptr)))__cmpxchg64_local((ptr),    \
+                               (unsigned long long)(o),                \
                                (unsigned long long)(n));               \
        else                                                            \
-               __ret = cmpxchg_486_u64((ptr), (unsigned long long)(o), \
+               __ret = (__typeof__(*(ptr)))cmpxchg_486_u64((ptr),      \
+                               (unsigned long long)(o),                \
                                (unsigned long long)(n));               \
        __ret;                                                          \
 })