summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2024-04-22 08:32:10 (GMT)
committerThomas Haller <thaller@redhat.com>2024-04-22 08:32:10 (GMT)
commit96ddcd999297d8697235e75417bda8a66e26bb0f (patch)
tree69e9f401f4a99f0b57c3cc007a959fd1ff8741dd
parent5873497482022167393f3e193d187340df4acf99 (diff)
parent13ab0122fc38462d16b2aa920167220ca196f15d (diff)
downloadlibnl-96ddcd999297d8697235e75417bda8a66e26bb0f.zip
libnl-96ddcd999297d8697235e75417bda8a66e26bb0f.tar.gz
libnl-96ddcd999297d8697235e75417bda8a66e26bb0f.tar.bz2
all: merge branch 'th/nl-debug'
-rw-r--r--.github/workflows/ci.yml4
-rw-r--r--configure.ac9
-rw-r--r--include/nl-aux-core/nl-core.h11
-rw-r--r--lib/cache_mngr.c10
-rw-r--r--lib/route/neigh.c2
-rw-r--r--lib/route/route_obj.c4
-rw-r--r--lib/utils.c4
7 files changed, 17 insertions, 27 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 708928e..25bb0b9 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 bc8b390..cce0ad0 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 5b34bcb..5198296 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 f16882f..7b2a9bd 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 9150024..7e698b4 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 ce68259..5077593 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 4f5fd1a..471cd21 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 *))
{