I always do that (well, almost always), just because it protects macros
from being mis-used.
For example, if you have
#define macro(x) ((x) = 3)
that _looks_ safe, but it allows people to write
x++ = macro(x);
or similar nonsense. So if you want a macro that always behaves like a
statement (and can't be used as an expression), the "do { } while (0)"
will do that.
[ The real answer is that it's so built in to my spine, that I just can't
stop myself. Even if it doesn't really matter. ]
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/