From 2100a469f5e47586e070f14079b25051d5065076 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 22 Apr 2024 09:39:40 +0200 Subject: [PATCH] utils: always define nl_debug_dp Otherwise, whether libnl-3.so exports nl_debug_dp depends on NL_DEBUG. That is ugly. Instead, always define it. It's small anyway. --- lib/cache_mngr.c | 10 ++++------ lib/utils.c | 4 +--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c index 0caf10d1..7b2a9bd3 100644 --- a/lib/cache_mngr.c +++ b/lib/cache_mngr.c @@ -58,10 +58,9 @@ static int include_cb(struct nl_object *obj, struct nl_parser_param *p) struct nl_cache_ops *ops = ca->ca_cache->c_ops; NL_DBG(2, "Including object %p into cache %p\n", obj, ca->ca_cache); -#if NL_DEBUG - if (nl_debug >= 4) + + if (NL_DEBUG && nl_debug >= 4) nl_object_dump(obj, &nl_debug_dp); -#endif if (ops->co_event_filter) if (ops->co_event_filter(ca->ca_cache, obj) != NL_OK) @@ -93,10 +92,9 @@ static int event_input(struct nl_msg *msg, void *arg) NL_DBG(2, "Cache manager %p, handling new message %p as event\n", mngr, msg); -#if NL_DEBUG - if (nl_debug >= 4) + + if (NL_DEBUG && nl_debug >= 4) nl_msg_dump(msg, stderr); -#endif if (mngr->cm_protocol != protocol) BUG(); diff --git a/lib/utils.c b/lib/utils.c index 2363c027..471cd21a 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -52,7 +52,6 @@ int nl_debug = 0; /** @cond SKIP */ -#if NL_DEBUG struct nl_dump_params nl_debug_dp = { .dp_type = NL_DUMP_DETAILS, }; @@ -61,7 +60,7 @@ static void _nl_init nl_debug_init(void) { char *nldbg, *end; - if ((nldbg = getenv("NLDBG"))) { + if (NL_DEBUG && (nldbg = getenv("NLDBG"))) { long level = strtol(nldbg, &end, 0); if (nldbg != end) nl_debug = level; @@ -69,7 +68,6 @@ static void _nl_init nl_debug_init(void) nl_debug_dp.dp_fd = stderr; } -#endif int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *)) {