From: John Crispin Date: Sat, 28 Mar 2015 16:58:44 +0000 (+0100) Subject: properly handle return codes X-Git-Tag: debian/1.1+git20160131-1~28 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=ec864c44e9959a5d65cc564182f4e960e47c6e9e;p=odhcp6c.git properly handle return codes Signed-off-by: John Crispin --- diff --git a/src/odhcp6c.c b/src/odhcp6c.c index 8b5cb54..dce1e0e 100644 --- a/src/odhcp6c.c +++ b/src/odhcp6c.c @@ -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) diff --git a/src/odhcp6c.h b/src/odhcp6c.h index 1fda72a..3e2713e 100644 --- a/src/odhcp6c.h +++ b/src/odhcp6c.h @@ -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 diff --git a/src/ra.c b/src/ra.c index 9541624..09d5c1d 100644 --- 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; }