diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 708928e9..25bb0b9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,15 +71,17 @@ jobs: export CC="${{ matrix.cc }}" export CFLAGS="-DNL_MORE_ASSERTS=1000 -O2 -Werror -Wall -Wdeclaration-after-statement -Wvla -std=gnu11 -fexceptions" + CONFIGURE_ARGS= if [ "$CC" = "clang" ]; then CFLAGS="$CFLAGS -Wno-error=unused-command-line-argument -Wno-error=unused-function" export LDFLAGS="-Wl,--no-undefined-version,--fatal-warnings" + CONFIGURE_ARGS="--enable-debug=no" else export LDFLAGS="-Wl,--no-undefined-version" fi ./autogen.sh - ./configure + ./configure $CONFIGURE_ARGS make -j 5 shell: bash diff --git a/configure.ac b/configure.ac index bc8b3908..cce0ad0b 100644 --- a/configure.ac +++ b/configure.ac @@ -110,10 +110,13 @@ fi AM_CONDITIONAL([ENABLE_STATIC], [test "$enable_static" != "no"]) AC_ARG_ENABLE([debug], - AS_HELP_STRING([--disable-debug], [Do not include debugging statements]), - [enable_debug="$enableval"], [enable_debug="yes"]) -if test "x$enable_debug" = "xyes"; then + AS_HELP_STRING([--disable-debug], [Do not include debugging statements]), + [enable_debug="$enableval"], [enable_debug="yes"]) +if test "$enable_debug" = "yes"; then AC_DEFINE([NL_DEBUG], [1], [Define to 1 to enable debugging]) +else + enable_debug=no + AC_DEFINE([NL_DEBUG], [0], [Define to 1 to enable debugging]) fi AC_CONFIG_SUBDIRS([doc]) diff --git a/include/nl-aux-core/nl-core.h b/include/nl-aux-core/nl-core.h index 5b34bcb0..5198296f 100644 --- a/include/nl-aux-core/nl-core.h +++ b/include/nl-aux-core/nl-core.h @@ -5,21 +5,16 @@ #include "base/nl-base-utils.h" -#ifdef NL_DEBUG #define NL_DBG(LVL, FMT, ARG...) \ do { \ - if (LVL <= nl_debug) { \ - int _errsv = errno; \ + if ((NL_DEBUG) && (LVL) <= nl_debug) { \ + const int _errsv = errno; \ + \ fprintf(stderr, "DBG<" #LVL ">%20s:%-4u %s: " FMT, \ __FILE__, __LINE__, __func__, ##ARG); \ errno = _errsv; \ } \ } while (0) -#else /* NL_DEBUG */ -#define NL_DBG(LVL, FMT, ARG...) \ - do { \ - } while (0) -#endif /* NL_DEBUG */ struct nl_addr; void nl_addr_put(struct nl_addr *); diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c index f16882f7..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); -#ifdef 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); -#ifdef 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/route/neigh.c b/lib/route/neigh.c index 91500244..7e698b49 100644 --- a/lib/route/neigh.c +++ b/lib/route/neigh.c @@ -242,9 +242,7 @@ static void neigh_keygen(struct nl_object *obj, uint32_t *hashkey, uint16_t n_vlan; char n_addr[0]; } _nl_packed *nkey; -#ifdef NL_DEBUG char buf[INET6_ADDRSTRLEN+5]; -#endif if (neigh->n_family == AF_BRIDGE) { if (neigh->n_lladdr) diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index ce68259c..50775937 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -345,9 +345,7 @@ static void route_keygen(struct nl_object *obj, uint32_t *hashkey, uint32_t rt_prio; char rt_addr[0]; } _nl_packed *rkey = NULL; -#ifdef NL_DEBUG char buf[INET6_ADDRSTRLEN+5]; -#endif if (route->rt_dst) addr = route->rt_dst; @@ -502,9 +500,7 @@ static int route_update(struct nl_object *old_obj, struct nl_object *new_obj) struct rtnl_route *old_route = (struct rtnl_route *) old_obj; struct rtnl_nexthop *new_nh; int action = new_obj->ce_msgtype; -#ifdef NL_DEBUG char buf[INET6_ADDRSTRLEN+5]; -#endif /* * ipv6 ECMP route notifications from the kernel come as diff --git a/lib/utils.c b/lib/utils.c index 4f5fd1aa..471cd21a 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -52,7 +52,6 @@ int nl_debug = 0; /** @cond SKIP */ -#ifdef 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 *)) {