s390/cmpxchg: fix compile warnings specific to s390
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Tue, 29 May 2012 06:28:38 +0000 (08:28 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 30 May 2012 07:07:56 +0000 (09:07 +0200)
The cmpxchg macros and functions are a bit different than on other
architectures. In particular the macros do not store the return
value of a __cmpxchg function call in a variable before returning the
value.

This causes compile warnings that only occur on s390 like this one:

net/ipv4/af_inet.c: In function 'build_ehash_secret':
net/ipv4/af_inet.c:241:2: warning: value computed is not used [-Wunused-value]

To get rid of these warnings use the same construct that we already use
for the xchg macro, which was introduced for the same reason.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/include/asm/cmpxchg.h

index ebd31481f1d2abbeb7aa932d7e930adfb553b93a..13c8b2eb6983f6626c7ebd63fa9de7e18bf532ad 100644 (file)
@@ -160,9 +160,14 @@ static inline unsigned long __cmpxchg(void *ptr, unsigned long old,
        return old;
 }
 
-#define cmpxchg(ptr, o, n)                                             \
-       ((__typeof__(*(ptr)))__cmpxchg((ptr), (unsigned long)(o),       \
-                                      (unsigned long)(n), sizeof(*(ptr))))
+#define cmpxchg(ptr, o, n)                                              \
+({                                                                      \
+       __typeof__(*(ptr)) __ret;                                        \
+       __ret = (__typeof__(*(ptr)))                                     \
+               __cmpxchg((ptr), (unsigned long)(o), (unsigned long)(n), \
+                         sizeof(*(ptr)));                               \
+       __ret;                                                           \
+})
 
 #ifdef CONFIG_64BIT
 #define cmpxchg64(ptr, o, n)                                           \
@@ -184,10 +189,16 @@ static inline unsigned long long __cmpxchg64(void *ptr,
                : "memory", "cc");
        return rp_old.pair;
 }
-#define cmpxchg64(ptr, o, n)                                           \
-       ((__typeof__(*(ptr)))__cmpxchg64((ptr),                         \
-                                        (unsigned long long)(o),       \
-                                        (unsigned long long)(n)))
+
+#define cmpxchg64(ptr, o, n)                           \
+({                                                     \
+       __typeof__(*(ptr)) __ret;                       \
+       __ret = (__typeof__(*(ptr)))                    \
+               __cmpxchg64((ptr),                      \
+                           (unsigned long long)(o),    \
+                           (unsigned long long)(n));   \
+       __ret;                                          \
+})
 #endif /* CONFIG_64BIT */
 
 #include <asm-generic/cmpxchg-local.h>
@@ -216,8 +227,13 @@ static inline unsigned long __cmpxchg_local(void *ptr,
  * them available.
  */
 #define cmpxchg_local(ptr, o, n)                                       \
-       ((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
-                       (unsigned long)(n), sizeof(*(ptr))))
+({                                                                     \
+       __typeof__(*(ptr)) __ret;                                       \
+       __ret = (__typeof__(*(ptr)))                                    \
+               __cmpxchg_local((ptr), (unsigned long)(o),              \
+                               (unsigned long)(n), sizeof(*(ptr)));    \
+       __ret;                                                          \
+})
 
 #define cmpxchg64_local(ptr, o, n)     cmpxchg64((ptr), (o), (n))