From 4f82b13f93c2946423ece1b9fec0714668b0eddb Mon Sep 17 00:00:00 2001 From: phk Date: Thu, 24 Aug 2006 06:58:37 +0000 Subject: [PATCH] Split assert into "static check" and "missing code" variants. 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 | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/varnish-cache/include/libvarnish.h b/varnish-cache/include/libvarnish.h index a3a1edd7..08388c63 100644 --- a/varnish-cache/include/libvarnish.h +++ b/varnish-cache/include/libvarnish.h @@ -5,6 +5,10 @@ #include #include +#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) -- 2.39.5