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: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH 4/7] a trivial code change for more idiomatic writing style
Date: Thu, 31 Jul 2014 14:59:45 +0100

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.

thanks
-- PMM



reply via email to

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