From: Ben Pfaff Date: Thu, 7 Apr 2011 21:39:36 +0000 (-0700) Subject: vlog: Fix VLOG and VLOG_RL macros' treatment of LEVEL argument. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45704b243abd1efcbb2ee26f342f07df4a7612f6;p=openvswitch vlog: Fix VLOG and VLOG_RL macros' treatment of LEVEL argument. 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. --- diff --git a/lib/vlog.h b/lib/vlog.h index d982db2b..bbc00ad2 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, ...) \