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: Harvey Harrison <harvey.harrison@...>, Håkon Løvdal <hlovdal@...>, Hannes Eder <hannes@...>, <netdev@...>, <kernel-janitors@...>, <linux-kernel@...>
Date: Tuesday, December 23, 2008 - 2:08 pm

On Tue, 23 Dec 2008, Krzysztof Halasa wrote:


It's more than that. I added the check after some person who had been 
programming the kernel (and thus was supposedly fluent in C) literally 
could not parse a macro that had "do x while (y)" in it.

Why? Because it's so uncommon, and because "while (y)" on its own means 
something totally different.

So the syntactic sugar to _always_ have do-while loops have that brace is 
a way to avoid one of the rather few places where the C language has 
syntax that is very context-dependent.

Another example of this is "sizeof". The kernel universally (I hope) has 
parenthesis around the sizeof argument, even though it's clearly not 
required by the C language. 

It's a coding standard. 

And quite frankly, anybody who works on gcc has no place complaining about 
sparse coding standard warnings. They are a _hell_ of a lot better than 
some of the really crazy warnings gcc spews out with "-W". At least the 
sparse warnings you can make go away while making the code more 
understandable. Some of the -W warnings are unfixable without breaking the 
source code.

		Linus
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
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-..., Krzysztof Halasa, (Tue Dec 23, 12:31 pm)
Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-..., Linus Torvalds, (Tue Dec 23, 2:08 pm)
Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-..., Krzysztof Halasa, (Tue Dec 23, 10:03 pm)