From e83ab952797c8830ca9e120c413142f6095f501e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 29 Sep 2025 00:09:56 +0500 Subject: [PATCH] engine: gethostbyname() is deprecated, remove it and always prefer getaddrinfo --- engine/common/net_ws.c | 21 --------------------- engine/platform/posix/net.h | 1 - engine/platform/win32/net.h | 2 -- 3 files changed, 24 deletions(-) diff --git a/engine/common/net_ws.c b/engine/common/net_ws.c index c608c198..5bf6e7a8 100644 --- a/engine/common/net_ws.c +++ b/engine/common/net_ws.c @@ -237,7 +237,6 @@ NET_GetHostByName */ static qboolean NET_GetHostByName( const char *hostname, int family, struct sockaddr_storage *addr ) { -#if defined HAVE_GETADDRINFO struct addrinfo *ai = NULL, *cur; struct addrinfo hints; qboolean ret = false; @@ -267,22 +266,6 @@ static qboolean NET_GetHostByName( const char *hostname, int family, struct sock } return ret; -#else - struct hostent *h; - -#if XASH_NO_IPV6_RESOLVE - if( family == AF_INET6 ) - return false; -#endif - - if(!( h = gethostbyname( hostname ))) - return false; - - ((struct sockaddr_in *)addr)->sin_family = AF_INET; - ((struct sockaddr_in *)addr)->sin_addr = *(struct in_addr *)h->h_addr_list[0]; - - return true; -#endif } #if !XASH_EMSCRIPTEN && !XASH_DOS4GW && !defined XASH_NO_ASYNC_NS_RESOLVE @@ -380,11 +363,7 @@ static void NET_ResolveThread( void ) RESOLVE_DBG( "[resolve thread] starting resolve for " ); RESOLVE_DBG( nsthread.hostname ); -#ifdef HAVE_GETADDRINFO RESOLVE_DBG( " with getaddrinfo\n" ); -#else - RESOLVE_DBG( " with gethostbyname\n" ); -#endif if(( res = NET_GetHostByName( nsthread.hostname, nsthread.family, &addr ))) RESOLVE_DBG( "[resolve thread] success\n" ); diff --git a/engine/platform/posix/net.h b/engine/platform/posix/net.h index 58532927..24bc6ab0 100644 --- a/engine/platform/posix/net.h +++ b/engine/platform/posix/net.h @@ -73,7 +73,6 @@ GNU General Public License for more details. #ifndef XASH_DOS4GW -#define HAVE_GETADDRINFO #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 diff --git a/engine/platform/win32/net.h b/engine/platform/win32/net.h index 465db08a..ff2fe5b8 100644 --- a/engine/platform/win32/net.h +++ b/engine/platform/win32/net.h @@ -18,6 +18,4 @@ GNU General Public License for more details. #include typedef int WSAsize_t; -#define HAVE_GETADDRINFO - #endif // NET_H