diff options
author | Nikolai Kondrashov <Nikolai.Kondrashov@redhat.com> | 2014-02-12 10:12:04 -0500 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-05-02 10:58:19 +0200 |
commit | b0d759c9a604add0573c04b1a4e88e1605e1fdc0 (patch) | |
tree | 15c83ce34cd254a30cc42c212123b7f194c21677 /src/monitor/monitor_netlink.c | |
parent | b9afd88065ecdb9c2cafb2ee767bd61585b31b8f (diff) | |
download | sssd-b0d759c9a604add0573c04b1a4e88e1605e1fdc0.tar.gz sssd-b0d759c9a604add0573c04b1a4e88e1605e1fdc0.tar.xz sssd-b0d759c9a604add0573c04b1a4e88e1605e1fdc0.zip |
Make DEBUG macro invocations variadic
Use a script to update DEBUG macro invocations to use it as a variadic
macro, supplying format string and its arguments directly, instead of
wrapping them in parens.
This script was used to update the code
(identical to commit a3c8390d19593b1e5277d95bfb4ab206d4785150):
grep -rwl --include '*.[hc]' DEBUG . |
while read f; do
mv "$f"{,.orig}
perl -e \
'use strict;
use File::Slurp;
my $text=read_file(\*STDIN);
$text=~s#(\bDEBUG\s*\([^(]+)\((.*?)\)\s*\)\s*;#$1$2);#gs;
print $text;' < "$f.orig" > "$f"
rm "$f.orig"
done
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
Reviewed-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'src/monitor/monitor_netlink.c')
-rw-r--r-- | src/monitor/monitor_netlink.c | 114 |
1 files changed, 57 insertions, 57 deletions
diff --git a/src/monitor/monitor_netlink.c b/src/monitor/monitor_netlink.c index 6baf13652..24fbed58d 100644 --- a/src/monitor/monitor_netlink.c +++ b/src/monitor/monitor_netlink.c @@ -155,7 +155,7 @@ 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(2, "Could not open socket: [%d] %s\n", ret, strerror(ret)); return false; } @@ -178,10 +178,10 @@ static bool has_ethernet_encapsulation(const char *sysfs_path) ret = snprintf(type_path, SYSFS_TYPE_PATH_MAX, "%s/%s", sysfs_path, TYPE_FILE); if (ret < 0) { - DEBUG(SSSDBG_OP_FAILURE, ("snprintf failed\n")); + DEBUG(SSSDBG_OP_FAILURE, "snprintf failed\n"); return false; } else if (ret >= SYSFS_TYPE_PATH_MAX) { - DEBUG(SSSDBG_OP_FAILURE, ("path too long?!?!\n")); + DEBUG(SSSDBG_OP_FAILURE, "path too long?!?!\n"); return false; } @@ -189,8 +189,8 @@ static bool has_ethernet_encapsulation(const char *sysfs_path) fd = open(type_path, O_RDONLY); if (fd == -1) { ret = errno; - DEBUG(SSSDBG_OP_FAILURE, ("Could not open sysfs file %s: [%d] %s\n", - type_path, ret, strerror(ret))); + DEBUG(SSSDBG_OP_FAILURE, "Could not open sysfs file %s: [%d] %s\n", + type_path, ret, strerror(ret)); return false; } @@ -200,7 +200,7 @@ static bool has_ethernet_encapsulation(const char *sysfs_path) if (ret == -1) { ret = errno; DEBUG(SSSDBG_OP_FAILURE, - ("read failed [%d][%s].\n", ret, strerror(ret))); + "read failed [%d][%s].\n", ret, strerror(ret)); close(fd); return false; } @@ -219,10 +219,10 @@ static bool has_phy_80211_subdir(const char *sysfs_path) ret = snprintf(phy80211_path, SYSFS_SUBDIR_PATH_MAX, "%s/%s", sysfs_path, PHY_80211_SUBDIR); if (ret < 0) { - DEBUG(SSSDBG_OP_FAILURE, ("snprintf failed")); + DEBUG(SSSDBG_OP_FAILURE, "snprintf failed"); return false; } else if (ret >= SYSFS_SUBDIR_PATH_MAX) { - DEBUG(SSSDBG_OP_FAILURE, ("path too long?!?!\n")); + DEBUG(SSSDBG_OP_FAILURE, "path too long?!?!\n"); return false; } @@ -231,18 +231,18 @@ static bool has_phy_80211_subdir(const char *sysfs_path) if (ret == -1) { ret = errno; if (ret == ENOENT || ret == ENOTDIR) { - DEBUG(SSSDBG_TRACE_LIBS, ("No %s directory in sysfs, probably " - "not a wireless interface\n", PHY_80211_SUBDIR)); + DEBUG(SSSDBG_TRACE_LIBS, "No %s directory in sysfs, probably " + "not a wireless interface\n", PHY_80211_SUBDIR); } else { - DEBUG(SSSDBG_OP_FAILURE, ("stat failed: [%d] %s\n", - ret, strerror(ret))); + DEBUG(SSSDBG_OP_FAILURE, "stat failed: [%d] %s\n", + ret, strerror(ret)); } return false; } if (statbuf.st_mode & S_IFDIR) { - DEBUG(SSSDBG_TRACE_LIBS, ("Directory %s found in sysfs, looks like " - "a wireless iface\n", PHY_80211_SUBDIR)); + DEBUG(SSSDBG_TRACE_LIBS, "Directory %s found in sysfs, looks like " + "a wireless iface\n", PHY_80211_SUBDIR); return true; } @@ -256,32 +256,32 @@ static bool discard_iff_up(const char *ifname) /* This catches most of the new 80211 drivers */ if (has_wireless_extension(ifname)) { - DEBUG(SSSDBG_TRACE_FUNC, ("%s has a wireless extension\n", ifname)); + DEBUG(SSSDBG_TRACE_FUNC, "%s has a wireless extension\n", ifname); return true; } ret = snprintf(path, SYSFS_IFACE_PATH_MAX, SYSFS_IFACE_TEMPLATE, ifname); if (ret < 0) { - DEBUG(SSSDBG_OP_FAILURE, ("snprintf failed")); + DEBUG(SSSDBG_OP_FAILURE, "snprintf failed"); return false; } else if (ret >= SYSFS_IFACE_PATH_MAX) { - DEBUG(SSSDBG_OP_FAILURE, ("path too long?!?!\n")); + DEBUG(SSSDBG_OP_FAILURE, "path too long?!?!\n"); return false; } /* This will filter PPP and such. Both wired and wireless * interfaces have the encapsulation. */ if (!has_ethernet_encapsulation(path)) { - DEBUG(SSSDBG_TRACE_FUNC, ("%s does not have ethernet encapsulation, " - "filtering out\n", ifname)); + DEBUG(SSSDBG_TRACE_FUNC, "%s does not have ethernet encapsulation, " + "filtering out\n", ifname); return true; } /* This captures old WEXT drivers, the new mac8011 would * be caught by the ioctl check */ if (has_phy_80211_subdir(path)) { - DEBUG(SSSDBG_TRACE_FUNC, ("%s has a 802_11 subdir, filtering out\n", - ifname)); + DEBUG(SSSDBG_TRACE_FUNC, "%s has a 802_11 subdir, filtering out\n", + ifname); return true; } @@ -303,7 +303,7 @@ static void nladdr_to_string(struct nl_addr *nl, char *buf, size_t bufsize) if (!addr) return; if (inet_ntop(addr_family, addr, buf, bufsize) == NULL) { - DEBUG(SSSDBG_MINOR_FAILURE, ("inet_ntop failed\n")); + DEBUG(SSSDBG_MINOR_FAILURE, "inet_ntop failed\n"); snprintf(buf, bufsize, "unknown"); } } @@ -320,7 +320,7 @@ static bool nlw_accept_message(struct nlw_handle *nlp, uint32_t local_port; if (snl == NULL) { - DEBUG(3, ("Malformed message, skipping\n")); + DEBUG(3, "Malformed message, skipping\n"); return false; } @@ -338,8 +338,8 @@ static bool nlw_accept_message(struct nlw_handle *nlp, } if (accept_msg == false) { - DEBUG(9, ("ignoring netlink message from PID %d", - hdr->nlmsg_pid)); + DEBUG(9, "ignoring netlink message from PID %d", + hdr->nlmsg_pid); } return accept_msg; @@ -352,13 +352,13 @@ static bool nlw_is_addr_object(struct nl_object *obj) filter = rtnl_addr_alloc(); if (!filter) { - DEBUG(SSSDBG_CRIT_FAILURE, ("Allocation error!\n")); + DEBUG(SSSDBG_CRIT_FAILURE, "Allocation error!\n"); is_addr_object = false; } /* Ensure it's an addr object */ if (!nl_object_match_filter(obj, OBJ_CAST(filter))) { - DEBUG(SSSDBG_MINOR_FAILURE, ("Not an addr object\n")); + DEBUG(SSSDBG_MINOR_FAILURE, "Not an addr object\n"); is_addr_object = false; } @@ -373,13 +373,13 @@ static bool nlw_is_route_object(struct nl_object *obj) filter = rtnl_route_alloc(); if (!filter) { - DEBUG(SSSDBG_CRIT_FAILURE, ("Allocation error!\n")); + DEBUG(SSSDBG_CRIT_FAILURE, "Allocation error!\n"); is_route_object = false; } /* Ensure it's a route object */ if (!nl_object_match_filter(obj, OBJ_CAST(filter))) { - DEBUG(SSSDBG_MINOR_FAILURE, ("Not a route object\n")); + DEBUG(SSSDBG_MINOR_FAILURE, "Not a route object\n"); is_route_object = false; } @@ -394,13 +394,13 @@ static bool nlw_is_link_object(struct nl_object *obj) filter = rtnl_link_alloc(); if (!filter) { - DEBUG(0, ("Allocation error!\n")); + DEBUG(0, "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(2, "Not a link object\n"); is_link_object = false; } @@ -427,7 +427,7 @@ static int nlw_group_subscribe(struct nlw_handle *nlp, int group) ret = nl_socket_add_membership(nlp, group); if (ret != 0) { DEBUG(SSSDBG_CRIT_FAILURE, - ("Unable to add membership: %s\n", nlw_geterror(ret))); + "Unable to add membership: %s\n", nlw_geterror(ret)); return ret; } #else @@ -438,7 +438,7 @@ 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(1, "setsockopt failed (%d): %s\n", ret, strerror(ret)); return ret; } #endif @@ -473,8 +473,8 @@ static int event_msg_recv(struct nl_msg *msg, void *arg) creds = nlmsg_get_creds(msg); if (!creds || creds->uid != 0) { DEBUG(SSSDBG_TRACE_ALL, - ("Ignoring netlink message from UID %"SPRIuid, - creds ? creds->uid : (uid_t)-1)); + "Ignoring netlink message from UID %"SPRIuid, + creds ? creds->uid : (uid_t)-1); return NL_SKIP; } @@ -494,7 +494,7 @@ static void addr_msg_handler(struct nl_object *obj, void *arg); static enum nlw_msg_type message_type(struct nlmsghdr *hdr) { - DEBUG(SSSDBG_FUNC_DATA, ("netlink Message type: %d\n", hdr->nlmsg_type)); + DEBUG(SSSDBG_FUNC_DATA, "netlink Message type: %d\n", hdr->nlmsg_type); switch (hdr->nlmsg_type) { /* network interface added */ case RTM_NEWLINK: @@ -548,7 +548,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(1, "Unable to set validation callback\n"); return ret; } @@ -559,7 +559,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(1, "Unable to set receive callback\n"); return ret; } @@ -581,9 +581,9 @@ static void route_msg_debug_print(struct rtnl_route *route_obj) prefixlen = 0; } - DEBUG(SSSDBG_TRACE_LIBS, ("route idx %d flags %#X family %d addr %s/%d\n", + DEBUG(SSSDBG_TRACE_LIBS, "route idx %d flags %#X family %d addr %s/%d\n", rtnlw_route_get_oif(route_obj), rtnl_route_get_flags(route_obj), - rtnl_route_get_family(route_obj), buf, prefixlen)); + rtnl_route_get_family(route_obj), buf, prefixlen); } @@ -600,7 +600,7 @@ static bool route_is_multicast(struct rtnl_route *route_obj) nl = rtnl_route_get_dst(route_obj); if (!nl) { - DEBUG(SSSDBG_MINOR_FAILURE, ("A route with no destination?\n")); + DEBUG(SSSDBG_MINOR_FAILURE, "A route with no destination?\n"); return false; } @@ -620,7 +620,7 @@ static bool route_is_multicast(struct rtnl_route *route_obj) return IN6_IS_ADDR_MULTICAST(addr6); } - DEBUG(SSSDBG_MINOR_FAILURE, ("Unknown route address family\n")); + DEBUG(SSSDBG_MINOR_FAILURE, "Unknown route address family\n"); return false; } @@ -635,7 +635,7 @@ static void route_msg_handler(struct nl_object *obj, void *arg) if (route_is_multicast(route_obj)) { DEBUG(SSSDBG_TRACE_INTERNAL, - ("Discarding multicast route message\n")); + "Discarding multicast route message\n"); return; } @@ -661,8 +661,8 @@ static void addr_msg_debug_print(struct rtnl_addr *addr_obj) rtnl_addr_flags2str(flags, str_flags, 512); nladdr_to_string(local_addr, buf, INET6_ADDRSTRLEN); - DEBUG(SSSDBG_TRACE_LIBS, ("netlink addr message: iface idx %u " - "addr %s flags 0x%X (%s)\n", ifidx, buf, flags, str_flags)); + DEBUG(SSSDBG_TRACE_LIBS, "netlink addr message: iface idx %u " + "addr %s flags 0x%X (%s)\n", ifidx, buf, flags, str_flags); } static void addr_msg_handler(struct nl_object *obj, void *arg) @@ -698,8 +698,8 @@ static void link_msg_handler(struct nl_object *obj, void *arg) rtnl_link_flags2str(flags, str_flags, 512); ifname = rtnl_link_get_name(link_obj); - DEBUG(SSSDBG_TRACE_LIBS, ("netlink link message: iface idx %u (%s) " - "flags 0x%X (%s)\n", ifidx, ifname, flags, str_flags)); + DEBUG(SSSDBG_TRACE_LIBS, "netlink link message: iface idx %u (%s) " + "flags 0x%X (%s)\n", ifidx, ifname, flags, str_flags); /* IFF_LOWER_UP is the indicator of carrier status */ if ((flags & IFF_RUNNING) && (flags & IFF_LOWER_UP) && @@ -715,13 +715,13 @@ 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(1, "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(1, "Error while reading from netlink fd\n"); return; } } @@ -751,8 +751,8 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, /* allocate the libnl handle/socket and register the default filter set */ nlctx->nlp = nlw_alloc(); if (!nlctx->nlp) { - DEBUG(SSSDBG_CRIT_FAILURE, (("unable to allocate netlink handle: %s"), - nlw_geterror(ENOMEM))); + DEBUG(SSSDBG_CRIT_FAILURE, ("unable to allocate netlink handle: %s"), + nlw_geterror(ENOMEM)); ret = ENOMEM; goto fail; } @@ -760,7 +760,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(1, "Unable to set callbacks\n"); ret = EIO; goto fail; } @@ -769,7 +769,7 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, ret = nl_connect(nlctx->nlp, NETLINK_ROUTE); if (ret != 0) { DEBUG(SSSDBG_CRIT_FAILURE, - ("Unable to connect to netlink: %s\n", nlw_geterror(ret))); + "Unable to connect to netlink: %s\n", nlw_geterror(ret)); ret = EIO; goto fail; } @@ -777,7 +777,7 @@ int setup_netlink(TALLOC_CTX *mem_ctx, struct tevent_context *ev, ret = nlw_enable_passcred(nlctx->nlp); if (ret != 0) { DEBUG(SSSDBG_CRIT_FAILURE, - ("Cannot enable credential passing: %s\n", nlw_geterror(ret))); + "Cannot enable credential passing: %s\n", nlw_geterror(ret)); ret = EIO; goto fail; } @@ -785,7 +785,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(1, "Unable to subscribe to netlink monitor\n"); ret = EIO; goto fail; } @@ -799,14 +799,14 @@ 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(1, "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(1, "tevent_add_fd() failed\n"); ret = EIO; goto fail; } |