← Commit list

6a3ebdb9f0

Viktor Szakats
Viktor Szakats
2026-08-31
SUCCESS Duration: 426s

Subject

winsock: drop redundant version checks at initialization

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

lib/system_win32.c+2 -26
@@ -38,33 +38,9 @@ CURLcode Curl_win32_init(long flags)
should take place after this block. */
if(flags & CURL_GLOBAL_WIN32) {
#ifdef USE_WINSOCK
- WORD wVersionRequested;
- WSADATA wsaData;
- int res;
-
- wVersionRequested = MAKEWORD(2, 2);
- res = WSAStartup(wVersionRequested, &wsaData);
-
- if(res)
- /* Tell the user that we could not find a usable */
- /* winsock.dll. */
- return CURLE_FAILED_INIT;
-
- /* Confirm that the Windows Sockets DLL supports what we need.*/
- /* Note that if the DLL supports versions greater */
- /* than wVersionRequested, it will still return */
- /* wVersionRequested in wVersion. wHighVersion contains the */
- /* highest supported version. */
-
- if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
- HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) {
- /* Tell the user that we could not find a usable */
-
- /* winsock.dll. */
- WSACleanup();
+ WSADATA wsa;
+ if(WSAStartup(MAKEWORD(2, 2), &wsa))
return CURLE_FAILED_INIT;
- }
- /* The Windows Sockets DLL is acceptable. Proceed. */
#elif defined(USE_LWIPSOCK)
lwip_init();
#endif
tests/server/util.c+4 -18
@@ -133,30 +133,16 @@ int win32_init(void)
curlx_now_init();
#ifdef USE_WINSOCK
{
- WORD wVersionRequested;
- WSADATA wsaData;
- int err;
- char buffer[STRERROR_LEN];
-
- wVersionRequested = MAKEWORD(2, 2);
- err = WSAStartup(wVersionRequested, &wsaData);
- if(err) {
+ WSADATA wsa;
+ if(WSAStartup(MAKEWORD(2, 2), &wsa)) {
+ char buffer[STRERROR_LEN];
curlx_strerror(SOCKERRNO, buffer, sizeof(buffer));
fprintf(stderr, "Winsock init failed: %s\n", buffer);
logmsg("Error initializing Winsock -- aborting");
return 1;
}
-
- if(LOBYTE(wsaData.wVersion) != LOBYTE(wVersionRequested) ||
- HIBYTE(wsaData.wVersion) != HIBYTE(wVersionRequested)) {
- WSACleanup();
- curlx_strerror(SOCKERRNO, buffer, sizeof(buffer));
- fprintf(stderr, "Winsock init failed: %s\n", buffer);
- logmsg("No suitable winsock.dll found -- aborting");
- return 1;
- }
}
-#endif /* USE_WINSOCK */
+#endif
atexit(win32_cleanup);
return 0;
}