Skip to contentSkip to conversation

drivers/i2c/i2c-core.c: Fix sparse warning

PATCH In review Nickolaus Woodruff 2 participants 2 messages Apr 3, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/i2c/i2c-core.c: Fix sparse warning

This patch fixes the following sparse warning in drivers/i2c/:

CHECK drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.c:2353:36: warning: dubious: x | !y

---
 drivers/i2c/i2c-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/i2c-core.c +1 -1
index edf274c..f50d46e 100644
@@ -2350,7 +2350,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
 static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
 {
 	/* The address will be sent first */
-	u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
+	u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) != 0);
 	pec = i2c_smbus_pec(pec, &addr, 1);
 
 	/* The data buffer follows */

--
1.9.1

#1 lore raw

drivers/i2c/i2c-core.c static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count) · line 2353

Quoted 3 lines
drivers/i2c/i2c-core.c +1 -1
-	u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
+	u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) != 0);

I prefer !! as an idiom for "bit to bool".

Thanks,

Wolfram