On 31 July 2014 14:55, Dr. David Alan Gilbert <dgilb...@redhat.com> wrote: > * arei.gong...@huawei.com (arei.gong...@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. thanks -- PMM