Skip to content

Commit

Permalink
utils: always define nl_debug_dp
Browse files Browse the repository at this point in the history
Otherwise, whether libnl-3.so exports nl_debug_dp depends on NL_DEBUG.
That is ugly.

Instead, always define it. It's small anyway.
  • Loading branch information
thom311 committed Apr 22, 2024
1 parent 7eb522e commit 2100a46
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
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);
#if 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);
#if 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
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 */
#if 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 2100a46

Please sign in to comment.