From: Vladimir Zapolskiy <vladimir_zapolskiy-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
To: Andy Shevchenko
<andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
mika.westerberg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Subject: Re: [PATCH 1/1] i2c: core: fix a code to suppress a warning
Date: Tue, 15 Sep 2015 15:47:11 +0300 [thread overview]
Message-ID: <55F8134F.5080401@mentor.com> (raw)
In-Reply-To: <1442318818.8361.29.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
On 15.09.2015 15:06, Andy Shevchenko wrote:
> On Tue, 2015-09-15 at 14:25 +0300, Vladimir Zapolskiy wrote:
>> Hello Andy,
>>
>> On 15.09.2015 13:11, 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 ternary operator.
>>>
>>> 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 3a4c54e..d13a8a0 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) ? 1
>>> : 0);
>>> pec = i2c_smbus_pec(pec, &addr, 1);
>>>
>>> /* The data buffer follows */
>>>
>>
>> I2C_M_RD is defined as 1, probably (msg->flags & I2C_M_RD) is good
>> enough here.
>
> Today is 1, tomorrow is 0x80, so, I would stay as I put in the initial
> fix.
I believe I2C_M_RD will never get any other value than 1, since this
value is deliberately set to 1 and it is in active use by userspace
applications for years, nobody intends to break ABI tomorrow.
--
With best wishes,
Vladimir
next prev parent reply other threads:[~2015-09-15 12:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-15 10:11 [PATCH 1/1] i2c: core: fix a code to suppress a warning Andy Shevchenko
[not found] ` <1442311867-60185-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-09-15 11:23 ` Alexander Sverdlin
2015-09-15 11:25 ` Vladimir Zapolskiy
[not found] ` <55F80047.4000805-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-09-15 12:06 ` Andy Shevchenko
[not found] ` <1442318818.8361.29.camel-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2015-09-15 12:47 ` Vladimir Zapolskiy [this message]
[not found] ` <55F8134F.5080401-nmGgyN9QBj3QT0dZR+AlfA@public.gmane.org>
2015-09-15 13:00 ` Wolfram Sang
2015-09-15 13:34 ` Andy Shevchenko
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=55F8134F.5080401@mentor.com \
--to=vladimir_zapolskiy-nmggyn9qbj3qt0dzr+alfa@public.gmane.org \
--cc=andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mika.westerberg-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=wsa-z923LK4zBo2bacvFa/9K2g@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.