qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions


From: Eric Blake
Subject: Re: [Qemu-devel] [Bug 1464611] [NEW] 4 * redundant conditions
Date: Fri, 12 Jun 2015 07:03:13 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

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: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]