linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drivers/i2c/i2c-core.c: Fix sparse warning
@ 2015-04-03  2:53 Nickolaus Woodruff
  2015-04-03 18:28 ` Wolfram Sang
  0 siblings, 1 reply; 2+ messages in thread
From: Nickolaus Woodruff @ 2015-04-03  2:53 UTC (permalink / raw)
  To: wsa; +Cc: linux-i2c, linux-kernel

This patch fixes the following sparse warning in drivers/i2c/:

CHECK   drivers/i2c/i2c-core.c
drivers/i2c/i2c-core.c:2353:36: warning: dubious: x | !y

Signed-off-by: Nickolaus Woodruff <nickolauswoodruff@gmail.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 edf274c..f50d46e 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -2350,7 +2350,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) != 0);
 	pec = i2c_smbus_pec(pec, &addr, 1);

 	/* The data buffer follows */
--
1.9.1


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

* Re: [PATCH] drivers/i2c/i2c-core.c: Fix sparse warning
  2015-04-03  2:53 [PATCH] drivers/i2c/i2c-core.c: Fix sparse warning Nickolaus Woodruff
@ 2015-04-03 18:28 ` Wolfram Sang
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfram Sang @ 2015-04-03 18:28 UTC (permalink / raw)
  To: Nickolaus Woodruff; +Cc: linux-i2c, linux-kernel

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


> -	u8 addr = (msg->addr << 1) | !!(msg->flags & I2C_M_RD);
> +	u8 addr = (msg->addr << 1) | ((msg->flags & I2C_M_RD) != 0);

I prefer !! as an idiom for "bit to bool".

Thanks,

   Wolfram


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

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

end of thread, other threads:[~2015-04-03 18:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-03  2:53 [PATCH] drivers/i2c/i2c-core.c: Fix sparse warning Nickolaus Woodruff
2015-04-03 18: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).