public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org>
To: Roel Kluin <roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
Subject: Re: [PATCH] i2c: misplaced parentheses?
Date: Mon, 16 Feb 2009 10:24:19 +0100	[thread overview]
Message-ID: <20090216102419.18e41eb5@hyperion.delvare> (raw)
In-Reply-To: <49983FF4.1000102-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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 <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

      parent reply	other threads:[~2009-02-16  9:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090216102419.18e41eb5@hyperion.delvare \
    --to=khali-puyad+kwke1g9huczpvpmw@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=roel.kluin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox