Re: [PATCH] i2c: misplaced parentheses?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Roel,

On Sun, 15 Feb 2009 17:16:52 +0100, Roel Kluin wrote:
> 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.

> 
> please review.
> -------------------------->8------------------8<---------------------------
> Fix misplaced parentheses
> 
> Signed-off-by: Roel Kluin <roel.kluin@xxxxxxxxx>
> ---
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index b1c9abe..2d34a7a 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -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.

-- 
Jean Delvare
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux