]> jfr.im git - solanum.git/blobdiff - include/s_assert.h
ircd/authproc.c: avoid crash on lack of any configured DNSBLs
[solanum.git] / include / s_assert.h
index 60ea28cd4323f15e25d2327fa40671554f28c52e..913ec1a9cb601fd794a9f674b727ede716d7af72 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  charybdis: An advanced IRCd.
+ *  solanum: An advanced IRCd.
  *  s_assert.h: Definition of the soft assert (s_assert) macro.
  *
  *  Copyright (C) 1990 Jarkko Oikarinen and University of Oulu, Co Center
 #ifndef INCLUDED_s_assert_h
 #define INCLUDED_s_assert_h
 
-#include "config.h"
-
-#ifdef SOFT_ASSERT
+#include "defaults.h"
 
 #include "logger.h"
 #include "send.h"
 #include "snomask.h"
 
 #ifdef __GNUC__
-#define s_assert(expr) do                                                              \
-                       if(!(expr)) {                                                   \
+#define ss_assert(expr)        (                                                               \
+                       ((expr)) || (                                                   \
                                ilog(L_MAIN,                                            \
                                "file: %s line: %d (%s): Assertion failed: (%s)",       \
-                               __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr);        \
+                               __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr), 0) || (\
                                sendto_realops_snomask(SNO_GENERAL, L_ALL,              \
                                "file: %s line: %d (%s): Assertion failed: (%s)",       \
-                               __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr);        \
-                       }                                                               \
-                       while(0)
+                               __FILE__, __LINE__, __PRETTY_FUNCTION__, #expr), 0)     \
+                       )
 #else
-#define s_assert(expr) do                                                              \
-                       if(!(expr)) {                                                   \
+#define ss_assert(expr)        (                                                               \
+                       ((expr)) || (                                                   \
                                ilog(L_MAIN,                                            \
                                "file: %s line: %d: Assertion failed: (%s)",            \
-                               __FILE__, __LINE__, #expr);                             \
+                               __FILE__, __LINE__, #expr), 0) || (                     \
                                sendto_realops_snomask(SNO_GENERAL, L_ALL,              \
                                "file: %s line: %d: Assertion failed: (%s)"             \
-                               __FILE__, __LINE__, #expr);                             \
-                       }                                                               \
-                       while(0)
+                               __FILE__, __LINE__, #expr), 0)                          \
+                       )
 #endif
+
+/* evaluates to true if assertion fails */
+#ifdef SOFT_ASSERT
+#define s_assert(expr) (!ss_assert(expr))
 #else
-#define s_assert(expr) assert(expr)
+#define s_assert(expr) (assert(ss_assert(expr)), 0)
 #endif
 
 #endif /* INCLUDED_s_assert_h */