From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lx4qr-0002OF-U7 for qemu-devel@nongnu.org; Thu, 23 Apr 2009 15:44:53 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lx4qn-0002Nb-9A for qemu-devel@nongnu.org; Thu, 23 Apr 2009 15:44:53 -0400 Received: from [199.232.76.173] (port=50225 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lx4qn-0002NU-14 for qemu-devel@nongnu.org; Thu, 23 Apr 2009 15:44:49 -0400 Received: from caffeine.csclub.uwaterloo.ca ([129.97.134.17]:60762) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Lx4qm-0002ck-KG for qemu-devel@nongnu.org; Thu, 23 Apr 2009 15:44:48 -0400 Date: Thu, 23 Apr 2009 15:44:47 -0400 Subject: Re: [Qemu-devel] [7234] Use a more natural order Message-ID: <20090423194447.GK3795@csclub.uwaterloo.ca> References: <20090423185308.GH3795@csclub.uwaterloo.ca> <20090423191040.GI3795@csclub.uwaterloo.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: From: lsorense@csclub.uwaterloo.ca (Lennart Sorensen) List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org On Thu, Apr 23, 2009 at 10:31:05PM +0300, Blue Swirl wrote: > I don't think any code style document can cover all possible cases. > But another approach can be used: you could try to find a precedent > case where this style has been used in QEMU. # grep -r '([0-9] =' . ./net.c: if (0 == errno && '\0' == *last_char && ./hw/gus.c: if (0 == ((mode >> 4) & 1)) { ./hw/dma.c: if ((0 == (d->mask & mask)) && (0 != (d->status & (mask << 4)))) { ./hw/sb16.c: if (0 == s->needed_bytes) { ./hw/sb16.c: if (0 == s->needed_bytes) { ./hw/sb16.c: if (0 == s->dma_auto) { ./hw/sb16.c: if (0 == s->dma_auto) { That was just one quick search. Looks like whoever wrote a bunch of the audio hardware emulation liked less buggy code. > The formats and systems with varying level of brokenness reflect the > centuries of weird history behind them. Only from a purely engineering > standpoint that is not a valid reason for still using them. Well to me software development is a kind of engineering and hence using anything but the safest practice that is at all practical makes no sense. That means: Constants before variables in all comparisons. Braces are never optional for blocks. The second one is especially hard to get some people to understand. -- Len Sorensen