Zebediah Figura : ws2_32: Reimplement inet_addr() on top of inet_pton().

Alexandre Julliard julliard at winehq.org
Tue Aug 3 16:52:22 CDT 2021


Module: wine
Branch: master
Commit: 671cf16f773e5dafc7edbf7766aed9e52e4e7b56
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=671cf16f773e5dafc7edbf7766aed9e52e4e7b56

Author: Zebediah Figura <zfigura at codeweavers.com>
Date:   Mon Aug  2 19:37:42 2021 -0500

ws2_32: Reimplement inet_addr() on top of inet_pton().

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ws2_32/protocol.c       | 9 ++++++---
 dlls/ws2_32/tests/protocol.c | 2 +-
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/ws2_32/protocol.c b/dlls/ws2_32/protocol.c
index 15616fdaf34..944f26912e6 100644
--- a/dlls/ws2_32/protocol.c
+++ b/dlls/ws2_32/protocol.c
@@ -2025,10 +2025,13 @@ int WINAPI WSAAddressToStringW( struct WS_sockaddr *addr, DWORD addr_len,
 /***********************************************************************
  *      inet_addr   (ws2_32.11)
  */
-WS_u_long WINAPI WS_inet_addr( const char *cp )
+WS_u_long WINAPI WS_inet_addr( const char *str )
 {
-    if (!cp) return INADDR_NONE;
-    return inet_addr( cp );
+    WS_u_long addr;
+
+    if (WS_inet_pton( WS_AF_INET, str, &addr ) == 1)
+        return addr;
+    return WS_INADDR_NONE;
 }
 
 
diff --git a/dlls/ws2_32/tests/protocol.c b/dlls/ws2_32/tests/protocol.c
index 0a2e42721af..99c78873d9a 100644
--- a/dlls/ws2_32/tests/protocol.c
+++ b/dlls/ws2_32/tests/protocol.c
@@ -945,7 +945,7 @@ static void test_inet_pton(void)
     WSASetLastError(0xdeadbeef);
     ret = inet_addr(NULL);
     ok(ret == INADDR_NONE, "got %#x\n", ret);
-    todo_wine ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
+    ok(WSAGetLastError() == WSAEFAULT, "got error %u\n", WSAGetLastError());
 
     for (i = 0; i < ARRAY_SIZE(ipv4_tests); ++i)
     {




More information about the wine-cvs mailing list