qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [7234] Use a more natural order


From: Lennart Sorensen
Subject: Re: [Qemu-devel] [7234] Use a more natural order
Date: Thu, 23 Apr 2009 15:44:47 -0400
User-agent: Mutt/1.5.18 (2008-05-17)

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]