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

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Krzysztof Halasa <khc@...>
Cc: Hannes Eder <hannes@...>, <netdev@...>, <kernel-janitors@...>, <linux-kernel@...>
Date: Monday, December 22, 2008 - 7:44 pm

2008/12/22 Krzysztof Halasa <khc@pm.waw.pl>:

For this specific issue the important aspect is to improve readability
(and not just eventually satisfy some warning from a tool), which I
assume there is no disagrement on. Now what constitutes improved
readbility on the other hand is another issue, and I guess there are
next to as many oppinions as developers... :)
I would most certainly prefer to have code look consistently and always
have brackets, even in the case of just one body line.

Of secondary importance is the benefit that always using brackets
makes 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 conflict
that has to be resolved manually. If the brackets had been in place from the
start tools should be able to resolv this automatically.

BR Håkon Løvdal
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/27] drivers/net: fix sparse warnings, Hannes Eder, (Mon Dec 22, 3:14 pm)
[PATCH 08/27] drivers/net/cxgb3: comment out dead code, Hannes Eder, (Mon Dec 22, 3:16 pm)
Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-..., Håkon Løvdal, (Mon Dec 22, 7:44 pm)
Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-..., Krzysztof Halasa, (Tue Dec 23, 12:31 pm)
Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-..., Krzysztof Halasa, (Tue Dec 23, 10:03 pm)