properly handle return codes
authorJohn Crispin <blogic@openwrt.org>
Sat, 28 Mar 2015 17:12:21 +0000 (18:12 +0100)
committerSteven Barth <steven@midlink.org>
Mon, 30 Mar 2015 12:14:22 +0000 (14:14 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
src/config.c
src/dhcpv6-ia.c
src/ndp.c
src/odhcpd.c
src/odhcpd.h

index 5fbb921..9dbe7f0 100644 (file)
@@ -683,9 +683,10 @@ void odhcpd_reload(void)
 static void handle_signal(int signal)
 {
        char b[1] = {0};
 static void handle_signal(int signal)
 {
        char b[1] = {0};
-       if (signal == SIGHUP)
-               write(reload_pipe[1], b, sizeof(b));
-       else
+
+       if (signal == SIGHUP) {
+               if (write(reload_pipe[1], b, sizeof(b)) < 0) {}
+       } else
                uloop_end();
 }
 
                uloop_end();
 }
 
@@ -694,7 +695,7 @@ static void handle_signal(int signal)
 static void reload_cb(struct uloop_fd *u, _unused unsigned int events)
 {
        char b[512];
 static void reload_cb(struct uloop_fd *u, _unused unsigned int events)
 {
        char b[512];
-       read(u->fd, b, sizeof(b));
+       if (read(u->fd, b, sizeof(b) < 0)) {}
        odhcpd_reload();
 }
 
        odhcpd_reload();
 }
 
@@ -702,7 +703,7 @@ static struct uloop_fd reload_fd = { .cb = reload_cb };
 
 void odhcpd_run(void)
 {
 
 void odhcpd_run(void)
 {
-       pipe2(reload_pipe, O_NONBLOCK | O_CLOEXEC);
+       if (pipe2(reload_pipe, O_NONBLOCK | O_CLOEXEC) < 0) {}
        reload_fd.fd = reload_pipe[0];
        uloop_fd_add(&reload_fd, ULOOP_READ);
 
        reload_fd.fd = reload_pipe[0];
        uloop_fd_add(&reload_fd, ULOOP_READ);
 
index 7db4cee..74e3441 100644 (file)
@@ -219,7 +219,7 @@ void dhcpv6_write_statefile(void)
                        return;
 
                lockf(fd, F_LOCK, 0);
                        return;
 
                lockf(fd, F_LOCK, 0);
-               ftruncate(fd, 0);
+               if (ftruncate(fd, 0) < 0) {}
 
                FILE *fp = fdopen(fd, "w");
                if (!fp) {
 
                FILE *fp = fdopen(fd, "w");
                if (!fp) {
index 45bb9db..5e8b5ac 100644 (file)
--- a/src/ndp.c
+++ b/src/ndp.c
@@ -132,7 +132,7 @@ int setup_ndp_interface(struct interface *iface, bool enable)
                iface->ndp_event.uloop.fd = -1;
 
                if (!enable || iface->ndp != RELAYD_RELAY)
                iface->ndp_event.uloop.fd = -1;
 
                if (!enable || iface->ndp != RELAYD_RELAY)
-                       write(procfd, "0\n", 2);
+                       if (write(procfd, "0\n", 2) < 0) {}
 
                dump_neigh = true;
        }
 
                dump_neigh = true;
        }
@@ -152,7 +152,7 @@ int setup_ndp_interface(struct interface *iface, bool enable)
        }
 
        if (enable && iface->ndp == RELAYD_RELAY) {
        }
 
        if (enable && iface->ndp == RELAYD_RELAY) {
-               write(procfd, "1\n", 2);
+               if (write(procfd, "1\n", 2) < 0) {}
                close(procfd);
 
                int sock = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IPV6));
                close(procfd);
 
                int sock = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC, htons(ETH_P_IPV6));
index 76dee9e..52bca13 100644 (file)
@@ -415,9 +415,9 @@ void odhcpd_process(struct odhcpd_event *event)
        odhcpd_receive_packets(&event->uloop, 0);
 }
 
        odhcpd_receive_packets(&event->uloop, 0);
 }
 
-void odhcpd_urandom(void *data, size_t len)
+int odhcpd_urandom(void *data, size_t len)
 {
 {
-       read(urandom_fd, data, len);
+       return read(urandom_fd, data, len);
 }
 
 
 }
 
 
index 1ada4aa..21dc99f 100644 (file)
@@ -190,7 +190,7 @@ int odhcpd_get_interface_mtu(const char *ifname);
 int odhcpd_get_mac(const struct interface *iface, uint8_t mac[6]);
 struct interface* odhcpd_get_interface_by_index(int ifindex);
 struct interface* odhcpd_get_master_interface(void);
 int odhcpd_get_mac(const struct interface *iface, uint8_t mac[6]);
 struct interface* odhcpd_get_interface_by_index(int ifindex);
 struct interface* odhcpd_get_master_interface(void);
-void odhcpd_urandom(void *data, size_t len);
+int odhcpd_urandom(void *data, size_t len);
 void odhcpd_setup_route(const struct in6_addr *addr, int prefixlen,
                const struct interface *iface, const struct in6_addr *gw, bool add);
 
 void odhcpd_setup_route(const struct in6_addr *addr, int prefixlen,
                const struct interface *iface, const struct in6_addr *gw, bool add);