From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XD6XT-0002tD-U4 for qemu-devel@nongnu.org; Fri, 01 Aug 2014 02:42:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XD6XP-0006cw-JV for qemu-devel@nongnu.org; Fri, 01 Aug 2014 02:42:03 -0400 Received: from mx1.redhat.com ([209.132.183.28]:3132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XD6XP-0006cg-Bd for qemu-devel@nongnu.org; Fri, 01 Aug 2014 02:41:59 -0400 From: Markus Armbruster References: <1406860365-5516-1-git-send-email-arei.gonglei@huawei.com> <1406860365-5516-3-git-send-email-arei.gonglei@huawei.com> <53DB0499.2010505@redhat.com> <33183CC9F5247A488A2544077AF1902086C1E41E@SZXEMA503-MBS.china.huawei.com> <53DB0CB1.9040207@suse.de> Date: Fri, 01 Aug 2014 08:41:18 +0200 In-Reply-To: <53DB0CB1.9040207@suse.de> ("Andreas =?utf-8?Q?F=C3=A4rber=22?= =?utf-8?Q?'s?= message of "Fri, 01 Aug 2014 05:42:41 +0200") Message-ID: <87fvhglnjl.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 2/8] usb: a trivial code change for more idiomatic writing style List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?utf-8?Q?F=C3=A4rber?= Cc: "peter.maydell@linaro.org" , "peter.crosthwaite@xilinx.com" , "Huangweidong (C)" , "aliguori@amazon.com" , "mst@redhat.com" , "marcel.a@redhat.com" , Luonengjun , "qemu-devel@nongnu.org" , "lcapitulino@redhat.com" , "Gonglei (Arei)" , "av1474@comtv.ru" , "kraxel@redhat.com" , "stefanha@redhat.com" , "pbonzini@redhat.com" , "dmitry@daynix.com" , "imammedo@redhat.com" , "Huangpeng (Peter)" , "dgilbert@redhat.com" Andreas F=C3=A4rber writes: > Am 01.08.2014 05:32, schrieb Gonglei (Arei): >> Hi, >>=20 >>> Subject: Re: [PATCH v2 2/8] usb: a trivial code change for more >>> idiomatic writing >>> style >>> >>> On 07/31/2014 08:32 PM, arei.gonglei@huawei.com wrote: >>>> From: Gonglei >>>> >>>> Signed-off-by: Gonglei >>>> --- >>>> hw/usb/dev-audio.c | 2 +- >>>> hw/usb/dev-mtp.c | 4 ++-- >>>> hw/usb/hcd-ehci.c | 2 +- >>>> 3 files changed, 4 insertions(+), 4 deletions(-) >>>> >>>> diff --git a/hw/usb/dev-audio.c b/hw/usb/dev-audio.c >>>> index bfebfe9..988f6cc 100644 >>>> --- a/hw/usb/dev-audio.c >>>> +++ b/hw/usb/dev-audio.c >>>> @@ -371,7 +371,7 @@ static void output_callback(void *opaque, int avai= l) >>>> return; >>>> } >>>> data =3D streambuf_get(&s->out.buf); >>>> - if (NULL =3D=3D data) { >>>> + if (data =3D=3D NULL) { >>> >>> Wouldn't it be even more idiomatic as: >>> >>> if (!data) { >>> >>> Probably applies throughout your series. >>> >> OK, will do. Thanks! > > Not so quick! You are free to use that in your patches, but please don't > change all code that way without the author's consent. Just like "equals > null" is a natural English way of reading, compared to "null equals > something", "not null" reads like a boolean expression to me, and even > worse while all valid C, "not strcmp" leads to mind-boggling inverted > logic... !strcmp() is somewhat error prone, because it suggests inequality. Can't claim that for !data. That one suggests "no data", which is exactly right. Like Eric, I prefer it to the cumbersome data =3D=3D NULL. data =3D=3D 0 is right out. Since there's no consensus on !data vs. data =3D=3D NULL, you're free to follow your own taste in new code. When changing existing code, imitate nearby code. When nearby code is inconsistent, it's your own taste again.