From 03e7dff8ff96ea5f87b393a9c11006683bef878e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 12 Dec 2023 19:27:44 +0000 Subject: [PATCH] windows: delete redundant headers `winsock2.h` pulls in `windows.h`. `ws2tcpip.h` pulls in `winsock2.h`. `winsock2.h` and `ws2tcpip.h` are also pulled by `curl/curl.h`. Keep only those headers that are not already included, or the code under it uses something from that specific header. Closes #12539 --- CMake/CurlTests.c | 5 ----- acinclude.m4 | 8 -------- configure.ac | 1 - docs/examples/externalsocket.c | 2 -- docs/examples/synctime.c | 6 +++--- lib/inet_pton.h | 3 --- lib/socketpair.c | 3 --- m4/curl-functions.m4 | 2 -- tests/libtest/lib1960.c | 6 ------ 9 files changed, 3 insertions(+), 33 deletions(-) diff --git a/CMake/CurlTests.c b/CMake/CurlTests.c index e00acc542e..83d743d34e 100644 --- a/CMake/CurlTests.c +++ b/CMake/CurlTests.c @@ -169,7 +169,6 @@ int main(void) { ; return 0; } # define WIN32_LEAN_AND_MEAN # endif # include -# include #endif int main(void) { @@ -189,7 +188,6 @@ int main(void) # define WIN32_LEAN_AND_MEAN # endif # include -# include #endif int main(void) { @@ -208,7 +206,6 @@ int main(void) # define WIN32_LEAN_AND_MEAN # endif # include -# include #endif int main(void) { @@ -228,7 +225,6 @@ int main(void) # define WIN32_LEAN_AND_MEAN # endif # include -# include #endif int main(void) { @@ -304,7 +300,6 @@ int main(void) # define WIN32_LEAN_AND_MEAN # endif # include -# include #endif /* includes start */ #ifdef HAVE_SYS_TYPES_H diff --git a/acinclude.m4 b/acinclude.m4 index 96187ade14..a44ae350e3 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -589,7 +589,6 @@ AC_DEFUN([TYPE_SOCKADDR_STORAGE], #define WIN32_LEAN_AND_MEAN #endif #include -#include #else #ifdef HAVE_SYS_TYPES_H #include @@ -625,7 +624,6 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [ #define WIN32_LEAN_AND_MEAN #endif #include -#include #else $curl_includes_bsdsocket #ifdef HAVE_SYS_TYPES_H @@ -674,7 +672,6 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [ #define WIN32_LEAN_AND_MEAN #endif #include -#include #else $curl_includes_bsdsocket #ifdef HAVE_SYS_TYPES_H @@ -719,7 +716,6 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [ #define WIN32_LEAN_AND_MEAN #endif #include -#include #else #ifdef HAVE_SYS_TYPES_H #include @@ -762,7 +758,6 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [ #define WIN32_LEAN_AND_MEAN #endif #include -#include #endif #ifdef HAVE_SYS_TYPES_H #include @@ -815,7 +810,6 @@ AC_DEFUN([TYPE_IN_ADDR_T], [ #define WIN32_LEAN_AND_MEAN #endif #include -#include #else #ifdef HAVE_SYS_TYPES_H #include @@ -855,7 +849,6 @@ AC_DEFUN([TYPE_IN_ADDR_T], [ #define WIN32_LEAN_AND_MEAN #endif #include -#include #else #ifdef HAVE_SYS_TYPES_H #include @@ -1134,7 +1127,6 @@ AC_DEFUN([CURL_CHECK_FUNC_SELECT], [ #define WIN32_LEAN_AND_MEAN #endif #include -#include #endif #ifdef HAVE_SYS_TYPES_H #include diff --git a/configure.ac b/configure.ac index e809502dfa..3e89da9f32 100644 --- a/configure.ac +++ b/configure.ac @@ -1125,7 +1125,6 @@ then #define WIN32_LEAN_AND_MEAN #endif #include -#include #endif ]],[[ gethostbyname("localhost"); diff --git a/docs/examples/externalsocket.c b/docs/examples/externalsocket.c index 6c9540a6db..9c34373443 100644 --- a/docs/examples/externalsocket.c +++ b/docs/examples/externalsocket.c @@ -32,8 +32,6 @@ #ifdef _WIN32 #include -#include -#include #define close closesocket #else #include /* socket types */ diff --git a/docs/examples/synctime.c b/docs/examples/synctime.c index fcf25d9411..2d7d523d50 100644 --- a/docs/examples/synctime.c +++ b/docs/examples/synctime.c @@ -91,11 +91,11 @@ #include #include -#ifndef __CYGWIN__ -#include +#include + +#ifdef _WIN32 #include #endif -#include #define MAX_STRING 256 diff --git a/lib/inet_pton.h b/lib/inet_pton.h index a6d161a999..f8562fa8a7 100644 --- a/lib/inet_pton.h +++ b/lib/inet_pton.h @@ -31,9 +31,6 @@ int Curl_inet_pton(int, const char *, void *); #ifdef HAVE_INET_PTON #ifdef HAVE_ARPA_INET_H #include -#elif defined(USE_WINSOCK) -/* inet_pton() exists in Vista or later */ -#include #endif #define Curl_inet_pton(x,y,z) inet_pton(x,y,z) #endif diff --git a/lib/socketpair.c b/lib/socketpair.c index e3d40ff94e..d01b255134 100644 --- a/lib/socketpair.c +++ b/lib/socketpair.c @@ -33,9 +33,6 @@ * This is a socketpair() implementation for Windows. */ #include -#include -#include -#include #include #else #ifdef HAVE_NETDB_H diff --git a/m4/curl-functions.m4 b/m4/curl-functions.m4 index 18147e4cac..425d9f96f8 100644 --- a/m4/curl-functions.m4 +++ b/m4/curl-functions.m4 @@ -419,7 +419,6 @@ curl_includes_winsock2="\ # define WIN32_LEAN_AND_MEAN # endif # include -# include #endif /* includes end */" CURL_CHECK_NATIVE_WINDOWS @@ -440,7 +439,6 @@ curl_includes_ws2tcpip="\ # endif # include # include -# include #endif /* includes end */" CURL_CHECK_NATIVE_WINDOWS diff --git a/tests/libtest/lib1960.c b/tests/libtest/lib1960.c index b01370e6e7..9b82128e9b 100644 --- a/tests/libtest/lib1960.c +++ b/tests/libtest/lib1960.c @@ -25,12 +25,6 @@ #ifdef HAVE_INET_PTON -#ifdef _WIN32 -#include -#include -#include -#endif - #ifdef HAVE_NETINET_IN_H #include #endif -- 2.47.3