From: Remi Gacogne Date: Mon, 24 Jun 2024 11:32:25 +0000 (+0200) Subject: dnsdist: Fix static analysis warnings (again) X-Git-Tag: rec-5.2.0-alpha1~172^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=113749b804fc648c23e508b1e7aa6d4f9761a640;p=thirdparty%2Fpdns.git dnsdist: Fix static analysis warnings (again) --- diff --git a/pdns/dnsdistdist/dnsdist-dynblocks.cc b/pdns/dnsdistdist/dnsdist-dynblocks.cc index 371a0f1194..ee0367a06c 100644 --- a/pdns/dnsdistdist/dnsdist-dynblocks.cc +++ b/pdns/dnsdistdist/dnsdist-dynblocks.cc @@ -773,7 +773,7 @@ void DynBlockMaintenance::run() time_t now = time(nullptr); auto purgeInterval = dnsdist::configuration::getCurrentRuntimeConfiguration().d_dynBlocksPurgeInterval; time_t nextExpiredPurge = now + purgeInterval; - time_t nextMetricsCollect = now + metricsCollectionInterval; + time_t nextMetricsCollect = now + static_cast(metricsCollectionInterval); time_t nextMetricsGeneration = now + metricsGenerationInterval; while (true) { @@ -813,7 +813,7 @@ void DynBlockMaintenance::run() purgeExpired(tspec); now = time(nullptr); - nextExpiredPurge = now + purgeInterval; + nextExpiredPurge = now + static_cast(purgeInterval); } } catch (const std::exception& e) { diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.cc b/pdns/dnsdistdist/dnsdist-lbpolicies.cc index a648435a0a..6fb2c24b43 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.cc +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.cc @@ -256,7 +256,7 @@ shared_ptr roundrobin(const ServerPolicy::NumberedServerVector& return servers.at(candidates.at((counter++) % candidates.size()) - 1).second; } -const std::shared_ptr getDownstreamCandidates(const std::string& poolName) +std::shared_ptr getDownstreamCandidates(const std::string& poolName) { std::shared_ptr pool = getPool(poolName); return pool->getServers(); @@ -266,9 +266,9 @@ std::shared_ptr createPoolIfNotExists(const string& poolName) { { const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools; - const auto it = pools.find(poolName); - if (it != pools.end()) { - return it->second; + const auto poolIt = pools.find(poolName); + if (poolIt != pools.end()) { + return poolIt->second; } } @@ -323,12 +323,12 @@ void removeServerFromPool(const string& poolName, std::shared_ptr getPool(const std::string& poolName) { const auto& pools = dnsdist::configuration::getCurrentRuntimeConfiguration().d_pools; - auto it = pools.find(poolName); - if (it == pools.end()) { + auto poolIt = pools.find(poolName); + if (poolIt == pools.end()) { throw std::out_of_range("No pool named " + poolName); } - return it->second; + return poolIt->second; } ServerPolicy::ServerPolicy(const std::string& name_, const std::string& code): d_name(name_), d_perThreadPolicyCode(code), d_isLua(true), d_isFFI(true), d_isPerThread(true) diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.hh b/pdns/dnsdistdist/dnsdist-lbpolicies.hh index b92237861d..ce95addab9 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.hh +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.hh @@ -100,7 +100,7 @@ void setPoolPolicy(const string& poolName, std::shared_ptr policy) void addServerToPool(const string& poolName, std::shared_ptr server); void removeServerFromPool(const string& poolName, std::shared_ptr server); -const std::shared_ptr getDownstreamCandidates(const std::string& poolName); +std::shared_ptr getDownstreamCandidates(const std::string& poolName); std::shared_ptr firstAvailable(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq); diff --git a/pdns/dnsdistdist/dnsdist.cc b/pdns/dnsdistdist/dnsdist.cc index 6e92f45806..50d1de1851 100644 --- a/pdns/dnsdistdist/dnsdist.cc +++ b/pdns/dnsdistdist/dnsdist.cc @@ -3457,7 +3457,7 @@ int main(int argc, char** argv) /* create the default pool no matter what */ createPoolIfNotExists(""); - for (auto& backend : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) { + for (const auto& backend : dnsdist::configuration::getCurrentRuntimeConfiguration().d_backends) { if (backend->connected) { backend->start(); } diff --git a/pdns/dnsdistdist/test-dnsdisttcp_cc.cc b/pdns/dnsdistdist/test-dnsdisttcp_cc.cc index 8fa4a636bf..bcf6ea10aa 100644 --- a/pdns/dnsdistdist/test-dnsdisttcp_cc.cc +++ b/pdns/dnsdistdist/test-dnsdisttcp_cc.cc @@ -57,10 +57,10 @@ void handleResponseSent(const InternalQueryState& ids, double udiff, const Combo std::function& selectedBackend)> s_processQuery; -ProcessQueryResult processQuery(DNSQuestion& dq, std::shared_ptr& selectedBackend) +ProcessQueryResult processQuery(DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) { if (s_processQuery) { - return s_processQuery(dq, selectedBackend); + return s_processQuery(dnsQuestion, selectedBackend); } return ProcessQueryResult::Drop; @@ -1767,6 +1767,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) } } +// NOLINTNEXTLINE(readability-function-cognitive-complexity) BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { const auto tcpRecvTimeout = dnsdist::configuration::getCurrentRuntimeConfiguration().d_tcpRecvTimeout;