[asterisk-dev] 0006889: [patch] Convert ast_verbose into macros

Kevin P. Fleming kpfleming at digium.com
Thu Apr 6 07:27:24 MST 2006


Russell Bryant wrote:

> if (option_verbose > 3)
>    ast_verbose(VERBOSE_PREFIX_3 "Hi!\n");
> 
> would become:
> 
> ast_verbose(3, "Hi!\n");

The concern with this method, as I understand it, is that it causes the
function call to ast_verbose (along with all the attendant argument
processing and stack pushing/popping) to happen even if the message is
not going to be generated at all.

Using a macro to simulate the existing code doesn't introduce this
side-effect.

I'm not opposed to the macros as proposed by casper, except I don't like
the use of the 'if (...); else ...;' construct; I'd rather see it use
the 'do { ... } while(0)' construct we typically use in macros to avoid
the problems that have been identified.



More information about the asterisk-dev mailing list