From 93886f5c7d5e8b62e93d6ab8a14ab9125b4af655 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 29 Mar 2024 12:13:41 -0400 Subject: file(DOWNLOAD|UPLOAD): Avoid unnecessary CMAKE_TLS_VERIFY variable lookup If the `TLS_VERIFY` option is given explicitly, we do not need to check the variable. --- CTestCustom.cmake.in | 1 + Source/cmFileCommand.cxx | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 3ba8f54..a81ee4b 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -85,6 +85,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION "[0-9]+ Warning\\(s\\) detected" # SunPro # Ignore false positive on `cm::optional` usage from GCC + "cmFileCommand.cxx:[0-9]*:[0-9]*: warning: '\\*\\(\\(void\\*\\)& tls_verify \\+2\\)' may be used uninitialized in this function \\[-Wmaybe-uninitialized\\]" "cmGlobalNinjaGenerator.cxx:[0-9]*:[0-9]*: warning: '.*cm::optional::_mem\\)\\)' may be used uninitialized \\[-Wmaybe-uninitialized\\]" "cmGlobalNinjaGenerator.cxx:[0-9]*:[0-9]*: note: '.*cm::optional::_mem\\)\\)' was declared here" "cmGlobalNinjaGenerator.cxx:[0-9]*:[0-9]*: warning: '\\*\\(\\(void\\*\\)& modmap_fmt \\+4\\)' may be used uninitialized in this function \\[-Wmaybe-uninitialized\\]" diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 115c332..ac1d22b 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1866,7 +1866,7 @@ bool HandleDownloadCommand(std::vector const& args, std::string logVar; std::string statusVar; cm::optional tls_version; - bool tls_verify = status.GetMakefile().IsOn("CMAKE_TLS_VERIFY"); + cm::optional tls_verify; cmValue cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO"); std::string netrc_level = status.GetMakefile().GetSafeDefinition("CMAKE_NETRC"); @@ -2031,6 +2031,12 @@ bool HandleDownloadCommand(std::vector const& args, ++i; } + if (!tls_verify) { + if (cmValue v = status.GetMakefile().GetDefinition("CMAKE_TLS_VERIFY")) { + tls_verify = v.IsOn(); + } + } + if (!tls_version) { if (cmValue v = status.GetMakefile().GetDefinition("CMAKE_TLS_VERSION")) { tls_version = *v; @@ -2133,7 +2139,7 @@ bool HandleDownloadCommand(std::vector const& args, } // check to see if TLS verification is requested - if (tls_verify) { + if (tls_verify && *tls_verify) { res = ::curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1); check_curl_result(res, "DOWNLOAD cannot set TLS/SSL Verify on: "); } else { @@ -2322,7 +2328,7 @@ bool HandleUploadCommand(std::vector const& args, std::string statusVar; bool showProgress = false; cm::optional tls_version; - bool tls_verify = status.GetMakefile().IsOn("CMAKE_TLS_VERIFY"); + cm::optional tls_verify; cmValue cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO"); std::string userpwd; std::string netrc_level = @@ -2428,6 +2434,12 @@ bool HandleUploadCommand(std::vector const& args, ++i; } + if (!tls_verify) { + if (cmValue v = status.GetMakefile().GetDefinition("CMAKE_TLS_VERIFY")) { + tls_verify = v.IsOn(); + } + } + if (!tls_version) { if (cmValue v = status.GetMakefile().GetDefinition("CMAKE_TLS_VERSION")) { tls_version = *v; @@ -2498,7 +2510,7 @@ bool HandleUploadCommand(std::vector const& args, } // check to see if TLS verification is requested - if (tls_verify) { + if (tls_verify && *tls_verify) { res = ::curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 1); check_curl_result(res, "UPLOAD cannot set TLS/SSL Verify on: "); } else { -- cgit v0.12