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 /include | |
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.
Diffstat (limited to 'include')
-rw-r--r-- | include/nl-aux-core/nl-core.h | 11 |
1 files changed, 3 insertions, 8 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 *); |