[socket] ret might not have been initialized (#4495)
authorLudovic Henry <ludovic@xamarin.com>
Thu, 9 Mar 2017 18:35:04 +0000 (13:35 -0500)
committerGitHub <noreply@github.com>
Thu, 9 Mar 2017 18:35:04 +0000 (13:35 -0500)
mono/metadata/w32socket-unix.c

index c10b210036825595d708b2b77a814abe1b855c84..f0139c318186b75d4755dc7b113c2bc0fa793bdc 100644 (file)
@@ -1134,6 +1134,7 @@ mono_w32socket_close (SOCKET sock)
 gint
 mono_w32socket_set_blocking (SOCKET socket, gboolean blocking)
 {
+#ifdef O_NONBLOCK
        gint ret;
        gpointer handle;
 
@@ -1143,14 +1144,12 @@ mono_w32socket_set_blocking (SOCKET socket, gboolean blocking)
                return SOCKET_ERROR;
        }
 
-#ifdef O_NONBLOCK
        /* This works better than ioctl(...FIONBIO...)
         * on Linux (it causes connect to return
         * EINPROGRESS, but the ioctl doesn't seem to) */
        ret = fcntl (socket, F_GETFL, 0);
        if (ret != -1)
                ret = fcntl (socket, F_SETFL, blocking ? (ret & (~O_NONBLOCK)) : (ret | (O_NONBLOCK)));
-#endif /* O_NONBLOCK */
 
        if (ret == -1) {
                gint errnum = errno;
@@ -1160,6 +1159,10 @@ mono_w32socket_set_blocking (SOCKET socket, gboolean blocking)
        }
 
        return 0;
+#else
+       mono_w32socket_set_last_error (ERROR_NOT_SUPPORTED);
+       return SOCKET_ERROR;
+#endif /* O_NONBLOCK */
 }
 
 gint