diff options
author | Nathan Hjelm <hjelmn@cs.unm.edu> | 2013-08-14 11:08:36 -0600 |
---|---|---|
committer | Nathan Hjelm <hjelmn@cs.unm.edu> | 2013-08-14 11:08:36 -0600 |
commit | f0fb99aeb93f45d2846f8884a348e90438d13ef8 (patch) | |
tree | b0379535a41bb8ff2fa902b1b0efee37bb5ececc | |
parent | 368d613a17a3d768a7f434b886a8299f13711f8d (diff) | |
download | libusb-f0fb99aeb93f45d2846f8884a348e90438d13ef8.tar.gz |
linux/netlink: correct usage of fcntl
Closes #130
-rw-r--r-- | libusb/os/linux_netlink.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libusb/os/linux_netlink.c b/libusb/os/linux_netlink.c index 20f1d02..40f3fef 100644 --- a/libusb/os/linux_netlink.c +++ b/libusb/os/linux_netlink.c @@ -68,14 +68,21 @@ static int set_fd_cloexec_nb (int fd) int flags; #if defined(FD_CLOEXEC) - fcntl (linux_netlink_socket, F_GETFD, &flags); + flags = fcntl (linux_netlink_socket, F_GETFD); + if (0 > flags) { + return -1; + } if (!(flags & FD_CLOEXEC)) { fcntl (linux_netlink_socket, F_SETFD, flags | FD_CLOEXEC); } #endif - fcntl (linux_netlink_socket, F_GETFL, &flags); + flags = fcntl (linux_netlink_socket, F_GETFL); + if (0 > flags) { + return -1; + } + if (!(flags & O_NONBLOCK)) { fcntl (linux_netlink_socket, F_SETFL, flags | O_NONBLOCK); } |