From 83bf46f4066e3d5e838a32357c201de9bd6ecdfd Mon Sep 17 00:00:00 2001 From: Nikolai Kondrashov Date: Wed, 12 Feb 2014 10:12:59 -0500 Subject: Update DEBUG* invocations to use new levels Use a script to update DEBUG* macro invocations, which use literal numbers for levels, to use bitmask macros instead: grep -rl --include '*.[hc]' DEBUG . | while read f; do mv "$f"{,.orig} perl -e 'use strict; use File::Slurp; my @map=qw" SSSDBG_FATAL_FAILURE SSSDBG_CRIT_FAILURE SSSDBG_OP_FAILURE SSSDBG_MINOR_FAILURE SSSDBG_CONF_SETTINGS SSSDBG_FUNC_DATA SSSDBG_TRACE_FUNC SSSDBG_TRACE_LIBS SSSDBG_TRACE_INTERNAL SSSDBG_TRACE_ALL "; my $text=read_file(\*STDIN); my $repl; $text=~s/ ^ ( .* \b (DEBUG|DEBUG_PAM_DATA|DEBUG_GR_MEM) \s* \(\s* )( [0-9] )( \s*, ) ( \s* ) ( .* ) $ / $repl = $1.$map[$3].$4.$5.$6, length($repl) <= 80 ? $repl : $1.$map[$3].$4."\n".(" " x length($1)).$6 /xmge; print $text; ' < "$f.orig" > "$f" rm "$f.orig" done Reviewed-by: Jakub Hrozek Reviewed-by: Stephen Gallagher Reviewed-by: Simo Sorce --- src/monitor/monitor_netlink.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src/monitor/monitor_netlink.c') diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c index 24fbed58d..b4d636191 100644 --- a/src/monitor/monitor_netlink.c +++ b/src/monitor/monitor_netlink.c @@ -155,7 +155,8 @@ static bool has_wireless_extension(const char *ifname) s = socket(PF_INET, SOCK_DGRAM, 0); if (s == -1) { ret = errno; - DEBUG(2, "Could not open socket: [%d] %s\n", ret, strerror(ret)); + DEBUG(SSSDBG_OP_FAILURE, + "Could not open socket: [%d] %s\n", ret, strerror(ret)); return false; } @@ -320,7 +321,7 @@ static bool nlw_accept_message(struct nlw_handle *nlp, uint32_t local_port; if (snl == NULL) { - DEBUG(3, "Malformed message, skipping\n"); + DEBUG(SSSDBG_MINOR_FAILURE, "Malformed message, skipping\n"); return false; } @@ -338,7 +339,7 @@ static bool nlw_accept_message(struct nlw_handle *nlp, } if (accept_msg == false) { - DEBUG(9, "ignoring netlink message from PID %d", + DEBUG(SSSDBG_TRACE_ALL, "ignoring netlink message from PID %d", hdr->nlmsg_pid); } @@ -394,13 +395,13 @@ static bool nlw_is_link_object(struct nl_object *obj) filter = rtnl_link_alloc(); if (!filter) { - DEBUG(0, "Allocation error!\n"); + DEBUG(SSSDBG_FATAL_FAILURE, "Allocation error!\n"); is_link_object = false; } /* Ensure it's a link object */ if (!nl_object_match_filter(obj, OBJ_CAST(filter))) { - DEBUG(2, "Not a link object\n"); + DEBUG(SSSDBG_OP_FAILURE, "Not a link object\n"); is_link_object = false; } @@ -438,7 +439,8 @@ static int nlw_group_subscribe(struct nlw_handle *nlp, int group) &group, sizeof(group)); if (ret < 0) { ret = errno; - DEBUG(1, "setsockopt failed (%d): %s\n", ret, strerror(ret)); + DEBUG(SSSDBG_CRIT_FAILURE, + "setsockopt failed (%d): %s\n", ret, strerror(ret)); return ret; } #endif @@ -548,7 +550,7 @@ static int nlw_set_callbacks(struct nlw_handle *nlp, void *data) ret = nl_cb_set(cb, NL_CB_MSG_IN, NL_CB_CUSTOM, event_msg_recv, data); #endif if (ret != 0) { - DEBUG(1, "Unable to set validation callback\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set validation callback\n"); return ret; } @@ -559,7 +561,7 @@ static int nlw_set_callbacks(struct nlw_handle *nlp, void *data) ret = nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, event_msg_ready, data); #endif if (ret != 0) { - DEBUG(1, "Unable to set receive callback\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set receive callback\n"); return ret; } @@ -715,13 +717,14 @@ static void netlink_fd_handler(struct tevent_context *ev, struct tevent_fd *fde, int ret; if (!nlctx || !nlctx->nlp) { - DEBUG(1, "Invalid netlink handle, this is most likely a bug!\n"); + DEBUG(SSSDBG_CRIT_FAILURE, + "Invalid netlink handle, this is most likely a bug!\n"); return; } ret = nl_recvmsgs_default(nlctx->nlp); if (ret != EOK) { - DEBUG(1, "Error while reading from netlink fd\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Error while reading from netlink fd\n"); return; } } @@ -760,7 +763,7 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, /* Register our custom message validation filter */ ret = nlw_set_callbacks(nlctx->nlp, nlctx); if (ret != 0) { - DEBUG(1, "Unable to set callbacks\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set callbacks\n"); ret = EIO; goto fail; } @@ -785,7 +788,7 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, /* Subscribe to the LINK group for internal carrier signals */ ret = nlw_groups_subscribe(nlctx->nlp, groups); if (ret != 0) { - DEBUG(1, "Unable to subscribe to netlink monitor\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "Unable to subscribe to netlink monitor\n"); ret = EIO; goto fail; } @@ -799,14 +802,15 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, ret = fcntl(nlfd, F_SETFL, flags | O_NONBLOCK); if (ret < 0) { ret = errno; - DEBUG(1, "Cannot set the netlink fd to nonblocking\n"); + DEBUG(SSSDBG_CRIT_FAILURE, + "Cannot set the netlink fd to nonblocking\n"); goto fail; } nlctx->tefd = tevent_add_fd(ev, nlctx, nlfd, TEVENT_FD_READ, netlink_fd_handler, nlctx); if (nlctx->tefd == NULL) { - DEBUG(1, "tevent_add_fd() failed\n"); + DEBUG(SSSDBG_CRIT_FAILURE, "tevent_add_fd() failed\n"); ret = EIO; goto fail; } -- cgit