From: Eric Blake <eblake@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, arei.gonglei@huawei.com
Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com,
weidong.huang@huawei.com, stefanha@redhat.com,
marcel.a@redhat.com, qemu-trivial@nongnu.org,
luonengjun@huawei.com, qemu-devel@nongnu.org, armbru@redhat.com,
av1474@comtv.ru, kraxel@redhat.com, aliguori@amazon.com,
imammedo@redhat.com, dmitry@daynix.com, pbonzini@redhat.com,
peter.huangpeng@huawei.com, lcapitulino@redhat.com,
afaerber@suse.de, dgilbert@redhat.com
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 [thread overview]
Message-ID: <53E18AAF.1090902@redhat.com> (raw)
In-Reply-To: <20140805140256.GA16091@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]
On 08/05/2014 08:02 AM, Michael S. Tsirkin wrote:
> On Fri, Aug 01, 2014 at 03:46:08PM +0800, arei.gonglei@huawei.com wrote:
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> $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 <mst@redhat.com>
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Eric Blake <eblake@redhat.com>
To: "Michael S. Tsirkin" <mst@redhat.com>, arei.gonglei@huawei.com
Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com,
weidong.huang@huawei.com, stefanha@redhat.com,
marcel.a@redhat.com, qemu-trivial@nongnu.org,
luonengjun@huawei.com, qemu-devel@nongnu.org, armbru@redhat.com,
av1474@comtv.ru, kraxel@redhat.com, aliguori@amazon.com,
imammedo@redhat.com, dmitry@daynix.com, pbonzini@redhat.com,
peter.huangpeng@huawei.com, lcapitulino@redhat.com,
afaerber@suse.de, dgilbert@redhat.com
Subject: Re: [Qemu-devel] [PATCH v3 for-2.2 0/8] don't use Yoda conditions
Date: Tue, 05 Aug 2014 19:53:51 -0600 [thread overview]
Message-ID: <53E18AAF.1090902@redhat.com> (raw)
In-Reply-To: <20140805140256.GA16091@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]
On 08/05/2014 08:02 AM, Michael S. Tsirkin wrote:
> On Fri, Aug 01, 2014 at 03:46:08PM +0800, arei.gonglei@huawei.com wrote:
>> From: Gonglei <arei.gonglei@huawei.com>
>>
>> $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 <mst@redhat.com>
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 #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 539 bytes --]
next prev parent reply other threads:[~2014-08-06 6:44 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-01 7:46 [Qemu-devel] [PATCH v3 for-2.2 0/8] don't use Yoda conditions arei.gonglei
2014-08-01 7:46 ` [Qemu-devel] [PATCH v3 1/8] CODING_STYLE: Section about conditional statement arei.gonglei
2014-08-01 16:01 ` Eric Blake
2014-08-04 0:55 ` Gonglei (Arei)
2014-08-05 15:48 ` Alex Bennée
2014-08-05 15:53 ` Michael S. Tsirkin
2014-08-06 1:53 ` Gonglei (Arei)
2014-08-01 7:46 ` [Qemu-devel] [PATCH v3 2/8] usb: don't use 'Yoda conditions' arei.gonglei
2014-08-01 7:46 ` [Qemu-devel] [PATCH v3 3/8] audio: " arei.gonglei
2014-08-01 7:46 ` [Qemu-devel] [PATCH v3 4/8] isa-bus: " arei.gonglei
2014-08-01 7:46 ` [Qemu-devel] [PATCH v3 5/8] " arei.gonglei
2014-08-01 7:46 ` [Qemu-devel] [PATCH v3 6/8] spice: " arei.gonglei
2014-08-01 7:46 ` [Qemu-devel] [PATCH v3 7/8] vl: " arei.gonglei
2014-08-01 7:46 ` [Qemu-devel] [PATCH v3 8/8] vmxnet3: " arei.gonglei
2014-08-05 14:02 ` [Qemu-trivial] [PATCH v3 for-2.2 0/8] don't use Yoda conditions Michael S. Tsirkin
2014-08-05 14:02 ` [Qemu-devel] " Michael S. Tsirkin
2014-08-06 1:47 ` [Qemu-trivial] " Gonglei (Arei)
2014-08-06 1:47 ` [Qemu-devel] " Gonglei (Arei)
2014-08-06 6:05 ` [Qemu-trivial] " Markus Armbruster
2014-08-06 6:05 ` Markus Armbruster
2014-08-06 6:57 ` [Qemu-trivial] " Michael S. Tsirkin
2014-08-06 6:57 ` Michael S. Tsirkin
2014-08-06 7:55 ` [Qemu-trivial] " Markus Armbruster
2014-08-06 7:55 ` Markus Armbruster
2014-08-06 1:53 ` Eric Blake [this message]
2014-08-06 1:53 ` Eric Blake
2014-08-06 6:53 ` [Qemu-trivial] " Michael S. Tsirkin
2014-08-06 6:53 ` [Qemu-devel] " Michael S. Tsirkin
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=53E18AAF.1090902@redhat.com \
--to=eblake@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=av1474@comtv.ru \
--cc=dgilbert@redhat.com \
--cc=dmitry@daynix.com \
--cc=imammedo@redhat.com \
--cc=kraxel@redhat.com \
--cc=lcapitulino@redhat.com \
--cc=luonengjun@huawei.com \
--cc=marcel.a@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=stefanha@redhat.com \
--cc=weidong.huang@huawei.com \
/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.