qemu-trivial
[Top][All Lists]
Advanced

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

Re: [Qemu-trivial] [PATCH v3 for-2.2 0/8] don't use Yoda conditions


From: Eric Blake
Subject: Re: [Qemu-trivial] [PATCH v3 for-2.2 0/8] don't use Yoda conditions
Date: Tue, 05 Aug 2014 19:53:51 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0

On 08/05/2014 08:02 AM, Michael S. Tsirkin wrote:
> On Fri, Aug 01, 2014 at 03:46:08PM +0800, address@hidden wrote:
>> From: Gonglei <address@hidden>
>>
>> $WHATEVER: don't use 'Yoda conditions'
>>
>> 'Yoda conditions' are not part of idiomatic QEMU coding
>> style, so rewrite them in the more usual order.
> 
> 
> OK but why stop at these files? How about this
> instead?
> 

> @ disable commeq @
> expression E;
> constant C;
> @@
> - C == E
> + E == C
> @ disable commeq @
> expression E;
> constant C;
> @@
> - C == E
> + E == C

Why is this listed twice?

> @ disable gtr_lss @
> expression E;
> constant C;
> @@
> - C > E
> + E < C

This is wrong for floating point (think NaN); you'd have to audit the
results to make sure only integers are commuted.

> @ disable gtr_lss_eq @
> expression E;
> constant C;
> @@
> - C >= E
> + E <= C

Ditto.

> 
> Signed-off-by: Michael S. Tsirkin <address@hidden>

The idea seems okay to me, but I haven't closely reviewed the patch yet.

-- 
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]