On Sat, 30 Sep 2006, Linus Torvalds wrote:
>
> It's not just unreadable and obviously buggy, it's so scarily that it's
> hard to even talk about it. Lookie here:
>
> #define HANDLE_STACK(cond) \
> do while (cond) { \
> unsigned long addr = *stack++; \
>
> What the F*CK! "do while(cond) {" ????
Btw, it took me quite a while to realize how something like that can
even compile. Seriously. Don't write code like that. Maybe some humans
parse it as
do {
while (cond) {
..
}
} while(0)
(which is the technically correct parsing and explains why it compiles
and wors), but I suspect I'm not the only one who went "What the F*CK"
when shown it without the "extraneous" braces.
For similar reasons, we write
#define dummy(x) do { } while (0)
rather than the shorter
#define dummy(x) do ; while (0)
(which some people _do_ seem to use. Aarggh!)
Or at least indent it. Or something.
I'll see if I can make git warn about "do <non-blockstatement> while ()",
if only because I at least personally seem to have trouble parsing it.
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]