Re: [PATCH] bit_spinlock: Fix the __bitlock() definition

From: Marco Elver

Date: Mon May 04 2026 - 02:00:59 EST


On Sat, 2 May 2026 at 03:55, Bart Van Assche <bvanassche@xxxxxxx> wrote:
>
> 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")
> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>

Reviewed-by: Marco Elver <elver@xxxxxxxxxx>


> ---
> include/linux/bit_spinlock.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/bit_spinlock.h b/include/linux/bit_spinlock.h
> index 7869a6e59b6a..bcae36b9a739 100644
> --- a/include/linux/bit_spinlock.h
> +++ b/include/linux/bit_spinlock.h
> @@ -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()