Skip to content

Commit

Permalink
dnsdist: Fix static analysis warnings (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Jul 5, 2024
1 parent 1179a8f commit 528448e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions pdns/dnsdistdist/dnsdist-dynblocks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<time_t>(metricsCollectionInterval);
time_t nextMetricsGeneration = now + metricsGenerationInterval;

while (true) {
Expand Down Expand Up @@ -813,7 +813,7 @@ void DynBlockMaintenance::run()
purgeExpired(tspec);

now = time(nullptr);
nextExpiredPurge = now + purgeInterval;
nextExpiredPurge = now + static_cast<time_t>(purgeInterval);
}
}
catch (const std::exception& e) {
Expand Down
14 changes: 7 additions & 7 deletions pdns/dnsdistdist/dnsdist-lbpolicies.cc
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ shared_ptr<DownstreamState> roundrobin(const ServerPolicy::NumberedServerVector&
return servers.at(candidates.at((counter++) % candidates.size()) - 1).second;
}

const std::shared_ptr<const ServerPolicy::NumberedServerVector> getDownstreamCandidates(const std::string& poolName)
std::shared_ptr<const ServerPolicy::NumberedServerVector> getDownstreamCandidates(const std::string& poolName)
{
std::shared_ptr<ServerPool> pool = getPool(poolName);
return pool->getServers();
Expand All @@ -266,9 +266,9 @@ std::shared_ptr<ServerPool> 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;
}
}

Expand Down Expand Up @@ -323,12 +323,12 @@ void removeServerFromPool(const string& poolName, std::shared_ptr<DownstreamStat
std::shared_ptr<ServerPool> 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)
Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/dnsdist-lbpolicies.hh
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void setPoolPolicy(const string& poolName, std::shared_ptr<ServerPolicy> policy)
void addServerToPool(const string& poolName, std::shared_ptr<DownstreamState> server);
void removeServerFromPool(const string& poolName, std::shared_ptr<DownstreamState> server);

const std::shared_ptr<const ServerPolicy::NumberedServerVector> getDownstreamCandidates(const std::string& poolName);
std::shared_ptr<const ServerPolicy::NumberedServerVector> getDownstreamCandidates(const std::string& poolName);

std::shared_ptr<DownstreamState> firstAvailable(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq);

Expand Down
2 changes: 1 addition & 1 deletion pdns/dnsdistdist/dnsdist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
5 changes: 3 additions & 2 deletions pdns/dnsdistdist/test-dnsdisttcp_cc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ void handleResponseSent(const InternalQueryState& ids, double udiff, const Combo

std::function<ProcessQueryResult(DNSQuestion& dq, std::shared_ptr<DownstreamState>& selectedBackend)> s_processQuery;

ProcessQueryResult processQuery(DNSQuestion& dq, std::shared_ptr<DownstreamState>& selectedBackend)
ProcessQueryResult processQuery(DNSQuestion& dnsQuestion, std::shared_ptr<DownstreamState>& selectedBackend)
{
if (s_processQuery) {
return s_processQuery(dq, selectedBackend);
return s_processQuery(dnsQuestion, selectedBackend);
}

return ProcessQueryResult::Drop;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 528448e

Please sign in to comment.