diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 11:58:34 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 12:04:41 +0100 |
commit | 0a1beeb64207eaa88ab9236787b1cbc2f704ae14 (patch) | |
tree | 50117277be2e2078d0373b944a30b4f09bb94443 /src/network | |
parent | b4d23205f238e06aaa31264628e20669e714acad (diff) |
treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'
Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
Diffstat (limited to 'src/network')
-rw-r--r-- | src/network/networkctl.c | 10 | ||||
-rw-r--r-- | src/network/networkd-address.c | 20 | ||||
-rw-r--r-- | src/network/networkd-manager.c | 4 | ||||
-rw-r--r-- | src/network/networkd-netdev-veth.c | 2 | ||||
-rw-r--r-- | src/network/networkd-netdev.c | 2 | ||||
-rw-r--r-- | src/network/networkd-network.c | 2 | ||||
-rw-r--r-- | src/network/networkd-route.c | 36 | ||||
-rw-r--r-- | src/network/networkd-wait-online-manager.c | 4 | ||||
-rw-r--r-- | src/network/networkd-wait-online.c | 4 | ||||
-rw-r--r-- | src/network/networkd.c | 16 |
10 files changed, 50 insertions, 50 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c index b374121fbc..3e21d9acb8 100644 --- a/src/network/networkctl.c +++ b/src/network/networkctl.c @@ -191,7 +191,7 @@ static int list_links(char **args, unsigned n) { r = sd_rtnl_open(&rtnl, 0); if (r < 0) { - log_error("Failed to connect to netlink: %s", strerror(-r)); + log_error_errno(-r, "Failed to connect to netlink: %m"); return r; } @@ -211,7 +211,7 @@ static int list_links(char **args, unsigned n) { r = sd_rtnl_call(rtnl, req, 0, &reply); if (r < 0) { - log_error("Failed to enumerate links: %s", strerror(-r)); + log_error_errno(-r, "Failed to enumerate links: %m"); return r; } @@ -323,7 +323,7 @@ static int link_status_one(sd_rtnl *rtnl, struct udev *udev, const char *name) { r = sd_rtnl_call(rtnl, req, 0, &reply); if (r < 0) { - log_error("Failed to query link: %s", strerror(-r)); + log_error_errno(-r, "Failed to query link: %m"); return r; } @@ -448,7 +448,7 @@ static int link_status(char **args, unsigned n) { r = sd_rtnl_open(&rtnl, 0); if (r < 0) { - log_error("Failed to connect to netlink: %s", strerror(-r)); + log_error_errno(-r, "Failed to connect to netlink: %m"); return r; } @@ -514,7 +514,7 @@ static int link_status(char **args, unsigned n) { r = sd_rtnl_call(rtnl, req, 0, &reply); if (r < 0) { - log_error("Failed to enumerate links: %s", strerror(-r)); + log_error_errno(-r, "Failed to enumerate links: %m"); return r; } diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index cf49909858..b85044d292 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -125,7 +125,7 @@ int address_drop(Address *address, Link *link, r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen); if (r < 0) { - log_error("Could not set prefixlen: %s", strerror(-r)); + log_error_errno(-r, "Could not set prefixlen: %m"); return r; } @@ -141,7 +141,7 @@ int address_drop(Address *address, Link *link, r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL); if (r < 0) { - log_error("Could not send rtnetlink message: %s", strerror(-r)); + log_error_errno(-r, "Could not send rtnetlink message: %m"); return r; } @@ -171,19 +171,19 @@ int address_update(Address *address, Link *link, r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen); if (r < 0) { - log_error("Could not set prefixlen: %s", strerror(-r)); + log_error_errno(-r, "Could not set prefixlen: %m"); return r; } r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT); if (r < 0) { - log_error("Could not set flags: %s", strerror(-r)); + log_error_errno(-r, "Could not set flags: %m"); return r; } r = sd_rtnl_message_addr_set_scope(req, address->scope); if (r < 0) { - log_error("Could not set scope: %s", strerror(-r)); + log_error_errno(-r, "Could not set scope: %m"); return r; } @@ -224,7 +224,7 @@ int address_update(Address *address, Link *link, r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL); if (r < 0) { - log_error("Could not send rtnetlink message: %s", strerror(-r)); + log_error_errno(-r, "Could not send rtnetlink message: %m"); return r; } @@ -320,19 +320,19 @@ int address_configure(Address *address, Link *link, r = sd_rtnl_message_addr_set_prefixlen(req, address->prefixlen); if (r < 0) { - log_error("Could not set prefixlen: %s", strerror(-r)); + log_error_errno(-r, "Could not set prefixlen: %m"); return r; } r = sd_rtnl_message_addr_set_flags(req, IFA_F_PERMANENT); if (r < 0) { - log_error("Could not set flags: %s", strerror(-r)); + log_error_errno(-r, "Could not set flags: %m"); return r; } r = sd_rtnl_message_addr_set_scope(req, address->scope); if (r < 0) { - log_error("Could not set scope: %s", strerror(-r)); + log_error_errno(-r, "Could not set scope: %m"); return r; } @@ -386,7 +386,7 @@ int address_configure(Address *address, Link *link, r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL); if (r < 0) { - log_error("Could not send rtnetlink message: %s", strerror(-r)); + log_error_errno(-r, "Could not send rtnetlink message: %m"); return r; } diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c index 6046dc7d62..e2190b591e 100644 --- a/src/network/networkd-manager.c +++ b/src/network/networkd-manager.c @@ -357,7 +357,7 @@ int manager_udev_listen(Manager *m) { r = udev_monitor_filter_add_match_subsystem_devtype(m->udev_monitor, "net", NULL); if (r < 0) { - log_error("Could not add udev monitor filter: %s", strerror(-r)); + log_error_errno(-r, "Could not add udev monitor filter: %m"); return r; } @@ -597,7 +597,7 @@ int manager_save(Manager *m) { return 0; fail: - log_error("Failed to save network state to %s: %s", m->state_file, strerror(-r)); + log_error_errno(-r, "Failed to save network state to %s: %m", m->state_file); unlink(m->state_file); unlink(temp_path); return r; diff --git a/src/network/networkd-netdev-veth.c b/src/network/networkd-netdev-veth.c index 859c26e931..ed43e1b2a9 100644 --- a/src/network/networkd-netdev-veth.c +++ b/src/network/networkd-netdev-veth.c @@ -47,7 +47,7 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m if (v->ifname_peer) { r = sd_rtnl_message_append_string(m, IFLA_IFNAME, v->ifname_peer); if (r < 0) { - log_error("Failed to add netlink interface name: %s", strerror(-r)); + log_error_errno(-r, "Failed to add netlink interface name: %m"); return r; } } diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c index 310b20ae3e..071ca4dcc5 100644 --- a/src/network/networkd-netdev.c +++ b/src/network/networkd-netdev.c @@ -744,7 +744,7 @@ int netdev_load(Manager *manager) { r = conf_files_list_strv(&files, ".netdev", NULL, network_dirs); if (r < 0) { - log_error("Failed to enumerate netdev files: %s", strerror(-r)); + log_error_errno(-r, "Failed to enumerate netdev files: %m"); return r; } diff --git a/src/network/networkd-network.c b/src/network/networkd-network.c index aad99236c4..79b8e75eba 100644 --- a/src/network/networkd-network.c +++ b/src/network/networkd-network.c @@ -132,7 +132,7 @@ int network_load(Manager *manager) { r = conf_files_list_strv(&files, ".network", NULL, network_dirs); if (r < 0) { - log_error("Failed to enumerate network files: %s", strerror(-r)); + log_error_errno(-r, "Failed to enumerate network files: %m"); return r; } diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c index 82c9e002fd..6db1bcffbd 100644 --- a/src/network/networkd-route.c +++ b/src/network/networkd-route.c @@ -114,7 +114,7 @@ int route_drop(Route *route, Link *link, RTM_DELROUTE, route->family, route->protocol); if (r < 0) { - log_error("Could not create RTM_DELROUTE message: %s", strerror(-r)); + log_error_errno(-r, "Could not create RTM_DELROUTE message: %m"); return r; } @@ -124,7 +124,7 @@ int route_drop(Route *route, Link *link, else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6); if (r < 0) { - log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_GATEWAY attribute: %m"); return r; } } @@ -135,13 +135,13 @@ int route_drop(Route *route, Link *link, else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_DST, &route->dst_addr.in6); if (r < 0) { - log_error("Could not append RTA_DST attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_DST attribute: %m"); return r; } r = sd_rtnl_message_route_set_dst_prefixlen(req, route->dst_prefixlen); if (r < 0) { - log_error("Could not set destination prefix length: %s", strerror(-r)); + log_error_errno(-r, "Could not set destination prefix length: %m"); return r; } } @@ -152,32 +152,32 @@ int route_drop(Route *route, Link *link, else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6); if (r < 0) { - log_error("Could not append RTA_PREFSRC attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_PREFSRC attribute: %m"); return r; } } r = sd_rtnl_message_route_set_scope(req, route->scope); if (r < 0) { - log_error("Could not set scope: %s", strerror(-r)); + log_error_errno(-r, "Could not set scope: %m"); return r; } r = sd_rtnl_message_append_u32(req, RTA_PRIORITY, route->metrics); if (r < 0) { - log_error("Could not append RTA_PRIORITY attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_PRIORITY attribute: %m"); return r; } r = sd_rtnl_message_append_u32(req, RTA_OIF, link->ifindex); if (r < 0) { - log_error("Could not append RTA_OIF attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_OIF attribute: %m"); return r; } r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL); if (r < 0) { - log_error("Could not send rtnetlink message: %s", strerror(-r)); + log_error_errno(-r, "Could not send rtnetlink message: %m"); return r; } @@ -201,7 +201,7 @@ int route_configure(Route *route, Link *link, RTM_NEWROUTE, route->family, route->protocol); if (r < 0) { - log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r)); + log_error_errno(-r, "Could not create RTM_NEWROUTE message: %m"); return r; } @@ -211,7 +211,7 @@ int route_configure(Route *route, Link *link, else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_GATEWAY, &route->in_addr.in6); if (r < 0) { - log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_GATEWAY attribute: %m"); return r; } } @@ -222,13 +222,13 @@ int route_configure(Route *route, Link *link, else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_DST, &route->dst_addr.in6); if (r < 0) { - log_error("Could not append RTA_DST attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_DST attribute: %m"); return r; } r = sd_rtnl_message_route_set_dst_prefixlen(req, route->dst_prefixlen); if (r < 0) { - log_error("Could not set destination prefix length: %s", strerror(-r)); + log_error_errno(-r, "Could not set destination prefix length: %m"); return r; } } @@ -239,32 +239,32 @@ int route_configure(Route *route, Link *link, else if (route->family == AF_INET6) r = sd_rtnl_message_append_in6_addr(req, RTA_PREFSRC, &route->prefsrc_addr.in6); if (r < 0) { - log_error("Could not append RTA_PREFSRC attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_PREFSRC attribute: %m"); return r; } } r = sd_rtnl_message_route_set_scope(req, route->scope); if (r < 0) { - log_error("Could not set scope: %s", strerror(-r)); + log_error_errno(-r, "Could not set scope: %m"); return r; } r = sd_rtnl_message_append_u32(req, RTA_PRIORITY, route->metrics); if (r < 0) { - log_error("Could not append RTA_PRIORITY attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_PRIORITY attribute: %m"); return r; } r = sd_rtnl_message_append_u32(req, RTA_OIF, link->ifindex); if (r < 0) { - log_error("Could not append RTA_OIF attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_OIF attribute: %m"); return r; } r = sd_rtnl_call_async(link->manager->rtnl, req, callback, link, 0, NULL); if (r < 0) { - log_error("Could not send rtnetlink message: %s", strerror(-r)); + log_error_errno(-r, "Could not send rtnetlink message: %m"); return r; } diff --git a/src/network/networkd-wait-online-manager.c b/src/network/networkd-wait-online-manager.c index b32f222701..0cdc4f8811 100644 --- a/src/network/networkd-wait-online-manager.c +++ b/src/network/networkd-wait-online-manager.c @@ -134,7 +134,7 @@ static int manager_process_link(sd_rtnl *rtnl, sd_rtnl_message *mm, void *userda return 0; fail: - log_warning("Failed to process RTNL link message: %s", strerror(-r)); + log_warning_errno(-r, "Failed to process RTNL link message: %m"); return 0; } @@ -211,7 +211,7 @@ static int on_network_event(sd_event_source *s, int fd, uint32_t revents, void * HASHMAP_FOREACH(l, m->links, i) { r = link_update_monitor(l); if (r < 0) - log_warning("Failed to update monitor information for %i: %s", l->ifindex, strerror(-r)); + log_warning_errno(-r, "Failed to update monitor information for %i: %m", l->ifindex); } if (manager_all_configured(m)) diff --git a/src/network/networkd-wait-online.c b/src/network/networkd-wait-online.c index 714343656b..40c89653b3 100644 --- a/src/network/networkd-wait-online.c +++ b/src/network/networkd-wait-online.c @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) { r = manager_new(&m, arg_interfaces); if (r < 0) { - log_error("Could not create manager: %s", strerror(-r)); + log_error_errno(-r, "Could not create manager: %m"); goto finish; } @@ -128,7 +128,7 @@ int main(int argc, char *argv[]) { r = sd_event_loop(m->event); if (r < 0) { - log_error("Event loop failed: %s", strerror(-r)); + log_error_errno(-r, "Event loop failed: %m"); goto finish; } diff --git a/src/network/networkd.c b/src/network/networkd.c index fdb80368d4..1020c72525 100644 --- a/src/network/networkd.c +++ b/src/network/networkd.c @@ -46,7 +46,7 @@ int main(int argc, char *argv[]) { r = get_user_creds(&user, &uid, &gid, NULL, NULL); if (r < 0) { - log_error("Cannot resolve user name %s: %s", user, strerror(-r)); + log_error_errno(-r, "Cannot resolve user name %s: %m", user); goto out; } @@ -79,37 +79,37 @@ int main(int argc, char *argv[]) { r = manager_new(&m); if (r < 0) { - log_error("Could not create manager: %s", strerror(-r)); + log_error_errno(-r, "Could not create manager: %m"); goto out; } r = manager_udev_listen(m); if (r < 0) { - log_error("Could not connect to udev: %s", strerror(-r)); + log_error_errno(-r, "Could not connect to udev: %m"); goto out; } r = manager_rtnl_listen(m); if (r < 0) { - log_error("Could not connect to rtnl: %s", strerror(-r)); + log_error_errno(-r, "Could not connect to rtnl: %m"); goto out; } r = manager_bus_listen(m); if (r < 0) { - log_error("Could not connect to system bus: %s", strerror(-r)); + log_error_errno(-r, "Could not connect to system bus: %m"); goto out; } r = manager_load_config(m); if (r < 0) { - log_error("Could not load configuration files: %s", strerror(-r)); + log_error_errno(-r, "Could not load configuration files: %m"); goto out; } r = manager_rtnl_enumerate_links(m); if (r < 0) { - log_error("Could not enumerate links: %s", strerror(-r)); + log_error_errno(-r, "Could not enumerate links: %m"); goto out; } @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { r = sd_event_loop(m->event); if (r < 0) { - log_error("Event loop failed: %s", strerror(-r)); + log_error_errno(-r, "Event loop failed: %m"); goto out; } |