From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Huangweidong (C)" <weidong.huang@huawei.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.a@redhat.com>,
Luonengjun <luonengjun@huawei.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Markus Armbruster <armbru@redhat.com>,
"Gonglei (Arei)" <arei.gonglei@huawei.com>,
Vassili Karpov <av1474@comtv.ru>,
Gerd Hoffmann <kraxel@redhat.com>,
Anthony Liguori <aliguori@amazon.com>,
Igor Mammedov <imammedo@redhat.com>,
Dmitry Fleytman <dmitry@daynix.com>,
Paolo Bonzini <pbonzini@redhat.com>,
peter.huangpeng@huawei.com,
Luiz Capitulino <lcapitulino@redhat.com>,
Andreas F?rber <afaerber@suse.de>
Subject: Re: [Qemu-devel] [PATCH 4/7] a trivial code change for more idiomatic writing style
Date: Thu, 31 Jul 2014 15:49:30 +0100 [thread overview]
Message-ID: <20140731144930.GI2405@work-vm> (raw)
In-Reply-To: <CAFEAcA_jCdw0GZCTyDoOty73qoc-RJB9-QU5GoefiN=tLSUCvA@mail.gmail.com>
* Peter Maydell (peter.maydell@linaro.org) wrote:
> On 31 July 2014 14:55, Dr. David Alan Gilbert <dgilbert@redhat.com> wrote:
> > * arei.gonglei@huawei.com (arei.gonglei@huawei.com) wrote:
> >> --- a/qdev-monitor.c
> >> +++ b/qdev-monitor.c
> >> @@ -694,7 +694,7 @@ void qmp_device_del(const char *id, Error **errp)
> >> DeviceState *dev;
> >>
> >> dev = qdev_find_recursive(sysbus_get_default(), id);
> >> - if (NULL == dev) {
> >> + if (dev == NULL) {
> >
> > I know people who write it as 'NULL == dev' on purpose,
> > because that will cause an error if you accidentally type a single =
> > where as 'dev = NULL' will just cause confusion.
>
> Yes, this is the motivation for Yoda conditionals. But it only
> makes sense if you don't have a compiler with a sensible
> warning configuration. For QEMU you will get an error if you
> write "dev = NULL" :
>
> error: suggest parentheses around assignment used as truth value
> [-Werror=parentheses]
>
> so we don't need to get people to contort their code like this.
OK, that's fair enough.
Dave
> thanks
> -- PMM
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
next prev parent reply other threads:[~2014-07-31 14:50 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-31 12:28 [Qemu-devel] [PATCH for-2.2 0/7] a trivial code change for more idiomatic writing style arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 1/7] usb: " arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 2/7] audio: " arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 3/7] isa-bus: " arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 4/7] " arei.gonglei
2014-07-31 13:55 ` Dr. David Alan Gilbert
2014-07-31 13:59 ` Peter Maydell
2014-07-31 14:49 ` Dr. David Alan Gilbert [this message]
2014-07-31 12:28 ` [Qemu-devel] [PATCH 5/7] spice: " arei.gonglei
2014-07-31 12:28 ` [Qemu-devel] [PATCH 6/7] vl: " arei.gonglei
2014-07-31 12:29 ` [Qemu-devel] [PATCH 7/7] vmxnet3: " arei.gonglei
2014-08-04 11:08 ` Stefan Hajnoczi
2014-07-31 12:39 ` [Qemu-devel] [PATCH for-2.2 0/7] " Peter Maydell
2014-07-31 12:46 ` Gonglei (Arei)
2014-07-31 12:55 ` Peter Crosthwaite
2014-07-31 13:04 ` Gonglei (Arei)
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=20140731144930.GI2405@work-vm \
--to=dgilbert@redhat.com \
--cc=afaerber@suse.de \
--cc=aliguori@amazon.com \
--cc=arei.gonglei@huawei.com \
--cc=armbru@redhat.com \
--cc=av1474@comtv.ru \
--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.huangpeng@huawei.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@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.