From: Milan Broz Date: Fri, 27 Mar 2026 09:40:35 +0000 (+0100) Subject: Silence MINGW warning about INVALID_SOCKET X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=35b4cf28b4492e9a062733b159cbb7c8a708859c;p=thirdparty%2Fopenssl.git Silence MINGW warning about INVALID_SOCKET On Windows, SOCKET is defined as unsigned (UINT_PTR). In OpenSSL, the socket abstraction uses int, see discussion in https://github.com/openssl/openssl/issues/7282. MINGW for some time uses a signed definition of INVALID_SOCKET, then switched back to unsigned, see for example https://sourceforge.net/p/mingw-w64/discussion/723797/thread/71522d10/ Currently, it is defined as unsigned, creating many warnings like warning: overflow in conversion from 'long long unsigned int' to 'int'  changes value from '18446744073709551615' to '-1' [-Woverflow]  *sock = INVALID_SOCKET; As we use INVALID_SOCKET only in our code, we can safely silence this warning just by redefining INVALID_SOCKET to signed (version that is commented out in MINGW headers). While this is only a workaround, it has been here for years and allows focus on more important warnings. Signed-off-by: Milan Broz Reviewed-by: Neil Horman Reviewed-by: Saša Nedvědický Reviewed-by: Eugene Syromiatnikov MergeDate: Tue Mar 31 00:22:27 2026 (Merged from https://github.com/openssl/openssl/pull/30616) --- diff --git a/include/internal/sockets.h b/include/internal/sockets.h index c5f2978713c..ba8432c0a57 100644 --- a/include/internal/sockets.h +++ b/include/internal/sockets.h @@ -73,6 +73,15 @@ struct servent *PASCAL getservbyname(const char *, const char *); #define SHUT_RDWR SD_BOTH #endif +/* + * Recent MINGW versions use Windows-style unsigned INVALID_SOCKET. + * Since OpenSSL uses int, this only silences an already-ignored warning. + */ +#if defined(__MINGW32__) && defined(INVALID_SOCKET) +#undef INVALID_SOCKET +#define INVALID_SOCKET (INT_PTR)(~0) +#endif + #else #if defined(__APPLE__) /*