mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86: properly parenthesize cmpxchg() macro arguments
@ 2012-01-26 15:47 Jan Beulich
  2012-01-26 21:37 ` [tip:x86/urgent] x86: Properly " tip-bot for Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Beulich @ 2012-01-26 15:47 UTC (permalink / raw)
  To: mingo, tglx, hpa; +Cc: linux-kernel

Quite oddly, all of the arguments passed through from the top level
macros to the second level which didn't need parentheses had them,
while the only expression (involving a parameter) needing them didn't.

Very recently I got bitten by the lack thereof when using something
like "array + index" for the first operand, with "array" being an
array more narrow than int.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

---
 arch/x86/include/asm/cmpxchg.h |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- 3.3-rc1/arch/x86/include/asm/cmpxchg.h
+++ 3.3-rc1-x86-cmpxchg-parenthesize/arch/x86/include/asm/cmpxchg.h
@@ -145,13 +145,13 @@ extern void __add_wrong_size(void)
 
 #ifdef __HAVE_ARCH_CMPXCHG
 #define cmpxchg(ptr, old, new)						\
-	__cmpxchg((ptr), (old), (new), sizeof(*ptr))
+	__cmpxchg(ptr, old, new, sizeof(*(ptr)))
 
 #define sync_cmpxchg(ptr, old, new)					\
-	__sync_cmpxchg((ptr), (old), (new), sizeof(*ptr))
+	__sync_cmpxchg(ptr, old, new, sizeof(*(ptr)))
 
 #define cmpxchg_local(ptr, old, new)					\
-	__cmpxchg_local((ptr), (old), (new), sizeof(*ptr))
+	__cmpxchg_local(ptr, old, new, sizeof(*(ptr)))
 #endif
 
 /*




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-01-26 21:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-26 15:47 [PATCH] x86: properly parenthesize cmpxchg() macro arguments Jan Beulich
2012-01-26 21:37 ` [tip:x86/urgent] x86: Properly " tip-bot for Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®