Skip to contentSkip to conversation

sparc: make xchg() into a statement expression

PATCH New Randy Dunlap 1 participant 1 message Oct 20, 2020 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sparc: make xchg() into a statement expression

Fix several of the same warning by using a GCC statement expression (extension):

../arch/sparc/include/asm/cmpxchg_32.h:28:22: warning: value computed is not used [-Wunused-value]
28 | #define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))

Passes sparc32 allmodconfig with no xchg warnings.

Cc Arnd Bergmann <[email protected]>
Cc "David S. Miller" <[email protected]>

---
This is similar to a patch from Arnd for m68k:
https://lore.kernel.org/linux-m68k/[email protected]/

 arch/sparc/include/asm/cmpxchg_32.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/include/asm/cmpxchg_32.h +1 -1
@@ -25,7 +25,7 @@ static inline unsigned long __xchg(unsig
 	return x;
 }
 
-#define xchg(ptr,x) ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
+#define xchg(ptr,x) ({(__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)));})
 
 /* Emulate cmpxchg() the same way we emulate atomics,
  * by hashing the object address and indexing into an array