summaryrefslogtreecommitdiffstats
path: root/gl/sockets.c
diff options
context:
space:
mode:
Diffstat (limited to 'gl/sockets.c')
-rw-r--r--gl/sockets.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/gl/sockets.c b/gl/sockets.c
index 7accfdd3..ce98698d 100644
--- a/gl/sockets.c
+++ b/gl/sockets.c
@@ -1,6 +1,6 @@
1/* sockets.c --- wrappers for Windows socket functions 1/* sockets.c --- wrappers for Windows socket functions
2 2
3 Copyright (C) 2008-2025 Free Software Foundation, Inc. 3 Copyright (C) 2008-2026 Free Software Foundation, Inc.
4 4
5 This file is free software: you can redistribute it and/or modify 5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as 6 it under the terms of the GNU Lesser General Public License as
@@ -46,11 +46,10 @@ close_fd_maybe_socket (const struct fd_hook *remaining_list,
46 our calls to closesocket() and the primary close(), some other thread 46 our calls to closesocket() and the primary close(), some other thread
47 could make system calls that allocate precisely the same HANDLE value 47 could make system calls that allocate precisely the same HANDLE value
48 as sock; then the primary close() would call CloseHandle() on it. */ 48 as sock; then the primary close() would call CloseHandle() on it. */
49 SOCKET sock;
50 WSANETWORKEVENTS ev;
51 49
52 /* Test whether fd refers to a socket. */ 50 /* Test whether fd refers to a socket. */
53 sock = FD_TO_SOCKET (fd); 51 SOCKET sock = FD_TO_SOCKET (fd);
52 WSANETWORKEVENTS ev;
54 ev.lNetworkEvents = 0xDEADBEEF; 53 ev.lNetworkEvents = 0xDEADBEEF;
55 WSAEnumNetworkEvents (sock, NULL, &ev); 54 WSAEnumNetworkEvents (sock, NULL, &ev);
56 if (ev.lNetworkEvents != 0xDEADBEEF) 55 if (ev.lNetworkEvents != 0xDEADBEEF)
@@ -83,11 +82,9 @@ ioctl_fd_maybe_socket (const struct fd_hook *remaining_list,
83 gl_ioctl_fn primary, 82 gl_ioctl_fn primary,
84 int fd, int request, void *arg) 83 int fd, int request, void *arg)
85{ 84{
86 SOCKET sock;
87 WSANETWORKEVENTS ev;
88
89 /* Test whether fd refers to a socket. */ 85 /* Test whether fd refers to a socket. */
90 sock = FD_TO_SOCKET (fd); 86 SOCKET sock = FD_TO_SOCKET (fd);
87 WSANETWORKEVENTS ev;
91 ev.lNetworkEvents = 0xDEADBEEF; 88 ev.lNetworkEvents = 0xDEADBEEF;
92 WSAEnumNetworkEvents (sock, NULL, &ev); 89 WSAEnumNetworkEvents (sock, NULL, &ev);
93 if (ev.lNetworkEvents != 0xDEADBEEF) 90 if (ev.lNetworkEvents != 0xDEADBEEF)
@@ -119,9 +116,7 @@ gl_sockets_startup (_GL_UNUSED int version)
119 if (version > initialized_sockets_version) 116 if (version > initialized_sockets_version)
120 { 117 {
121 WSADATA data; 118 WSADATA data;
122 int err; 119 int err = WSAStartup (version, &data);
123
124 err = WSAStartup (version, &data);
125 if (err != 0) 120 if (err != 0)
126 return 1; 121 return 1;
127 122
@@ -146,13 +141,11 @@ int
146gl_sockets_cleanup (void) 141gl_sockets_cleanup (void)
147{ 142{
148#if WINDOWS_SOCKETS 143#if WINDOWS_SOCKETS
149 int err;
150
151 initialized_sockets_version = 0; 144 initialized_sockets_version = 0;
152 145
153 unregister_fd_hook (&fd_sockets_hook); 146 unregister_fd_hook (&fd_sockets_hook);
154 147
155 err = WSACleanup (); 148 int err = WSACleanup ();
156 if (err != 0) 149 if (err != 0)
157 return 1; 150 return 1;
158#endif 151#endif