properly handle return codes
authorJohn Crispin <blogic@openwrt.org>
Sat, 28 Mar 2015 16:58:44 +0000 (17:58 +0100)
committerSteven Barth <steven@midlink.org>
Mon, 30 Mar 2015 11:58:07 +0000 (13:58 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
src/odhcp6c.c
src/odhcp6c.h
src/ra.c

index 8b5cb54308c8f7224e37c3dbd7d5e1571981d53e..dce1e0ee7494a3893df9ebef0625d75b7c042bcb 100644 (file)
@@ -445,7 +445,7 @@ static int usage(void)
        "       -e              Write logmessages to stderr\n"
        "       -v              Increase logging verbosity\n"
        "       -h              Show this help\n\n";
-       write(STDERR_FILENO, buf, sizeof(buf));
+       fputs(buf, stderr);
        return 1;
 }
 
@@ -654,9 +654,9 @@ uint32_t odhcp6c_elapsed(void)
 }
 
 
-void odhcp6c_random(void *buf, size_t len)
+int odhcp6c_random(void *buf, size_t len)
 {
-       read(urandom_fd, buf, len);
+       return read(urandom_fd, buf, len);
 }
 
 bool odhcp6c_is_bound(void)
index 1fda72a2ae32f6b5e005a7ad22e782ff3895683f..3e2713ea25bd19e31f272820851939b9d1c8035e 100644 (file)
@@ -325,7 +325,7 @@ void script_call(const char *status);
 
 bool odhcp6c_signal_process(void);
 uint64_t odhcp6c_get_milli_time(void);
-void odhcp6c_random(void *buf, size_t len);
+int odhcp6c_random(void *buf, size_t len);
 bool odhcp6c_is_bound(void);
 
 // State manipulation
index 95416240b2113fa313aa35bf2b55fcca4f69575c..09d5c1d9ce5985dd6300c4dca3d53ff3c0d60849 100644 (file)
--- a/src/ra.c
+++ b/src/ra.c
@@ -165,14 +165,16 @@ static int16_t pref_to_priority(uint8_t flags)
 }
 
 
-static void update_proc(const char *sect, const char *opt, uint32_t value)
+static int update_proc(const char *sect, const char *opt, uint32_t value)
 {
        char buf[64];
        snprintf(buf, sizeof(buf), "/proc/sys/net/ipv6/%s/%s/%s", sect, if_name, opt);
 
        int fd = open(buf, O_WRONLY);
-       write(fd, buf, snprintf(buf, sizeof(buf), "%u", value));
+       int ret = write(fd, buf, snprintf(buf, sizeof(buf), "%u", value));
        close(fd);
+
+       return ret;
 }