Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while a compound statement

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

 



2008/12/22 Krzysztof Halasa <khc@xxxxxxxxx>:>> --- a/drivers/net/starfire.c>> +++ b/drivers/net/starfire.c>> @@ -882,9 +882,9 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)>>       void __iomem *mdio_addr = np->base + MIICtrl + (phy_id<<7) + (location<<2);>>       int result, boguscnt=1000;>>       /* ??? Should we add a busy-wait here? */>> -     do>> +     do {>>               result = readl(mdio_addr);>> -     while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);>> +     } while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);>>       if (boguscnt == 0)>>               return 0;>>       if ((result & 0xffff) == 0xffff)>>> I don't know how one could think the above is an improvement.
For this specific issue the important aspect is to improve readability(and not just eventually satisfy some warning from a tool), which Iassume there is no disagrement on. Now what constitutes improvedreadbility on the other hand is another issue, and I guess there arenext to as many oppinions as developers... :)I would most certainly prefer to have code look consistently and alwayshave brackets, even in the case of just one body line.
Of secondary importance is the benefit that always using bracketsmakes them much more merge friendly. Consider the following scenario:
Common base:        do                result = readl(mdio_addr);        while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);
Branch 1        do {                result = readl(mdio_addr);                do_something();        } while ((result & 0xC0000000) != 0x80000000 && --boguscnt > 0);
Branch 2        do                result = readl(mdio_addr);        while (NOT_OK(result) && --boguscnt > 0);
In this case if both branch 1 and 2 are merged, there will be a merge conflictthat has to be resolved manually. If the brackets had been in place from thestart tools should be able to resolv this automatically.
BR Håkon Løvdal��.n��������+%������w��{.n����z�ޗ�����n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�m


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux