about summary refs log tree commit homepage
path: root/ext/kgio/connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/kgio/connect.c')
-rw-r--r--ext/kgio/connect.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ext/kgio/connect.c b/ext/kgio/connect.c
index 63c0bbc..2027795 100644
--- a/ext/kgio/connect.c
+++ b/ext/kgio/connect.c
@@ -36,7 +36,7 @@ static int my_socket(int domain)
 retry:
         fd = socket(domain, MY_SOCK_STREAM, 0);
 
-        if (fd == -1) {
+        if (fd < 0) {
                 switch (errno) {
                 case EMFILE:
                 case ENFILE:
@@ -53,12 +53,12 @@ retry:
                                 goto retry;
                         }
                 }
-                if (fd == -1)
+                if (fd < 0)
                         rb_sys_fail("socket");
         }
 
         if (MY_SOCK_STREAM == SOCK_STREAM) {
-                if (fcntl(fd, F_SETFL, O_RDWR | O_NONBLOCK) == -1)
+                if (fcntl(fd, F_SETFL, O_RDWR | O_NONBLOCK) < 0)
                         close_fail(fd, "fcntl(F_SETFL, O_RDWR | O_NONBLOCK)");
                 rb_fd_fix_cloexec(fd);
         }
@@ -71,7 +71,7 @@ my_connect(VALUE klass, int io_wait, int domain, void *addr, socklen_t addrlen)
 {
         int fd = my_socket(domain);
 
-        if (connect(fd, addr, addrlen) == -1) {
+        if (connect(fd, addr, addrlen) < 0) {
                 if (errno == EINPROGRESS) {
                         VALUE io = sock_for_fd(klass, fd);