lib: Convert network.c to use new error subsystem codes

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2018-08-20 09:50:31 -04:00 committed by Quentin Young
parent 9ef9495e3a
commit fc41c1531f

View File

@ -22,6 +22,7 @@
#include <zebra.h> #include <zebra.h>
#include "log.h" #include "log.h"
#include "network.h" #include "network.h"
#include "lib_errors.h"
/* Read nbytes from fd and store into ptr. */ /* Read nbytes from fd and store into ptr. */
int readn(int fd, uint8_t *ptr, int nbytes) int readn(int fd, uint8_t *ptr, int nbytes)
@ -78,12 +79,14 @@ int set_nonblocking(int fd)
should should
never be negative. */ never be negative. */
if ((flags = fcntl(fd, F_GETFL)) < 0) { if ((flags = fcntl(fd, F_GETFL)) < 0) {
zlog_warn("fcntl(F_GETFL) failed for fd %d: %s", fd, flog_err(LIB_ERR_SYSTEM_CALL,
"fcntl(F_GETFL) failed for fd %d: %s", fd,
safe_strerror(errno)); safe_strerror(errno));
return -1; return -1;
} }
if (fcntl(fd, F_SETFL, (flags | O_NONBLOCK)) < 0) { if (fcntl(fd, F_SETFL, (flags | O_NONBLOCK)) < 0) {
zlog_warn("fcntl failed setting fd %d non-blocking: %s", fd, flog_err(LIB_ERR_SYSTEM_CALL,
"fcntl failed setting fd %d non-blocking: %s", fd,
safe_strerror(errno)); safe_strerror(errno));
return -1; return -1;
} }