summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Eitzenberger <heitzenberger@astaro.com>2009-10-09 15:07:49 +0200
committerHarald Welte <laforge@gnumonks.org>2010-10-21 19:15:37 +0200
commit934e1eaa5dbf98c22a037af0d6fefdb1f5b43db6 (patch)
tree983011aa93f6e33a9389bbec8250f0be0f9f4140
parent73ae211f224094de378e4fa527c37df908207971 (diff)
Disable BUG_ON() if NDEBUG set
Signed-off-by: Holger Eitzenberger <holger@eitzenberger.org>
-rw-r--r--include/ulogd/ulogd.h7
-rw-r--r--src/plugin.c5
2 files changed, 11 insertions, 1 deletions
diff --git a/include/ulogd/ulogd.h b/include/ulogd/ulogd.h
index d865e15..ad66c81 100644
--- a/include/ulogd/ulogd.h
+++ b/include/ulogd/ulogd.h
@@ -62,8 +62,13 @@ void ulogd_log(enum ulogd_loglevel, const char *fmt, ...)
void ulogd_bug(const char *, int) __noreturn __cold;
-#define BUG() ulogd_bug(__FILE__, __LINE__);
+#ifdef NDEBUG
+#define BUG() do { } while (0)
+#define BUG_ON(expr)
+#else
+#define BUG() ulogd_bug(__FILE__, __LINE__)
#define BUG_ON(expr) do { if (UNLIKELY(expr)) BUG(); } while (0)
+#endif /* NDEBUG */
/***********************************************************************
* file descriptor handling
diff --git a/src/plugin.c b/src/plugin.c
index ad992f2..e88f9c8 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -881,11 +881,14 @@ static void
__check_set(const struct ulogd_key *key, unsigned type)
{
BUG_ON(!key);
+
+#ifndef NDEBUG
if (UNLIKELY(!(key_type(key) & type))) {
ulogd_log(ULOGD_FATAL, "%s: invalid key set (%d <-> %d)\n",
key->name, key_type(key), type);
BUG();
}
+#endif
}
void
@@ -1002,11 +1005,13 @@ __check_get(const struct ulogd_key *key, unsigned type)
BUG_ON(!key);
BUG_ON(!key_valid(key));
+#ifndef NDEBUG
if (UNLIKELY(!(key_type(key) & type))) {
ulogd_log(ULOGD_FATAL, "%s: invalid key access (%d <-> %d)\n",
key->name, key_type(key), type);
BUG();
}
+#endif
}
int