Skip to content

Commit

Permalink
windows: delete redundant headers
Browse files Browse the repository at this point in the history
`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
  • Loading branch information
vszakats committed Dec 18, 2023
1 parent 7e8fdad commit 03e7dff
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 33 deletions.
5 changes: 0 additions & 5 deletions CMake/CurlTests.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 169,6 @@ int main(void) { ; return 0; }
# define WIN32_LEAN_AND_MEAN
# endif
# include <winsock2.h>
# include <windows.h>
#endif
int main(void)
{
Expand All @@ -189,7 188,6 @@ int main(void)
# define WIN32_LEAN_AND_MEAN
# endif
# include <winsock2.h>
# include <windows.h>
#endif
int main(void)
{
Expand All @@ -208,7 206,6 @@ int main(void)
# define WIN32_LEAN_AND_MEAN
# endif
# include <winsock2.h>
# include <windows.h>
#endif
int main(void)
{
Expand All @@ -228,7 225,6 @@ int main(void)
# define WIN32_LEAN_AND_MEAN
# endif
# include <winsock2.h>
# include <windows.h>
#endif
int main(void)
{
Expand Down Expand Up @@ -304,7 300,6 @@ int main(void)
# define WIN32_LEAN_AND_MEAN
# endif
# include <winsock2.h>
# include <windows.h>
#endif
/* includes start */
#ifdef HAVE_SYS_TYPES_H
Expand Down
8 changes: 0 additions & 8 deletions acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 589,6 @@ AC_DEFUN([TYPE_SOCKADDR_STORAGE],
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down Expand Up @@ -625,7 624,6 @@ AC_DEFUN([CURL_CHECK_FUNC_RECV], [
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#else
$curl_includes_bsdsocket
#ifdef HAVE_SYS_TYPES_H
Expand Down Expand Up @@ -674,7 672,6 @@ AC_DEFUN([CURL_CHECK_FUNC_SEND], [
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#else
$curl_includes_bsdsocket
#ifdef HAVE_SYS_TYPES_H
Expand Down Expand Up @@ -719,7 716,6 @@ AC_DEFUN([CURL_CHECK_MSG_NOSIGNAL], [
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down Expand Up @@ -762,7 758,6 @@ AC_DEFUN([CURL_CHECK_STRUCT_TIMEVAL], [
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down Expand Up @@ -815,7 810,6 @@ AC_DEFUN([TYPE_IN_ADDR_T], [
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down Expand Up @@ -855,7 849,6 @@ AC_DEFUN([TYPE_IN_ADDR_T], [
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#else
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down Expand Up @@ -1134,7 1127,6 @@ AC_DEFUN([CURL_CHECK_FUNC_SELECT], [
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
Expand Down
1 change: 0 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 1125,6 @@ then
#define WIN32_LEAN_AND_MEAN
#endif
#include <winsock2.h>
#include <windows.h>
#endif
]],[[
gethostbyname("localhost");
Expand Down
2 changes: 0 additions & 2 deletions docs/examples/externalsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 32,6 @@

#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#define close closesocket
#else
#include <sys/types.h> /* socket types */
Expand Down
6 changes: 3 additions & 3 deletions docs/examples/synctime.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 91,11 @@

#include <stdio.h>
#include <time.h>
#ifndef __CYGWIN__
#include <winsock2.h>
#include <curl/curl.h>

#ifdef _WIN32
#include <windows.h>
#endif
#include <curl/curl.h>


#define MAX_STRING 256
Expand Down
3 changes: 0 additions & 3 deletions lib/inet_pton.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 31,6 @@ int Curl_inet_pton(int, const char *, void *);
#ifdef HAVE_INET_PTON
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#elif defined(USE_WINSOCK)
/* inet_pton() exists in Vista or later */
#include <ws2tcpip.h>
#endif
#define Curl_inet_pton(x,y,z) inet_pton(x,y,z)
#endif
Expand Down
3 changes: 0 additions & 3 deletions lib/socketpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 33,6 @@
* This is a socketpair() implementation for Windows.
*/
#include <string.h>
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#include <io.h>
#else
#ifdef HAVE_NETDB_H
Expand Down
2 changes: 0 additions & 2 deletions m4/curl-functions.m4
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 419,6 @@ curl_includes_winsock2="\
# define WIN32_LEAN_AND_MEAN
# endif
# include <winsock2.h>
# include <windows.h>
#endif
/* includes end */"
CURL_CHECK_NATIVE_WINDOWS
Expand All @@ -440,7 439,6 @@ curl_includes_ws2tcpip="\
# endif
# include <winsock2.h>
# include <ws2tcpip.h>
# include <windows.h>
#endif
/* includes end */"
CURL_CHECK_NATIVE_WINDOWS
Expand Down
6 changes: 0 additions & 6 deletions tests/libtest/lib1960.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 25,6 @@

#ifdef HAVE_INET_PTON

#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#include <windows.h>
#endif

#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
Expand Down

0 comments on commit 03e7dff

Please sign in to comment.