On Wed, 2005-09-14 at 18:16 -0400, Tyler Trafford wrote:
> Something from the driver modules I've been wondering about:
> 
> #define WM8775_DEBUG(args...) \
>     do { \
>         if (debug) \
>             printk(KERN_INFO "wm8775 debug: " args); \
>     } while (0)
> 
> Does the 'loop' provide some optimization that I can't see?

It's a common idiom that ensures that the whole lot is a single C
statement.

There's a good explanation towards the end of 
http://www.kernelnewbies.org/faq/#dowhile

I was thinking that this case might be too simple to warrant it but:
        if (something)
                WM8775_DEBUG("blah");
        else
                some_other_action();
has an ambiguous else if you don't use the do while.

Ian.

-- 
Ian Campbell

ASCII a stupid question, you get an EBCDIC answer.

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to