diff options
author | John Crispin <blogic@openwrt.org> | 2015-03-28 18:12:21 +0100 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2015-03-30 14:14:22 +0200 |
commit | 73a7133b6e42edc218da5b8011c580ed48c7731a (patch) | |
tree | 71bf65b4c602e14fd8c17ff2ff94db9d394c2b19 /src | |
parent | 3b4e6d19b7ce0953efcd6d1c545b031b73e0ab6e (diff) |
properly handle return codes
Signed-off-by: John Crispin <blogic@openwrt.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 11 | ||||
-rw-r--r-- | src/dhcpv6-ia.c | 2 | ||||
-rw-r--r-- | src/ndp.c | 4 | ||||
-rw-r--r-- | src/odhcpd.c | 4 | ||||
-rw-r--r-- | src/odhcpd.h | 2 |
5 files changed, 12 insertions, 11 deletions
diff --git a/src/config.c b/src/config.c index 5fbb921..9dbe7f0 100644 --- a/src/config.c +++ b/src/config.c @@ -683,9 +683,10 @@ void odhcpd_reload(void) 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(); } @@ -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]; - read(u->fd, b, sizeof(b)); + if (read(u->fd, b, sizeof(b) < 0)) {} odhcpd_reload(); } @@ -702,7 +703,7 @@ static struct uloop_fd reload_fd = { .cb = reload_cb }; 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); diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index 7db4cee..74e3441 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -219,7 +219,7 @@ void dhcpv6_write_statefile(void) return; lockf(fd, F_LOCK, 0); - ftruncate(fd, 0); + if (ftruncate(fd, 0) < 0) {} FILE *fp = fdopen(fd, "w"); if (!fp) { @@ -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) - write(procfd, "0\n", 2); + if (write(procfd, "0\n", 2) < 0) {} dump_neigh = true; } @@ -152,7 +152,7 @@ int setup_ndp_interface(struct interface *iface, bool enable) } 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)); diff --git a/src/odhcpd.c b/src/odhcpd.c index 76dee9e..52bca13 100644 --- a/src/odhcpd.c +++ b/src/odhcpd.c @@ -415,9 +415,9 @@ void odhcpd_process(struct odhcpd_event *event) 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); } diff --git a/src/odhcpd.h b/src/odhcpd.h index 1ada4aa..21dc99f 100644 --- a/src/odhcpd.h +++ b/src/odhcpd.h @@ -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); -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); |