All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>,
	Bug 1464611 <1464611@bugs.launchpad.net>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions
Date: Fri, 12 Jun 2015 07:03:13 -0600	[thread overview]
Message-ID: <557AD891.90904@redhat.com> (raw)
In-Reply-To: <CAFEAcA-P6upSykggf73surT6VvVfhdVZvBrzHvSEpv8nV3W2hQ@mail.gmail.com>

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

On 06/12/2015 05:01 AM, Peter Maydell wrote:

>> 4.
>>
>> [qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition:
>> size<3. 'A && (!A || B)' is equivalent to 'A || B'
>>
>>       if (size > 3
>>             || (size < 3 && is_q)
>>             || (size == 3 && !is_q)) {
> 
> ...but I'm less sure about this one. I'm not even sure
> what it's trying to suggest this should simplify to:
> just dropping "size < 3" is obviously wrong, and the
> condition format isn't "A && (!A || B)" either.

Let's break it down into the 6 possibilities based on the binary *
ternary conditions being checked:

> 3, is_q   => accept
> 3, !is_q  => accept
== 3, is_q  => reject
== 3, !is_q => accept
< 3, is_q   => accept
< 3, !is_q  => reject

Here's a shorter conditional with the same properties, but it's gross:

if (size > 3 || (is_q != (size == 3))) {

Too much mental thought to prove it accepts the same set of conditions.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-06-12 13:03 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 10:38 [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions dcb
2015-06-12 11:01 ` Peter Maydell
2015-06-12 13:03   ` Eric Blake [this message]
2015-06-12 13:11     ` Peter Maydell
2015-06-12 15:30 ` [Qemu-devel] [Bug 1464611] " dcb
2016-10-31 16:35 ` Thomas Huth
2017-01-11  6:44 ` Thomas Huth

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=557AD891.90904@redhat.com \
    --to=eblake@redhat.com \
    --cc=1464611@bugs.launchpad.net \
    --cc=peter.maydell@linaro.org \
    --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.