r911 - trunk/varnish-cache/include

phk at projects.linpro.no phk at projects.linpro.no
Thu Aug 24 08:58:37 CEST 2006


Author: phk
Date: 2006-08-24 08:58:37 +0200 (Thu, 24 Aug 2006)
New Revision: 911

Modified:
   trunk/varnish-cache/include/libvarnish.h
Log:
Split assert into "static check" and "missing code" variants.

The "missing code" variants have xxx prefix

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



Modified: trunk/varnish-cache/include/libvarnish.h
===================================================================
--- trunk/varnish-cache/include/libvarnish.h	2006-08-24 06:15:13 UTC (rev 910)
+++ trunk/varnish-cache/include/libvarnish.h	2006-08-24 06:58:37 UTC (rev 911)
@@ -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 @@
 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 @@
 } 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)




More information about the varnish-commit mailing list