qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 4/7] a trivial code change for more idiomatic wr


From: Dr. David Alan Gilbert
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
User-agent: Mutt/1.5.23 (2014-03-12)

* Peter Maydell (address@hidden) wrote:
> On 31 July 2014 14:55, Dr. David Alan Gilbert <address@hidden> wrote:
> > * address@hidden (address@hidden) 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 / address@hidden / Manchester, UK



reply via email to

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