From 648ad2e72099189cd3086f093b62d40f9239a747 Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Thu, 12 Jun 2014 13:33:01 +0000 Subject: [PATCH] - Fix out of range shifting bug in bitops.h. - Make code a bit easier to read by adding parenthesis. MFC after: 3 days Sponsored by: Mellanox Technologies --- sys/ofed/include/linux/bitops.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/ofed/include/linux/bitops.h b/sys/ofed/include/linux/bitops.h index bac688af5e7..04bd5e6607e 100644 --- a/sys/ofed/include/linux/bitops.h +++ b/sys/ofed/include/linux/bitops.h @@ -286,14 +286,14 @@ bitmap_empty(unsigned long *addr, int size) #define NBLONG (NBBY * sizeof(long)) #define set_bit(i, a) \ - atomic_set_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << (i) % NBLONG) + atomic_set_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG)) #define clear_bit(i, a) \ - atomic_clear_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << (i) % NBLONG) + atomic_clear_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG)) #define test_bit(i, a) \ !!(atomic_load_acq_long(&((volatile long *)(a))[(i)/NBLONG]) & \ - 1UL << ((i) % NBLONG)) + (1UL << ((i) % NBLONG))) static inline long test_and_clear_bit(long bit, long *var) @@ -302,7 +302,7 @@ test_and_clear_bit(long bit, long *var) var += bit / (sizeof(long) * NBBY); bit %= sizeof(long) * NBBY; - bit = 1 << bit; + bit = (1UL << bit); do { val = *(volatile long *)var; } while (atomic_cmpset_long(var, val, val & ~bit) == 0); @@ -317,7 +317,7 @@ test_and_set_bit(long bit, long *var) var += bit / (sizeof(long) * NBBY); bit %= sizeof(long) * NBBY; - bit = 1 << bit; + bit = (1UL << bit); do { val = *(volatile long *)var; } while (atomic_cmpset_long(var, val, val | bit) == 0);