[PATCH 2/5] server: return WSAESOCKTNOSUPPORT when appropriate for socket() failure on FreeBSD

Damjan Jovanovic damjan.jov at gmail.com
Sun Jan 5 12:32:44 CST 2020


These tests fail on FreeBSD:
sock.c:2509: Test failed: Expected 10044, received 10041
sock.c:2549: Test failed: Expected 10044, received 10041

That's because:
WSASocketA(AF_INET, -1, 0, NULL, 0, 0)
WSASocketA(AF_INET, 0xdead, 0, NULL, 0, 0)
are supposed to fail with WSAESOCKTNOSUPPORT.

Translate the return codes like we do on Linux.

Signed-off-by: Damjan Jovanovic <damjan.jov at gmail.com>
---
 server/sock.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
-------------- next part --------------
diff --git a/server/sock.c b/server/sock.c
index 1a53ce4b09..8c8eb086ac 100644
--- a/server/sock.c
+++ b/server/sock.c
@@ -663,8 +663,12 @@ static struct object *create_socket( int family, int type, int protocol, unsigne
     sockfd = socket( family, type, protocol );
     if (sockfd == -1)
     {
+        set_win32_error( sock_get_error( errno ));
+#if defined (linux)
         if (errno == EINVAL) set_win32_error( WSAESOCKTNOSUPPORT );
-        else set_win32_error( sock_get_error( errno ));
+#elif defined (__FreeBSD__) || defined(__FreeBSD_kernel__)
+        if (errno == EPROTOTYPE) set_win32_error( WSAESOCKTNOSUPPORT );
+#endif
         return NULL;
     }
     fcntl(sockfd, F_SETFL, O_NONBLOCK); /* make socket nonblocking */


More information about the wine-devel mailing list