lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  PHC 
Open Source and information security mailing list archives
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 23 Dec 2008 15:38:02 -0800 (PST)
From:	Linus Torvalds <>
To:	Krzysztof Halasa <>
cc:	Harvey Harrison <>,
	Håkon Løvdal <>,
	Hannes Eder <>,,,
Subject: Re: [PATCH 02/27] drivers/net: fix sparse warnings: make do-while
 a compound statement

On Wed, 24 Dec 2008, Krzysztof Halasa wrote:
> So is a case like
> 	do
> 		x;
> 	while (y);
> It can't be made more clear with brackets.

Oh yes it can. People look at that, and it's so uncommon that they 
literally believe it is a mis-indent.

Your example with nested if-statements are totally pointless, because you 
didn't even apparently understand my comment about "while()" having two 
totally different meanings (which is not true of "if()"), nor realize the 
importance of how common something is.

Common patterns become things that people take for granted and don't have 
any trouble with. In contrast, do-while without braces is _extremely_ 

> IOW: improving the style is great. Changing it only to silence some
> tool is not.

Sorry, you're wrong. It's not changed to silence some tool. THIS IS THE 

I don't care one whit about your personal coding style. The kernel has 
brances. End of discussion. sparse complains about lack of them. 

> Right, but they (at least for me) make it more readable.

I don't care.

> kmalloc(sizeof i) just doesn't look good, the operator looks like
> a variable name.

And I agree with you. "sizeof i" doesn't look good. It's uncommon, and 
doesn't match peoples expectations.

> But there is this return statement. Some people tend to write
> return (x); I simply write return x;

I do to. And it's the common thing to do, and only totally confused people 
think that 'return' is a somehow remotely like a "function" of its 
arguments (the way 'sizeof' is - sizeof _is_ a function of its arguments, 
albeit a very rare one).

> It's clear, and so is a simple do-while.

No. "return x;" is clear because it's the common thing, which means that 
peopel are good at reading it.

Another example of "common vs non-common" is this:

	if (0 <= x)
		do something..

is something that crazy people do (sadly, one of the crazy people taught 
the git maintainer C programming, so now even sane people do it). It's 
crazy because it's uncommon, which means that most people have to think 
about it A LOT MORE than about

	if (x >= 0)
		do something..

even though technically both are obviously EXACTLY THE SAME THING.

Can you see the argument? Doing things the common way is important, 
because it allows people to see what they mean without having to think 
about it. They just scan it, and the meaning is clear.

And that's why "do while" without braces is bad. If you scan it quickly on 
its own, you may well end up just seeing the

	while (x);

part, and get confused ("oh, a delay loop"). But if you see

	} while (x);

you aren't confused, because the latter one is clearly an ending condition 
of a do-while loop, IN A WAY THAT THE FIRST ONE IS NOT!


do-while is very special, because as mentioned, "while" is a really magic 
C keyword that has two TOTALLY DIFFERENT meanings. Don't make people look 
for the "do".

To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to
More majordomo info at

Powered by blists - more mailing lists