All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sparc: make xchg() into a statement expression
@ 2020-10-20  5:33 Randy Dunlap
  0 siblings, 0 replies; only message in thread
From: Randy Dunlap @ 2020-10-20  5:33 UTC (permalink / raw)
  To: sparclinux

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.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparclinux@vger.kernel.org
---
This is similar to a patch from Arnd for m68k:
  https://lore.kernel.org/linux-m68k/20201008123429.1133896-1-arnd@arndb.de/

 arch/sparc/include/asm/cmpxchg_32.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-next-20201009.orig/arch/sparc/include/asm/cmpxchg_32.h
+++ linux-next-20201009/arch/sparc/include/asm/cmpxchg_32.h
@@ -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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-10-20  5:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-20  5:33 [PATCH] sparc: make xchg() into a statement expression Randy Dunlap

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.