Re: [PATCH V2 0/3] Introduce and use DO_ONCE statement expressionmacro

From: Al Viro
Date: Fri May 22 2009 - 01:27:12 EST


On Thu, May 21, 2009 at 09:27:29PM -0700, Joe Perches wrote:
> The printk_once macro in kernel.h is limited to printk
>
> This generalizes the functionality of printk_once and
> allows statements like DO_ONCE(pr_info("foo\n"))
> and DO_ONCE(initialize(foo));

Sigh... Please, don't do introduce new control structures without extremely
good reasons.

printk_once() has syntax of function call; it's far more tolerable for
casual reader (e.g. somebody looking through the code while trying to
localize a bug) since it doesn't interrupt the flow - it parses as
"some function call, apparently doing some debugging output, let's see
if there are any obvious side effects in the arguments and move on".
Your DO_ONCE(....) parses as "what the fuck is that?" followed by
grepping for definition, and the cost is much higher.

Don't do that. Staying close to normal syntax is a very good thing;
preprocessor can be used in a lot of ways that are harmful and introduction
of (effectively) new kinds of statements is a prime example. It *does*
have its place, but it should be done very sparingly.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/