]> jfr.im git - irc/atheme/libmowgli-2.git/commitdiff
Switched assert to use do while(0)s, fixed files broken by this
authorPatrick McFarland <redacted>
Mon, 4 Feb 2013 08:43:28 +0000 (03:43 -0500)
committerPatrick McFarland <redacted>
Mon, 4 Feb 2013 08:43:28 +0000 (03:43 -0500)
src/libmowgli/base/argstack.c
src/libmowgli/core/assert.h
src/libmowgli/vio/vio_sockets.c

index 7baec71e2f1aad2128d2d1a14ced4e3cdf957a09..38cfa2828267c560d921ad2023d9bd415f0b9252 100644 (file)
@@ -178,7 +178,7 @@ const char *mowgli_argstack_pop_string(mowgli_argstack_t *self)
  */
 int mowgli_argstack_pop_numeric(mowgli_argstack_t *self)
 {
-       return_val_if_fail(self != NULL, 0)
+       return_val_if_fail(self != NULL, 0);
 
        mowgli_node_t *n;
        mowgli_argstack_element_t *e;
index 656222144bc0afbe32591dea77d3716e8aa2a7e7..5c55e8113dc0b52daa02b3db6257906fc0da0494 100644 (file)
 #ifndef __MOWGLI_ASSERT_H__
 #define __MOWGLI_ASSERT_H__
 
-#define _assert_msg(x) "sssertion '#x' failed."
+#define _assert_msg(exp) "assertion '#exp' failed."
 
-#define soft_assert(x, ...) \
-       if (!(x)) { \
-               mowgli_log_warning(_assert_msg(x),  ##__VA_ARGS__); \
-       }
+#define soft_assert(exp) \
+       do { \
+               if (!(exp)) { \
+                       mowgli_log_warning(_assert_msg(exp)); \
+               } \
+       } while(0)
 
-#define return_if_fail(x, ...) \
-       if (!(x)) { \
-               mowgli_log_warning(_assert_msg(x), ##__VA_ARGS__); \
-               return; \
-       }
+#define return_if_fail(exp) \
+       do { \
+               if (!(exp)) { \
+                       mowgli_log_warning(_assert_msg(exp)); \
+                       return; \
+               } \
+       } while(0)
 
-#define return_val_if_fail(x, y, ...) \
-       if (!(x)) { \
-               mowgli_log_warning(_assert_msg(x), ##__VA_ARGS__); \
-               return (y); \
-       }
+#define return_val_if_fail(exp, val) \
+       do { \
+               if (!(exp)) { \
+                       mowgli_log_warning(_assert_msg(exp)); \
+                       return (val); \
+               } \
+       } while(0)
 
-#define return_null_if_fail(x, ...) return_val_if_fail(x, NULL, ##__VA_ARGS__);
+#define return_null_if_fail(exp) return_val_if_fail(exp, NULL)
 
 #endif
index 842a939f4f0f7fb623641089998560aea0435132..af8b512071bc915f2c0312c2c6876e50e99908b8 100644 (file)
@@ -379,7 +379,7 @@ int mowgli_vio_default_seek(mowgli_vio_t *vio, long offset, int whence)
 
 int mowgli_vio_default_tell(mowgli_vio_t *vio)
 {
-       return_val_if_fail(vio, -255)
+       return_val_if_fail(vio, -255);
        vio->error.op = MOWGLI_VIO_ERR_OP_TELL;
        errno = ENOSYS;
        return mowgli_vio_err_errcode(vio, strerror, errno);