Skip to contentSkip to conversation

bit_spinlock: Fix the __bitlock() definition

PATCH In review Bart Van Assche 2 participants 2 messages May 2 – May 4

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bit_spinlock: Fix the __bitlock() definition

Surround the bitnum argument with parentheses because it could be an expression that includes an operator with a lower priority than the addition operator, e.g. the exclusive or operator.

Fixes eb7d96a13bf4 ("bit_spinlock: Support Clang's context analysis")
---
 include/linux/bit_spinlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bit_spinlock.h +1 -1
index 7869a6e59b6a..bcae36b9a739 100644
@@ -17,7 +17,7 @@
  * static analysis can use.
  */
 context_lock_struct(__context_bitlock) { };
-#define __bitlock(bitnum, addr) (struct __context_bitlock *)(bitnum + (addr))
+#define __bitlock(bitnum, addr) (struct __context_bitlock *)((bitnum) + (addr))
 
 /*
  *  bit-based spin_lock()
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Bart Van Assche

Surround the bitnum argument with parentheses because it could be an expression that includes an operator with a lower priority than the addition operator, e.g. the exclusive or operator.

Fixes eb7d96a13bf4 ("bit_spinlock: Support Clang's context analysis")
Quoted 17 lines
---
 include/linux/bit_spinlock.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/bit_spinlock.h +1 -1
index 7869a6e59b6a..bcae36b9a739 100644
@@ -17,7 +17,7 @@
  * static analysis can use.
  */
 context_lock_struct(__context_bitlock) { };
-#define __bitlock(bitnum, addr) (struct __context_bitlock *)(bitnum + (addr))
+#define __bitlock(bitnum, addr) (struct __context_bitlock *)((bitnum) + (addr))
 
 /*
  *  bit-based spin_lock()