[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v3 1/8] CODING_STYLE: Section about conditional
From: |
Gonglei (Arei) |
Subject: |
Re: [Qemu-devel] [PATCH v3 1/8] CODING_STYLE: Section about conditional statement |
Date: |
Wed, 6 Aug 2014 01:53:06 +0000 |
Hi,
> > >
> > >> > Yoda conditions lack readability, and QEMU has a
> > >> > strict compiler configuration for checking a common
> > >> > mistake like "if (dev = NULL)". Make it a written rule.
> > <snip>
> > >>
> > >> I know this is my suggested text, but now that I'm re-reading it, I'd
> > >> recommend s/0/1/ in all three places, since comparison to 0 is one of
> > >> those special cases where '!a' is faster to write than 'a == 0'.
> > >>
> > > Got it.
> >
> > Should we add explicit examples for:
> >
> > if (x)
> > if (!x)
> >
> > then?
>
> Some people prefer a != NULL and not !a.
> It's easy to change all == NULL and != NULL if
> people prefer this:
>
> http://www.emn.fr/z-info/coccinelle/rules/badzero.html
>
Yes, please see below conversation in v2:
http://thread.gmane.org/gmane.comp.emulators.qemu/288564/focus=288586
Best regards,
-Gonglei
[Qemu-devel] [PATCH v3 3/8] audio: don't use 'Yoda conditions', arei.gonglei, 2014/08/01
[Qemu-devel] [PATCH v3 6/8] spice: don't use 'Yoda conditions', arei.gonglei, 2014/08/01
[Qemu-devel] [PATCH v3 7/8] vl: don't use 'Yoda conditions', arei.gonglei, 2014/08/01
[Qemu-devel] [PATCH v3 2/8] usb: don't use 'Yoda conditions', arei.gonglei, 2014/08/01
[Qemu-devel] [PATCH v3 4/8] isa-bus: don't use 'Yoda conditions', arei.gonglei, 2014/08/01
Re: [Qemu-devel] [PATCH v3 for-2.2 0/8] don't use Yoda conditions, Michael S. Tsirkin, 2014/08/05