From 136bfb428a537c94161d428747991a78d432e00f Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 6 Oct 2025 16:11:51 +0200 Subject: [PATCH] dnsdist: Apply suggestions from code review Signed-off-by: Remi Gacogne --- pdns/dnsdistdist/dnsdist-lbpolicies.cc | 16 ++++++---------- pdns/dnsdistdist/dnsdist-lua.cc | 3 +-- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.cc b/pdns/dnsdistdist/dnsdist-lbpolicies.cc index 56c6fcda20..dae8630e53 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.cc +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.cc @@ -71,10 +71,8 @@ static std::optional getLeastOutstanding(c } // get server with least outstanding queries, and within those, with the lowest order, and within those: the fastest -std::optional leastOutstanding(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq) +std::optional leastOutstanding(const ServerPolicy::NumberedServerVector& servers, [[maybe_unused]] const DNSQuestion* dnsQuestion) { - (void)dq; - if (servers.size() == 1 && servers[0].second->isUp()) { return 1; } @@ -84,9 +82,9 @@ std::optional leastOutstanding(const Serve std::optional firstAvailable(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq) { - for (auto& d : servers) { - if (d.second->isUp() && (!d.second->d_qpsLimiter || d.second->d_qpsLimiter->checkOnly())) { - return d.first; + for (auto& server : servers) { + if (server.second->isUp() && (!server.second->d_qpsLimiter || server.second->d_qpsLimiter->checkOnly())) { + return server.first; } } return leastOutstanding(servers, dq); @@ -158,9 +156,8 @@ static std::optional valrandom(const unsig return getValRandom(servers, poss, val, targetLoad); } -std::optional wrandom(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq) +std::optional wrandom(const ServerPolicy::NumberedServerVector& servers, [[maybe_unused]] const DNSQuestion* dnsQuestion) { - (void)dq; return valrandom(dns_random_uint32(), servers); } @@ -240,9 +237,8 @@ std::optional chashed(const ServerPolicy:: return chashedFromHash(servers, dq->ids.qname.hash(hashPerturbation)); } -std::optional roundrobin(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq) +std::optional roundrobin(const ServerPolicy::NumberedServerVector& servers, [[maybe_unused]] const DNSQuestion* dnsQuestion) { - (void)dq; if (servers.empty()) { return std::nullopt; } diff --git a/pdns/dnsdistdist/dnsdist-lua.cc b/pdns/dnsdistdist/dnsdist-lua.cc index 422dcf4032..24af5ce78b 100644 --- a/pdns/dnsdistdist/dnsdist-lua.cc +++ b/pdns/dnsdistdist/dnsdist-lua.cc @@ -1642,8 +1642,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) } string servers; - const auto& poolServers = pool.getServers(); - for (const auto& server : poolServers) { + for (const auto& server : pool.getServers()) { if (!servers.empty()) { servers += ", "; } -- 2.47.3