From: Jonathan Bastien-Filiatrault Date: Sat, 15 Aug 2009 17:17:25 +0000 (-0400) Subject: Make LEVEL and LEVEL_EQ macros safer. X-Git-Tag: gnutls_2_11_3~323 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=80fee6924dd72b17113a1e72e8d2930634f4a463;p=thirdparty%2Fgnutls.git Make LEVEL and LEVEL_EQ macros safer. Once again, I got bit by this pretty hard. --- diff --git a/lib/gnutls_errors.h b/lib/gnutls_errors.h index e6085eda09..8bc0c6f0d7 100644 --- a/lib/gnutls_errors.h +++ b/lib/gnutls_errors.h @@ -53,11 +53,11 @@ _gnutls_log (int, const char *fmt, ...) void _gnutls_mpi_log (const char *prefix, bigint_t a); #ifdef C99_MACROS -#define LEVEL(l, ...) if (_gnutls_log_level >= l || _gnutls_log_level > 9) \ - _gnutls_log( l, __VA_ARGS__) +#define LEVEL(l, ...) do { if (_gnutls_log_level >= l || _gnutls_log_level > 9) \ + _gnutls_log( l, __VA_ARGS__); } while(0) -#define LEVEL_EQ(l, ...) if (_gnutls_log_level == l || _gnutls_log_level > 9) \ - _gnutls_log( l, __VA_ARGS__) +#define LEVEL_EQ(l, ...) do { if (_gnutls_log_level == l || _gnutls_log_level > 9) \ + _gnutls_log( l, __VA_ARGS__); } while(0) # define _gnutls_debug_log(...) LEVEL(2, __VA_ARGS__) # define _gnutls_handshake_log(...) LEVEL(3, __VA_ARGS__)