odhcpd: Replace strerror(errno) with %m format
authorRosen Penev <rosenp@gmail.com>
Sun, 17 Dec 2017 03:55:04 +0000 (19:55 -0800)
committerHans Dedecker <dedeckeh@gmail.com>
Sun, 17 Dec 2017 19:02:02 +0000 (20:02 +0100)
Saves a few bytes.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
src/config.c
src/dhcpv4.c
src/dhcpv6.c
src/ndp.c
src/netlink.c
src/odhcpd.c
src/router.c
src/ubus.c

index 409b3b81b9c988409b08b1e852d9b6e137f3e800..c3e2437901f7db340a8ca93d5eeec3382b2a7a68 100644 (file)
@@ -186,7 +186,7 @@ static int mkdir_p(char *dir, mode_t mask)
                return 0;
 
        if (ret)
-               syslog(LOG_ERR, "mkdir(%s, %d) failed: %s\n", dir, mask, strerror(errno));
+               syslog(LOG_ERR, "mkdir(%s, %d) failed: %m\n", dir, mask);
 
        return ret;
 }
index c36750783c3276f2d6d33a137c25eeb714d9af20..db5f138d95928f05116917d0243f09b997961d1f 100644 (file)
@@ -86,8 +86,7 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable)
 
                int sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
                if (sock < 0) {
-                       syslog(LOG_ERR, "Failed to create DHCPv4 server socket: %s",
-                                       strerror(errno));
+                       syslog(LOG_ERR, "Failed to create DHCPv4 server socket: %m");
                        return -1;
                }
 
@@ -110,8 +109,7 @@ int dhcpv4_setup_interface(struct interface *iface, bool enable)
                                        {INADDR_ANY}, {0}};
 
                if (bind(sock, (struct sockaddr*)&bind_addr, sizeof(bind_addr))) {
-                       syslog(LOG_ERR, "Failed to open DHCPv4 server socket: %s",
-                                       strerror(errno));
+                       syslog(LOG_ERR, "Failed to open DHCPv4 server socket: %m");
                        return -1;
                }
 
index 462a85ecfc8b2817fa958da3db92c323d209d7f0..e092c1076b73b9df0bf4e292a49128e51388996a 100644 (file)
@@ -53,8 +53,7 @@ int dhcpv6_setup_interface(struct interface *iface, bool enable)
        if (enable && iface->dhcpv6) {
                int sock = socket(AF_INET6, SOCK_DGRAM | SOCK_CLOEXEC, IPPROTO_UDP);
                if (sock < 0) {
-                       syslog(LOG_ERR, "Failed to create DHCPv6 server socket: %s",
-                                       strerror(errno));
+                       syslog(LOG_ERR, "Failed to create DHCPv6 server socket: %m");
                        return -1;
                }
 
@@ -76,8 +75,7 @@ int dhcpv6_setup_interface(struct interface *iface, bool enable)
                                        0, IN6ADDR_ANY_INIT, 0};
 
                if (bind(sock, (struct sockaddr*)&bind_addr, sizeof(bind_addr))) {
-                       syslog(LOG_ERR, "Failed to open DHCPv6 server socket: %s",
-                                       strerror(errno));
+                       syslog(LOG_ERR, "Failed to open DHCPv6 server socket: %m");
                        return -1;
                }
 
index d58906620aa100f702e4955a444bf104ecdf6ab4..72fd3bc37d87e360caf2d30c75dffd972cebb3ed 100644 (file)
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -62,7 +62,7 @@ int ndp_init(void)
        // Open ICMPv6 socket
        ping_socket = socket(AF_INET6, SOCK_RAW | SOCK_CLOEXEC, IPPROTO_ICMPV6);
        if (ping_socket < 0) {
-               syslog(LOG_ERR, "Unable to open raw socket: %s", strerror(errno));
+               syslog(LOG_ERR, "Unable to open raw socket: %m");
                        return -1;
        }
 
