From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCqtv-0003TZ-KG for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:00:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCqtq-00017G-Ql for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:00:11 -0400 Received: from mail-la0-f53.google.com ([209.85.215.53]:63693) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCqtq-000153-Jn for qemu-devel@nongnu.org; Thu, 31 Jul 2014 10:00:06 -0400 Received: by mail-la0-f53.google.com with SMTP id gl10so2048423lab.26 for ; Thu, 31 Jul 2014 07:00:05 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20140731135501.GH2405@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> From: Peter Maydell Date: Thu, 31 Jul 2014 14:59:45 +0100 Message-ID: Content-Type: text/plain; charset=UTF-8 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: "Dr. David Alan Gilbert" 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 , =?UTF-8?Q?Andreas_F=C3=A4rber?= 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. thanks -- PMM