lkml.org 
[lkml]   [2009]   [May]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V2 0/3] Introduce and use DO_ONCE statement expression macro
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.


\
 
 \ /
  Last update: 2009-05-22 07:31    [W:0.050 / U:0.676 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site