Skip to content

Commit

Permalink
Use NL_DBG() instead of printing warnings and errors to stderr
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Graf <tgraf@suug.ch>
  • Loading branch information
tgraf committed Nov 15, 2012
1 parent 235aa7f commit 23c4ef6
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions include/netlink-local.h
Expand Up @@ -86,16 +86,16 @@ struct trans_list {
fprintf(stderr, "DBG<" #LVL ">: " FMT, ##ARG); \
} while (0)

#define BUG() \
do { \
fprintf(stderr, "BUG: %s:%d\n", \
__FILE__, __LINE__); \
assert(0); \
#define BUG() \
do { \
NL_DBG(1, "BUG: %s:%d\n", \
__FILE__, __LINE__); \
assert(0); \
} while (0)

#define APPBUG(msg) \
do { \
fprintf(stderr, "APPLICATION BUG: %s:%d:%s: %s\n", \
NL_DBG(1, "APPLICATION BUG: %s:%d:%s: %s\n", \
__FILE__, __LINE__, __PRETTY_FUNCTION__, msg); \
assert(0); \
} while(0)
Expand Down
4 changes: 2 additions & 2 deletions lib/attr.c
Expand Up @@ -253,7 +253,7 @@ int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
int type = nla_type(nla);

if (type == 0) {
fprintf(stderr, "Illegal nla->nla_type == 0\n");
NL_DBG(1, "Illegal nla->nla_type == 0\n");
continue;
}

Expand All @@ -269,7 +269,7 @@ int nla_parse(struct nlattr *tb[], int maxtype, struct nlattr *head, int len,
}

if (rem > 0)
fprintf(stderr, "netlink: %d bytes leftover after parsing "
NL_DBG(1, "netlink: %d bytes leftover after parsing "
"attributes.\n", rem);

err = 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/cache.c
Expand Up @@ -925,7 +925,7 @@ int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)

err = nl_cache_pickup(sk, cache);
if (err == -NLE_DUMP_INTR) {
fprintf(stderr, "dump interrupted, restarting!\n");
NL_DBG(1, "dump interrupted, restarting!\n");
goto restart;
} else if (err < 0)
break;
Expand Down
8 changes: 4 additions & 4 deletions lib/cache_mngt.c
Expand Up @@ -404,10 +404,10 @@ struct nl_cache *nl_cache_mngt_require(const char *name)
struct nl_cache *cache;

if (!(cache = __nl_cache_mngt_require(name)))
fprintf(stderr, "Application BUG: Your application must "
"call nl_cache_mngt_provide() and\nprovide a valid "
"%s cache to be used for internal lookups.\nSee the "
" API documentation for more details.\n", name);
NL_DBG(1, "Application BUG: Your application must "
"call nl_cache_mngt_provide() and\nprovide a valid "
"%s cache to be used for internal lookups.\nSee the "
" API documentation for more details.\n", name);

return cache;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/route/classid.c
Expand Up @@ -441,7 +441,7 @@ static void __init classid_init(void)
nl_init_list_head(&tbl_name[i]);

if ((err = rtnl_tc_read_classid_file()) < 0)
fprintf(stderr, "Failed to read classid file: %s\n", nl_geterror(err));
NL_DBG(1, "Failed to read classid file: %s\n", nl_geterror(err));
}

static void free_map(void *map) {
Expand Down
2 changes: 1 addition & 1 deletion lib/utils.c
Expand Up @@ -426,7 +426,7 @@ static void __init get_psched_settings(void)

if (fscanf(fd, "%08x %08x %08x %08x",
&ns_per_usec, &ns_per_tick, &nom, &denom) != 4) {
fprintf(stderr, "Fatal error: can not read psched settings from \"%s\". " \
NL_DBG(1, "Fatal error: can not read psched settings from \"%s\". " \
"Try to set TICKS_PER_USEC, PROC_NET_PSCHED or PROC_ROOT " \
"environment variables\n", name);
exit(1);
Expand Down

0 comments on commit 23c4ef6

Please sign in to comment.