Skip to content

Commit ddb5a0d

Browse files
committed
bmp581: fix: Add parenthesis to macro arguments
Otherwise it leads to potential incorrect expansions. Signed-off-by: Luis Ubieda <luisf@croxel.com>
1 parent 95ef866 commit ddb5a0d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/sensor/bosch/bmp581/bmp581.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
#define BMP5_SET_HIGH_BYTE 0xFF00u
3030

3131
/* BIT SLICE GET AND SET FUNCTIONS */
32-
#define BMP5_GET_BITSLICE(regvar, bitname) ((regvar & bitname##_MSK) >> bitname##_POS)
32+
#define BMP5_GET_BITSLICE(regvar, bitname) (((regvar) & (bitname##_MSK)) >> (bitname##_POS))
3333

3434
#define BMP5_SET_BITSLICE(regvar, bitname, val) \
35-
((regvar & ~bitname##_MSK) | ((val << bitname##_POS) & bitname##_MSK))
35+
(((regvar) & ~(bitname##_MSK)) | (((val) << (bitname##_POS)) & (bitname##_MSK)))
3636

3737
#define BMP5_GET_LSB(var) (uint8_t)(var & BMP5_SET_LOW_BYTE)
3838
#define BMP5_GET_MSB(var) (uint8_t)((var & BMP5_SET_HIGH_BYTE) >> 8)

0 commit comments

Comments
 (0)