[linux-yocto] [PATCH 10/15] arch/arm: Backport a Change to Fix Compiler Warnings

Daniel Dragomir daniel.dragomir at windriver.com
Fri Jan 8 07:51:41 PST 2016


From: John Jacques <john.jacques at intel.com>

A recent change in kernel/acct.c added a new warning for many
configurations on ARM:

kernel/acct.c: In function 'acct_pin_kill':
arch/arm/include/asm/cmpxchg.h:122:3:
          warning: value computed is not used [-Wunu\sed-value]
  ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\

The code is in fact correct, it's just a cmpxchg() call that intentionally
ignores the result, and no other code does that. The warning does not
show up on x86 because of the way that its cmpxchg() macro is written.

This changes the ARM implementation to use a similar construct with a
compound expression instead of a typecast, which causes the compiler to
not complain about an unused result.

Signed-off-by: Arnd Bergmann <arnd at arndb.de>
Signed-off-by: John Jacques <john.jacques at intel.com>
---
 arch/arm/include/asm/cmpxchg.h | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
index abb2c37..5ceaa53 100644
--- a/arch/arm/include/asm/cmpxchg.h
+++ b/arch/arm/include/asm/cmpxchg.h
@@ -118,9 +118,11 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
  * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
  * them available.
  */
-#define cmpxchg_local(ptr, o, n)				  	       \
-	((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), (unsigned long)(o),\
-			(unsigned long)(n), sizeof(*(ptr))))
+#define cmpxchg_local(ptr, o, n)				\
+	({(__typeof__(*(ptr)))__cmpxchg_local_generic((ptr),	\
+			(unsigned long)(o),			\
+			(unsigned long)(n),			\
+			sizeof(*(ptr))); })
 #define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
 
 #ifndef CONFIG_SMP
@@ -201,11 +203,11 @@ static inline unsigned long __cmpxchg_mb(volatile void *ptr, unsigned long old,
 	return ret;
 }
 
-#define cmpxchg(ptr,o,n)						\
-	((__typeof__(*(ptr)))__cmpxchg_mb((ptr),			\
-					  (unsigned long)(o),		\
-					  (unsigned long)(n),		\
-					  sizeof(*(ptr))))
+#define cmpxchg(ptr, o, n)					\
+	({(__typeof__(*(ptr)))__cmpxchg_mb((ptr),		\
+					(unsigned long)(o),	\
+					(unsigned long)(n),	\
+					sizeof(*(ptr))); })
 
 static inline unsigned long __cmpxchg_local(volatile void *ptr,
 					    unsigned long old,
-- 
1.9.1



More information about the linux-yocto mailing list