These macros expanded the LEVEL argument without protecting it with parentheses, which meant that an argument like 'cond ? VLL_DBG : VLL_WARN' did not have the desired effect (and caused a GCC warning).
This commit fixes the problem and avoids expanding LEVEL more than once, too. --- lib/vlog.h | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/vlog.h b/lib/vlog.h index d982db2..bbc00ad 100644 --- a/lib/vlog.h +++ b/lib/vlog.h @@ -234,16 +234,18 @@ void vlog_rate_limit(const struct vlog_module *, enum vlog_level, void vlog_usage(void); /* Implementation details. */ -#define VLOG(LEVEL, ...) \ - do { \ - if (THIS_MODULE->min_level >= LEVEL) { \ - vlog(THIS_MODULE, LEVEL, __VA_ARGS__); \ - } \ +#define VLOG(LEVEL, ...) \ + do { \ + enum vlog_level level__ = LEVEL; \ + if (THIS_MODULE->min_level >= level__) { \ + vlog(THIS_MODULE, level__, __VA_ARGS__); \ + } \ } while (0) #define VLOG_RL(RL, LEVEL, ...) \ do { \ - if (THIS_MODULE->min_level >= LEVEL) { \ - vlog_rate_limit(THIS_MODULE, LEVEL, RL, __VA_ARGS__); \ + enum vlog_level level__ = LEVEL; \ + if (THIS_MODULE->min_level >= level__) { \ + vlog_rate_limit(THIS_MODULE, level__, RL, __VA_ARGS__); \ } \ } while (0) #define VLOG_ONCE(LEVEL, ...) \ -- 1.7.1 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev