]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cf-socket: deduplicate Windows Vista detection
authorJay Satiro <raysatiro@yahoo.com>
Wed, 19 Feb 2025 21:36:07 +0000 (16:36 -0500)
committerJay Satiro <raysatiro@yahoo.com>
Fri, 21 Feb 2025 08:12:32 +0000 (03:12 -0500)
- Remove Vista detection logic from Curl_sndbuf_init and evaluate global
  init variable Curl_isVistaOrGreater instead.

This way we don't need a separate initialization in Curl_sndbuf_init.

Ref: https://github.com/curl/curl/pull/16393#discussion_r1962377920

Closes https://github.com/curl/curl/pull/16400

lib/cf-socket.c

index 0f36bcec860384e137740df33a0eaa3725e60a67..ce3a771fc0a10a194977967ec542f1d25834d90a 100644 (file)
@@ -82,6 +82,7 @@
 #include "rand.h"
 #include "share.h"
 #include "strdup.h"
+#include "system_win32.h"
 #include "version_win32.h"
 #include "strparse.h"
 
@@ -461,9 +462,6 @@ int Curl_socket_close(struct Curl_easy *data, struct connectdata *conn,
    Windows. Following function trying to detect OS version and skips
    SO_SNDBUF adjustment for Windows Vista and above.
 */
-#define DETECT_OS_NONE 0
-#define DETECT_OS_PREVISTA 1
-#define DETECT_OS_VISTA_OR_LATER 2
 
 void Curl_sndbuf_init(curl_socket_t sockfd)
 {
@@ -471,17 +469,7 @@ void Curl_sndbuf_init(curl_socket_t sockfd)
   int curval = 0;
   int curlen = sizeof(curval);
 
-  static int detectOsState = DETECT_OS_NONE;
-
-  if(detectOsState == DETECT_OS_NONE) {
-    if(curlx_verify_windows_version(6, 0, 0, PLATFORM_WINNT,
-                                    VERSION_GREATER_THAN_EQUAL))
-      detectOsState = DETECT_OS_VISTA_OR_LATER;
-    else
-      detectOsState = DETECT_OS_PREVISTA;
-  }
-
-  if(detectOsState == DETECT_OS_VISTA_OR_LATER)
+  if(Curl_isVistaOrGreater)
     return;
 
   if(getsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, (char *)&curval, &curlen) == 0)