From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jean Delvare Subject: Re: [PATCH] i2c: misplaced parentheses? Date: Mon, 16 Feb 2009 10:24:19 +0100 Message-ID: <20090216102419.18e41eb5@hyperion.delvare> References: <49983FF4.1000102@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <49983FF4.1000102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> Sender: linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Roel Kluin Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Andrew Morton List-Id: linux-i2c@vger.kernel.org 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 > --- > 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