linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/1] i2c: core: replace boolean variable by integer
@ 2015-11-19 16:11 Andy Shevchenko
  2016-01-25  8:55 ` Andy Shevchenko
  2016-01-26  8:56 ` Uwe Kleine-König
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2015-11-19 16:11 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang, Alexander Sverdlin; +Cc: Andy Shevchenko

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

Replace boolean exdpression by 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@linux.intel.com>
Reviewed-by: Alexander Sverdlin <aleaxander.sverdlin@nokia.com>
---
Changelog v3:
- add tag
- rephrase commit message
 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 040af5c..873ca1c 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -2591,7 +2591,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.6.2

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

* Re: [PATCH v3 1/1] i2c: core: replace boolean variable by integer
  2015-11-19 16:11 [PATCH v3 1/1] i2c: core: replace boolean variable by integer Andy Shevchenko
@ 2016-01-25  8:55 ` Andy Shevchenko
  2016-01-26  6:04   ` Wolfram Sang
  2016-01-26  8:56 ` Uwe Kleine-König
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2016-01-25  8:55 UTC (permalink / raw)
  To: linux-i2c, Wolfram Sang, Alexander Sverdlin

On Thu, 2015-11-19 at 18:11 +0200, Andy Shevchenko wrote:
> There is a warning when compiling i2c-core.c
> drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
> 
> Replace boolean exdpression by a plain bitwise AND since I2C_M_RD is
> a bit 0
> and thus we are on the safe side.

Wolfram, any news about this change? Last time I remember you talked
about your series which makes this change obsolete.

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Alexander Sverdlin <aleaxander.sverdlin@nokia.com>
> ---
> Changelog v3:
> - add tag
> - rephrase commit message
>  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 040af5c..873ca1c 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -2591,7 +2591,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 v3 1/1] i2c: core: replace boolean variable by integer
  2016-01-25  8:55 ` Andy Shevchenko
@ 2016-01-26  6:04   ` Wolfram Sang
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2016-01-26  6:04 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-i2c, Alexander Sverdlin

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

On Mon, Jan 25, 2016 at 10:55:44AM +0200, Andy Shevchenko wrote:
> On Thu, 2015-11-19 at 18:11 +0200, Andy Shevchenko wrote:
> > There is a warning when compiling i2c-core.c
> > drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
> > 
> > Replace boolean exdpression by a plain bitwise AND since I2C_M_RD is
> > a bit 0
> > and thus we are on the safe side.
> 
> Wolfram, any news about this change? Last time I remember you talked
> about your series which makes this change obsolete.

-EBUSY :/

I hope to tackle it on the train to FOSDEM later this week...


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

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

* Re: [PATCH v3 1/1] i2c: core: replace boolean variable by integer
  2015-11-19 16:11 [PATCH v3 1/1] i2c: core: replace boolean variable by integer Andy Shevchenko
  2016-01-25  8:55 ` Andy Shevchenko
@ 2016-01-26  8:56 ` Uwe Kleine-König
  1 sibling, 0 replies; 4+ messages in thread
From: Uwe Kleine-König @ 2016-01-26  8:56 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-i2c, Wolfram Sang, Alexander Sverdlin

Hello,

On Thu, Nov 19, 2015 at 06:11:56PM +0200, Andy Shevchenko wrote:
> There is a warning when compiling i2c-core.c
> drivers/i2c/i2c-core.c:2561:36: warning: dubious: x | !y
> 
> Replace boolean exdpression by a plain bitwise AND since I2C_M_RD is a bit 0

s/exdpression/expression/

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2016-01-26  8:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-19 16:11 [PATCH v3 1/1] i2c: core: replace boolean variable by integer Andy Shevchenko
2016-01-25  8:55 ` Andy Shevchenko
2016-01-26  6:04   ` Wolfram Sang
2016-01-26  8:56 ` Uwe Kleine-König

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).