From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44495) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCrgw-0005SZ-GB for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:50:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCrgs-0003yg-22 for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:50:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19939) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCrgr-0003ya-Oz for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:50:45 -0400 Date: Thu, 31 Jul 2014 15:49:30 +0100 From: "Dr. David Alan Gilbert" Message-ID: <20140731144930.GI2405@work-vm> References: <1406809740-10836-1-git-send-email-arei.gonglei@huawei.com> <1406809740-10836-5-git-send-email-arei.gonglei@huawei.com> <20140731135501.GH2405@work-vm> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH 4/7] a trivial code change for more idiomatic writing style List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell Cc: "Huangweidong (C)" , Stefan Hajnoczi , "Michael S. Tsirkin" , Marcel Apfelbaum , Luonengjun , QEMU Developers , Markus Armbruster , "Gonglei (Arei)" , Vassili Karpov , Gerd Hoffmann , Anthony Liguori , Igor Mammedov , Dmitry Fleytman , Paolo Bonzini , peter.huangpeng@huawei.com, Luiz Capitulino , Andreas F?rber * Peter Maydell (peter.maydell@linaro.org) wrote: > On 31 July 2014 14:55, Dr. David Alan Gilbert 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