From: Marek VavruĊĦa Date: Wed, 28 Jan 2015 17:44:54 +0000 (+0100) Subject: lib: option to turn off debugging X-Git-Tag: v1.0.0-beta1~350^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=84cd855bd8dbf38ff743277fa8ab3d399a5014be;p=thirdparty%2Fknot-resolver.git lib: option to turn off debugging --- diff --git a/lib/cache.c b/lib/cache.c index 8a3014e20..85b32a41d 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -29,7 +29,12 @@ #include "lib/cache.h" #include "lib/defines.h" +#ifndef NDEBUG #define DEBUG_MSG(fmt, ...) fprintf(stderr, "[cache] " fmt, ## __VA_ARGS__) +#else +#define DEBUG_MSG(fmt, ...) +#endif + #define db_api namedb_lmdb_api() namedb_t *kr_cache_open(const char *handle, mm_ctx_t *mm, size_t maxsize) diff --git a/lib/layer/iterate.c b/lib/layer/iterate.c index 5e1027bc4..b0acb1161 100644 --- a/lib/layer/iterate.c +++ b/lib/layer/iterate.c @@ -26,7 +26,11 @@ #include "lib/rplan.h" #include "lib/utils.h" +#ifndef NDEBUG #define DEBUG_MSG(fmt, ...) fprintf(stderr, "[qiter] " fmt, ## __VA_ARGS__) +#else +#define DEBUG_MSG(fmt, ...) +#endif /* Iterator often walks through packet section, this is an abstraction. */ typedef int (*rr_callback_t)(const knot_rrset_t *, struct kr_layer_param *); diff --git a/lib/layer/itercache.c b/lib/layer/itercache.c index ff990429b..228e3595e 100644 --- a/lib/layer/itercache.c +++ b/lib/layer/itercache.c @@ -24,7 +24,11 @@ #include "lib/layer/iterate.h" #include "lib/utils.h" +#ifndef NDEBUG #define DEBUG_MSG(fmt, ...) fprintf(stderr, "[cache] " fmt, ## __VA_ARGS__) +#else +#define DEBUG_MSG(fmt, ...) +#endif typedef int (*rr_callback_t)(const knot_rrset_t *, unsigned, struct kr_layer_param *); diff --git a/lib/layer/stats.c b/lib/layer/stats.c index ccd171c57..bb25b2281 100644 --- a/lib/layer/stats.c +++ b/lib/layer/stats.c @@ -19,7 +19,11 @@ #include "lib/layer/stats.h" #include "lib/rplan.h" +#ifndef NDEBUG #define DEBUG_MSG(fmt, ...) fprintf(stderr, "[stats] " fmt, ## __VA_ARGS__) +#else +#define DEBUG_MSG(fmt, ...) +#endif //static void update_stats(struct kr_ns *ns, double rtt) //{ @@ -38,11 +42,11 @@ static int begin(knot_layer_t *ctx, void *param) static int finish(knot_layer_t *ctx) { +#ifndef NDEBUG struct kr_layer_param *param = ctx->data; struct kr_rplan *rplan = param->rplan; const knot_pkt_t *answer = param->answer; -#ifndef NDEBUG /* Calculate total RTT and number of queries. */ double total_rtt = 0.0; size_t nr_queries = list_size(&rplan->resolved); diff --git a/lib/resolve.c b/lib/resolve.c index 4e415497b..c94288dac 100755 --- a/lib/resolve.c +++ b/lib/resolve.c @@ -29,7 +29,11 @@ #include "lib/layer/static.h" #include "lib/layer/stats.h" +#ifndef NDEBUG #define DEBUG_MSG(fmt, ...) fprintf(stderr, "[reslv] " fmt, ## __VA_ARGS__) +#else +#define DEBUG_MSG(fmt, ...) +#endif /* Defines */ #define ITER_LIMIT 50 diff --git a/lib/rplan.c b/lib/rplan.c index f8a493d90..4b4e76a9f 100644 --- a/lib/rplan.c +++ b/lib/rplan.c @@ -25,7 +25,11 @@ #include "lib/cache.h" #include "lib/utils.h" +#ifndef NDEBUG #define DEBUG_MSG(fmt, ...) fprintf(stderr, "[rplan] " fmt, ## __VA_ARGS__) +#else +#define DEBUG_MSG(fmt, ...) +#endif static struct kr_query *query_create(mm_ctx_t *pool, const knot_dname_t *name) { diff --git a/lib/zonecut.c b/lib/zonecut.c index fb7620255..a2345b345 100644 --- a/lib/zonecut.c +++ b/lib/zonecut.c @@ -23,7 +23,11 @@ #include "lib/utils.h" #include "lib/rplan.h" +#ifndef NDEBUG #define DEBUG_MSG(fmt, ...) fprintf(stderr, "[z-cut] " fmt, ## __VA_ARGS__) +#else +#define DEBUG_MSG(fmt, ...) +#endif /* \brief Root hint descriptor. */ struct hint_info {