@@ -113,8 +113,7 @@ int ndp_setup_interface(struct interface *iface, bool enable)
 
                int sock = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IPV6));
                if (sock < 0) {
-                       syslog(LOG_ERR, "Unable to open packet socket: %s",
-                                       strerror(errno));
+                       syslog(LOG_ERR, "Unable to open packet socket: %m");
                        ret = -1;
                        goto out;
                }
@@ -126,7 +125,7 @@ int ndp_setup_interface(struct interface *iface, bool enable)
 
                if (setsockopt(sock, SOL_SOCKET, SO_ATTACH_FILTER,
                                &bpf_prog, sizeof(bpf_prog))) {
-                       syslog(LOG_ERR, "Failed to set BPF: %s", strerror(errno));
+                       syslog(LOG_ERR, "Failed to set BPF: %m");
                        ret = -1;
                        goto out;
                }
index ca9376e5c7ac06007b0f50c8b50fe73cc5ecbb4a..e9fd04a17dc98863e0ecb84835b4c37033351f6c 100644 (file)
@@ -58,13 +58,13 @@ int netlink_init(void)
 {
        rtnl_socket = create_socket(NETLINK_ROUTE);
        if (!rtnl_socket) {
-               syslog(LOG_ERR, "Unable to open nl socket: %s", strerror(errno));
+               syslog(LOG_ERR, "Unable to open nl socket: %m");
                goto err;
        }
 
        rtnl_event.sock = create_socket(NETLINK_ROUTE);
        if (!rtnl_event.sock) {
-               syslog(LOG_ERR, "Unable to open nl event socket: %s", strerror(errno));
+               syslog(LOG_ERR, "Unable to open nl event socket: %m");
                goto err;
        }
 
index 58c4338b908296a2e279559e45593c4937486463..71b803d01534935037d89c9f6da9dc91f58732d1 100644 (file)
@@ -187,8 +187,8 @@ ssize_t odhcpd_send(int socket, struct sockaddr_in6 *dest,
 
        ssize_t sent = sendmsg(socket, &msg, MSG_DONTWAIT);
        if (sent < 0)
-               syslog(LOG_NOTICE, "Failed to send to %s%%%s (%s)",
-                               ipbuf, iface->ifname, strerror(errno));
+               syslog(LOG_NOTICE, "Failed to send to %s%%%s (%m)",
+                               ipbuf, iface->ifname);
        else
                syslog(LOG_DEBUG, "Sent %li bytes to %s%%%s",
                                (long)sent, ipbuf, iface->ifname);
index 7bc94ed7825da5d7c91d2ea15ffa4023a3f26eb0..e62282b92cdf0e25cb2150c3058d2eb461103a98 100644 (file)
@@ -48,7 +48,7 @@ int router_init(void)
        // Open ICMPv6 socket
        int sock = socket(AF_INET6, SOCK_RAW | SOCK_CLOEXEC, IPPROTO_ICMPV6);
        if (sock < 0 && errno != EAFNOSUPPORT) {
-               syslog(LOG_ERR, "Failed to open RAW-socket: %s", strerror(errno));
+               syslog(LOG_ERR, "Failed to open RAW-socket: %m");
                return -1;
        }
 
@@ -82,8 +82,7 @@ int router_init(void)
        odhcpd_register(&router_event);
 
        if (!(fp_route = fopen("/proc/net/ipv6_route", "r")))
-               syslog(LOG_ERR, "Failed to open routing table: %s",
-                               strerror(errno));
+               syslog(LOG_ERR, "Failed to open routing table: %m");
 
        netlink_add_netevent_handler(&router_netevent_handler);
 
index 19b14be9175a875456624d863e7faf312f835117..6af591185de511a58a237d76214d6dce062d94cd 100644 (file)
@@ -412,7 +412,7 @@ bool ubus_has_prefix(const char *name, const char *ifname)
 int ubus_init(void)
 {
        if (!(ubus = ubus_connect(NULL))) {
-               syslog(LOG_ERR, "Unable to connect to ubus: %s", strerror(errno));
+               syslog(LOG_ERR, "Unable to connect to ubus: %m");
                return -1;
        }