public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: misplaced parentheses?
@ 2009-02-15 16:16 Roel Kluin
       [not found] ` <49983FF4.1000102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-02-15 16:16 UTC (permalink / raw)
  To: Jean Delvare; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Andrew Morton

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

Signed-off-by: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
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:

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i2c: misplaced parentheses?
       [not found] ` <49983FF4.1000102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2009-02-16  9:24   ` Jean Delvare
  0 siblings, 0 replies; 2+ messages in thread
From: Jean Delvare @ 2009-02-16  9:24 UTC (permalink / raw)
  To: Roel Kluin; +Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Andrew Morton

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-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-16  9:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-15 16:16 [PATCH] i2c: misplaced parentheses? Roel Kluin
     [not found] ` <49983FF4.1000102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2009-02-16  9:24   ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox