diff options
author | Thomas Haller <thaller@redhat.com> | 2024-04-22 07:13:24 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2024-04-22 08:30:03 (GMT) |
commit | dbe21b8d64cdfd38476cddee0bb766fa7d4a7c3c (patch) | |
tree | 957fafa052367e50a3c8a1bb625dc637e0452980 | |
parent | e592dd89f1d6a6613b2ca37434ad568da0998b19 (diff) | |
download | libnl-dbe21b8d64cdfd38476cddee0bb766fa7d4a7c3c.zip libnl-dbe21b8d64cdfd38476cddee0bb766fa7d4a7c3c.tar.gz libnl-dbe21b8d64cdfd38476cddee0bb766fa7d4a7c3c.tar.bz2 |
core: always define statements for NL_DBG()
Conditionally defining to nothing, means that the compiler doesn't see
the print statement without NL_DEBUG. In turn, we lack checking of the
statement by the compiler.
Instead, add an "if (NL_DEBUG)" around it. Since NL_DEBUG is a constant, the
compiler will optimize out all the code of the statement, while still
checking it.
-rw-r--r-- | include/nl-aux-core/nl-core.h | 11 | ||||
-rw-r--r-- | lib/route/neigh.c | 2 | ||||
-rw-r--r-- | lib/route/route_obj.c | 4 |
3 files changed, 3 insertions, 14 deletions
diff --git a/include/nl-aux-core/nl-core.h b/include/nl-aux-core/nl-core.h index c6bdbeb..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" -#if 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/route/neigh.c b/lib/route/neigh.c index 1f19fed..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; -#if 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 488cff5..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; -#if 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; -#if NL_DEBUG char buf[INET6_ADDRSTRLEN+5]; -#endif /* * ipv6 ECMP route notifications from the kernel come as |