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.
void vlog_usage(void);
/* Implementation details. */
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 { \
} 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, ...) \
} \
} while (0)
#define VLOG_ONCE(LEVEL, ...) \