]> err.no Git - varnish/commitdiff
Split assert into "static check" and "missing code" variants.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 24 Aug 2006 06:58:37 +0000 (06:58 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 24 Aug 2006 06:58:37 +0000 (06:58 +0000)
The "missing code" variants have xxx prefix

Introduce AN() (assert non-null) variant as well.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@911 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/include/libvarnish.h

index a3a1edd72e7822317758c89adebb135847b0fa66..08388c63eef7a3ffa121fb518f8c01f2fc1be6bd 100644 (file)
@@ -5,6 +5,10 @@
 #include <errno.h>
 #include <time.h>
 
+#ifndef NULL
+#define NULL ((void*)0)
+#endif
+
 /* from libvarnish/argv.c */
 void FreeArgv(char **argv);
 char **ParseArgv(const char *s, int comment);
@@ -17,6 +21,12 @@ time_t TIM_parse(const char *p);
 void varnish_version(const char *);
 
 /* from libvarnish/assert.c */
+
+/*
+ * assert(), AN() and AZ() are static checks that should not happen.
+ * xxxassert(), XXXAN() and XXXAZ() are markers for missing code.
+ */
+
 #ifdef WITHOUT_ASSERTS
 #define assert(e)      ((void)0)
 #else /* WITH_ASSERTS */
@@ -27,7 +37,16 @@ do {                                                                         \
 } while (0)
 #endif
 
+#define xxxassert(e)                                                   \
+do {                                                                   \
+       if (!(e))                                                       \
+               lbv_assert("XXX:" __func__, __FILE__, __LINE__, #e, errno); \
+} while (0)
+
 void lbv_assert(const char *, const char *, int, const char *, int);
 
 /* Assert zero return value */
 #define AZ(foo)        do { assert((foo) == 0); } while (0)
+#define AN(foo)        do { assert((foo) != NULL); } while (0)
+#define XXXAZ(foo)     do { xxxassert((foo) == 0); } while (0)
+#define XXXAN(foo)     do { xxxassert((foo) != NULL); } while (0)