ws2_32/tests/sock.c -- fix error checking

Gerald Pfeifer gerald at pfeifer.com
Sat Nov 3 12:45:39 CDT 2007


Another real example where my quest to address warnings uncovered a
real bug.  In all those three cases the error handling simply didn't
take place because the condition wasn't able to trigger.

Gerald

ChangeLog:
Fix error checking in test_extendedSocketOptions() and test_getsockname().

Index: dlls/ws2_32/tests/sock.c
===================================================================
RCS file: /home/wine/wine/dlls/ws2_32/tests/sock.c,v
retrieving revision 1.19
diff -u -3 -p -r1.19 sock.c
--- dlls/ws2_32/tests/sock.c	25 Sep 2007 12:52:33 -0000	1.19
+++ dlls/ws2_32/tests/sock.c	3 Nov 2007 17:38:11 -0000
@@ -1638,7 +1638,7 @@ static void test_extendedSocketOptions(v
     sa.sin_port = htons(0);
     sa.sin_addr.s_addr = htonl(INADDR_ANY);
 
-    if((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) < 0){
+    if((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP)) == INVALID_SOCKET) {
         trace("Creating the socket failed: %d\n", WSAGetLastError());
         WSACleanup();
         return;
@@ -1664,7 +1664,7 @@ static void test_extendedSocketOptions(v
 
     closesocket(sock);
 
-    if((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_IP)) < 0){
+    if((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_IP)) == INVALID_SOCKET) {
         trace("Creating the socket failed: %d\n", WSAGetLastError());
         WSACleanup();
         return;
@@ -1711,7 +1711,7 @@ static void test_getsockname(void)
     sa_set.sin_port = htons(0);
     sa_set.sin_addr.s_addr = htonl(INADDR_ANY);
 
-    if((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_IP)) < 0){
+    if((sock = socket(PF_INET, SOCK_STREAM, IPPROTO_IP)) == INVALID_SOCKET) {
         trace("Creating the socket failed: %d\n", WSAGetLastError());
         WSACleanup();
         return;



More information about the wine-patches mailing list