]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Make LEVEL and LEVEL_EQ macros safer.
authorJonathan Bastien-Filiatrault <joe@x2a.org>
Sat, 15 Aug 2009 17:17:25 +0000 (13:17 -0400)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Thu, 3 Jun 2010 17:37:55 +0000 (19:37 +0200)
Once again, I got bit by this pretty hard.

lib/gnutls_errors.h

index e6085eda09e0514aac95af26466984575407d498..8bc0c6f0d781b95510a6305da7b47c403e56d5a8 100644 (file)
@@ -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__)