linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/1] i2c: core: fix a code to suppress a warning
@ 2015-09-18 11:06 Andy Shevchenko
       [not found] ` <1442574399-26131-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2015-10-22 11:48 ` Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2015-09-18 11:06 UTC (permalink / raw)
  To: linux-i2c-u79uwXL29TY76Z2rM5mHXA, Wolfram Sang,
	Alexander Sverdlin, Vladimir Zapolskiy
  Cc: Andy Shevchenko

There is a warning when compiling i2c-core.c
drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y

Fix it by using a plain bitwise AND since I2C_M_RD is a bit 0 and thus we are
on the safe side.

Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
---
 drivers/i2c/i2c-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 5f89f1e..a732107 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -2555,7 +2555,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
 static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
 {
 	/* The address will be sent first */
-	u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
+	u8 addr = (msg->addr << 1) | (msg->flags & I2C_M_RD);
 	pec = i2c_smbus_pec(pec, &addr, 1);
 
 	/* The data buffer follows */
-- 
2.5.1

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

* Re: [PATCH v2 1/1] i2c: core: fix a code to suppress a warning
       [not found] ` <1442574399-26131-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-09-18 11:10   ` Alexander Sverdlin
  0 siblings, 0 replies; 4+ messages in thread
From: Alexander Sverdlin @ 2015-09-18 11:10 UTC (permalink / raw)
  To: EXT Andy Shevchenko, linux-i2c-u79uwXL29TY76Z2rM5mHXA,
	Wolfram Sang, Vladimir Zapolskiy

On 18/09/15 13:06, EXT Andy Shevchenko wrote:
> There is a warning when compiling i2c-core.c
> drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
> 
> Fix it by using a plain bitwise AND since I2C_M_RD is a bit 0 and thus we are
> on the safe side.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Reviewed-by: Alexander Sverdlin <aleaxander.sverdlin-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>

> ---
>  drivers/i2c/i2c-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 5f89f1e..a732107 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -2555,7 +2555,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t count)
>  static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
>  {
>  	/* The address will be sent first */
> -	u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
> +	u8 addr = (msg->addr << 1) | (msg->flags & I2C_M_RD);
>  	pec = i2c_smbus_pec(pec, &addr, 1);
>  
>  	/* The data buffer follows */

-- 
Best regards,
Alexander Sverdlin.

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

* Re: [PATCH v2 1/1] i2c: core: fix a code to suppress a warning
  2015-09-18 11:06 [PATCH v2 1/1] i2c: core: fix a code to suppress a warning Andy Shevchenko
       [not found] ` <1442574399-26131-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2015-10-22 11:48 ` Andy Shevchenko
  2015-12-01  0:28   ` Wolfram Sang
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2015-10-22 11:48 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang, Alexander Sverdlin, Vladimir Zapolskiy

On Fri, 2015-09-18 at 14:06 +0300, Andy Shevchenko wrote:
> There is a warning when compiling i2c-core.c
> drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
> 
> Fix it by using a plain bitwise AND since I2C_M_RD is a bit 0 and
> thus we are
> on the safe side.

Wolfram, as of today I didn't see this in linux-next. Should I amend
this one somehow?

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/i2c/i2c-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 5f89f1e..a732107 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -2555,7 +2555,7 @@ static u8 i2c_smbus_pec(u8 crc, u8 *p, size_t
> count)
>  static u8 i2c_smbus_msg_pec(u8 pec, struct i2c_msg *msg)
>  {
>  	/* The address will be sent first */
> -	u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
> +	u8 addr = (msg->addr << 1) | (msg->flags & I2C_M_RD);
>  	pec = i2c_smbus_pec(pec, &addr, 1);
>  
>  	/* The data buffer follows */

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

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

* Re: [PATCH v2 1/1] i2c: core: fix a code to suppress a warning
  2015-10-22 11:48 ` Andy Shevchenko
@ 2015-12-01  0:28   ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2015-12-01  0:28 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-i2c, Alexander Sverdlin, Vladimir Zapolskiy

[-- Attachment #1: Type: text/plain, Size: 664 bytes --]

On Thu, Oct 22, 2015 at 02:48:03PM +0300, Andy Shevchenko wrote:
> On Fri, 2015-09-18 at 14:06 +0300, Andy Shevchenko wrote:
> > There is a warning when compiling i2c-core.c
> > drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
> > 
> > Fix it by using a plain bitwise AND since I2C_M_RD is a bit 0 and
> > thus we are
> > on the safe side.
> 
> Wolfram, as of today I didn't see this in linux-next. Should I amend
> this one somehow?

I am working on my own series, introducing a macro for this operation
which can be used in drivers, too. Just need to fiddle a little more
with my coccinelle scripts. Stay tuned!

Thanks,

   Wolfram


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

end of thread, other threads:[~2015-12-01  0:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-18 11:06 [PATCH v2 1/1] i2c: core: fix a code to suppress a warning Andy Shevchenko
     [not found] ` <1442574399-26131-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-09-18 11:10   ` Alexander Sverdlin
2015-10-22 11:48 ` Andy Shevchenko
2015-12-01  0:28   ` Wolfram Sang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).