diff options
author | Will Deacon <will.deacon@arm.com> | 2014-04-30 11:23:06 -0400 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2014-05-09 12:00:00 -0400 |
commit | e1dfda9ced9bea1413a736f0d578f8218a7788ec (patch) | |
tree | f78c6b760a585d8efacaff2249105f73ed60d90a /arch | |
parent | 206a2a73a62d37c8b8f6ddd3180c202b2e7298ab (diff) |
arm64: xchg: prevent warning if return value is unused
Some users of xchg() don't bother using the return value, which results
in a compiler warning like the following (from kgdb):
In file included from linux/arch/arm64/include/asm/atomic.h:27:0,
from include/linux/atomic.h:4,
from include/linux/spinlock.h:402,
from include/linux/seqlock.h:35,
from include/linux/time.h:5,
from include/uapi/linux/timex.h:56,
from include/linux/timex.h:56,
from include/linux/sched.h:19,
from include/linux/pid_namespace.h:4,
from kernel/debug/debug_core.c:30:
kernel/debug/debug_core.c: In function ‘kgdb_cpu_enter’:
linux/arch/arm64/include/asm/cmpxchg.h:75:3: warning: value computed is not used [-Wunused-value]
((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
^
linux/arch/arm64/include/asm/atomic.h:132:30: note: in expansion of macro ‘xchg’
#define atomic_xchg(v, new) (xchg(&((v)->counter), new))
kernel/debug/debug_core.c:504:4: note: in expansion of macro ‘atomic_xchg’
atomic_xchg(&kgdb_active, cpu);
^
This patch makes use of the same trick as we do for cmpxchg, by assigning
the return value to a dummy variable in the xchg() macro itself.
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm64/include/asm/cmpxchg.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/arch/arm64/include/asm/cmpxchg.h b/arch/arm64/include/asm/cmpxchg.h index 57c0fa7bf711..ddb9d7830558 100644 --- a/arch/arm64/include/asm/cmpxchg.h +++ b/arch/arm64/include/asm/cmpxchg.h | |||
@@ -72,7 +72,12 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size | |||
72 | } | 72 | } |
73 | 73 | ||
74 | #define xchg(ptr,x) \ | 74 | #define xchg(ptr,x) \ |
75 | ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr)))) | 75 | ({ \ |
76 | __typeof__(*(ptr)) __ret; \ | ||
77 | __ret = (__typeof__(*(ptr))) \ | ||
78 | __xchg((unsigned long)(x), (ptr), sizeof(*(ptr))); \ | ||
79 | __ret; \ | ||
80 | }) | ||
76 | 81 | ||
77 | static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, | 82 | static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, |
78 | unsigned long new, int size) | 83 | unsigned long new, int size) |