[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[augeas-devel] augeas: master - * src/errcode.h: more usable BUG_ON and BUG_FMT



Gitweb:        http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=b9cb63d3850d4cf67ee5419ee7cd39f549161f12
Commit:        b9cb63d3850d4cf67ee5419ee7cd39f549161f12
Parent:        d640667168c83297dde3f361ab8cd33945f1b124
Author:        David Lutterkort <lutter redhat com>
AuthorDate:    Wed Dec 23 17:33:18 2009 -0800
Committer:     David Lutterkort <lutter redhat com>
CommitterDate: Thu Jan 14 14:48:38 2010 -0800

* src/errcode.h: more usable BUG_ON and BUG_FMT

---
 src/errcode.h |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/errcode.h b/src/errcode.h
index e5d2334..54dc330 100644
--- a/src/errcode.h
+++ b/src/errcode.h
@@ -68,6 +68,19 @@ void bug_on(struct error *err, const char *srcfile, int srclineno,
         }                                               \
     } while(0)
 
+/* A variant of assert that uses our error reporting infrastructure
+ * instead of aborting
+ */
+#ifdef NDEBUG
+# define ensure(cond, obj) ((void) (0))
+#else
+# define ensure(cond, obj)                                           \
+    if (!(cond)) {                                                   \
+        bug_on((obj)->error, __FILE__, __LINE__, NULL);              \
+        goto error;                                                  \
+    }
+#endif
+
 #define BUG_ON(cond, obj, fmt ...)                                  \
     if (cond) {                                                     \
         bug_on((obj)->error, __FILE__, __LINE__, ## fmt);           \



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]