Skip to content

Commit

Permalink
all: merge branch 'th/nl-debug'
Browse files Browse the repository at this point in the history
  • Loading branch information
thom311 committed Apr 22, 2024
2 parents 5873497 + 13ab012 commit 96ddcd9
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 27 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 6 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
11 changes: 3 additions & 8 deletions include/nl-aux-core/nl-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down
10 changes: 4 additions & 6 deletions lib/cache_mngr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 0 additions & 2 deletions lib/route/neigh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions lib/route/route_obj.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -61,15 +60,14 @@ 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;
}

nl_debug_dp.dp_fd = stderr;
}
#endif

int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *))
{
Expand Down

0 comments on commit 96ddcd9

Please sign in to comment.