i2c: misplaced parentheses?
Subsystems (2)
PATCH 1/1 i2c: misplaced parentheses?
I think below is what was intended? otherwise we could as well have written:
msg[0].flags = flags || (read_write == I2C_SMBUS_READ) ? I2C_M_RD : 0;
please review. -------------------------->8------------------8<--------------------------- Fix misplaced parentheses
---
drivers/i2c/i2c-core.c +2 -1
@@ -1831,7 +1831,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,case I2C_SMBUS_QUICK : msg[0 ].len =0 ;/* Special case: The read/write field is used as data */ - msg[0 ].flags = flags | (read_write==I2C_SMBUS_READ )?I2C_M_RD :0 ; + msg[0 ].flags = flags | (read_write ==I2C_SMBUS_READ ? +I2C_M_RD :0 ); num =1 ;break ;case I2C_SMBUS_BYTE :
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Roel,
Quoted 3 lines · Roel Kluin
I think below is what was intended? otherwise we could as well have written:
msg[0].flags = flags || (
read_write==I2C_SMBUS_READ) ?I2C_M_RD: 0;
Which would clearly be wrong, as flags is a bit field.
Quoted 12 lines
please review. -------------------------->8------------------8<--------------------------- Fix misplaced parentheses
Signed-off-by Roel Kluin <[email protected]>---
drivers/i2c/i2c-core.c +0
-0
drivers/i2c/i2c-core.c static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr, · line 1838
Quoted 9 lines
drivers/i2c/i2c-core.c +2
-1@@ -1831,7 +1831,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter * adapter, u16 addr,case I2C_SMBUS_QUICK : msg[0 ].len =0 ;/* Special case: The read/write field is used as data */ - msg[0 ].flags = flags | (read_write==I2C_SMBUS_READ )?I2C_M_RD :0 ; + msg[0 ].flags = flags | (read_write ==I2C_SMBUS_READ ? +I2C_M_RD :0 ); num =1 ;break ;case I2C_SMBUS_BYTE :
You are perfectly right. We are probably just lucky that in most cases flags is 0 so both expressions are equivalent. Otherwise we'd have noticed the bug earlier I guess.
Patch applied, thanks.
Signature · 1 line
Jean Delvare