All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: Blue Swirl <blauwirbel@gmail.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] Correct use of ! and &
Date: Fri, 27 Aug 2010 11:03:56 +0200	[thread overview]
Message-ID: <m3y6bspgub.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <20100826132313.GA32336@edde.se.axis.com> (Edgar E. Iglesias's message of "Thu, 26 Aug 2010 15:23:13 +0200")

"Edgar E. Iglesias" <edgar.iglesias@gmail.com> writes:

> On Sat, Aug 21, 2010 at 09:42:51AM +0000, Blue Swirl wrote:
>> Combining bitwise AND and logical NOT is suspicious.
>> 
>> Fixed by this Coccinelle script:
>> // From http://article.gmane.org/gmane.linux.kernel/646367
>> @@ expression E1,E2; @@
>> (
>>   !E1 & !E2
>> |
>> - !E1 & E2
>> + !(E1 & E2)
>> )
>> 
>> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
>> ---
>> 
>> Maybe the middle hunk should be fixed this way instead:
>> -            } else if ((rw == 1) & !matching->d) {
>> +            } else if ((rw == 1) && !matching->d) {
>> 
>> ---
>>  hw/etraxfs_eth.c    |    2 +-
>>  target-sh4/helper.c |    4 ++--
>>  2 files changed, 3 insertions(+), 3 deletions(-)
>> 
>> diff --git a/hw/etraxfs_eth.c b/hw/etraxfs_eth.c
>> index b897c9c..ade96f1 100644
>> --- a/hw/etraxfs_eth.c
>> +++ b/hw/etraxfs_eth.c
>> @@ -464,7 +464,7 @@ static int eth_match_groupaddr(struct fs_eth *eth,
>> const unsigned char *sa)
>> 
>>  	/* First bit on the wire of a MAC address signals multicast or
>>  	   physical address.  */
>> -	if (!m_individual && !sa[0] & 1)
>> +	if (!m_individual && !(sa[0] & 1))
>>  		return 0;
>
>
> Yep, the etrax part is a bug and your patch looks OK to me.
>
> Thanks
>
> Acked-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>

Such review is exactly what we need when static analysis spots fishy
code.  Thanks!

Volunteers to look at the other two hunks?

  parent reply	other threads:[~2010-08-27  9:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-21  9:42 [Qemu-devel] [PATCH] Correct use of ! and & Blue Swirl
2010-08-21 13:19 ` Markus Armbruster
2010-08-21 14:49   ` Blue Swirl
2010-08-26 13:23 ` Edgar E. Iglesias
2010-08-26 18:05   ` Blue Swirl
2010-08-27  9:03   ` Markus Armbruster [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-01-14 22:05 Blue Swirl

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=m3y6bspgub.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=edgar.iglesias@gmail.com \
    --cc=qemu-devel@nongnu.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.