]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Apply suggestions from code review
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 6 Oct 2025 14:11:51 +0000 (16:11 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 6 Oct 2025 14:50:27 +0000 (16:50 +0200)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
pdns/dnsdistdist/dnsdist-lbpolicies.cc
pdns/dnsdistdist/dnsdist-lua.cc

index 56c6fcda20854851bcedb798c8edd33899cabed6..dae8630e53dbcd821d8fb13a934595ca049d351d 100644 (file)
@@ -71,10 +71,8 @@ static std::optional<ServerPolicy::SelectedServerPosition> getLeastOutstanding(c
 }
 
 // get server with least outstanding queries, and within those, with the lowest order, and within those: the fastest
-std::optional<ServerPolicy::SelectedServerPosition> leastOutstanding(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq)
+std::optional<ServerPolicy::SelectedServerPosition> 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<ServerPolicy::SelectedServerPosition> leastOutstanding(const Serve
 
 std::optional<ServerPolicy::SelectedServerPosition> 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<ServerPolicy::SelectedServerPosition> valrandom(const unsig
   return getValRandom(servers, poss, val, targetLoad);
 }
 
-std::optional<ServerPolicy::SelectedServerPosition> wrandom(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq)
+std::optional<ServerPolicy::SelectedServerPosition> wrandom(const ServerPolicy::NumberedServerVector& servers, [[maybe_unused]] const DNSQuestion* dnsQuestion)
 {
-  (void)dq;
   return valrandom(dns_random_uint32(), servers);
 }
 
@@ -240,9 +237,8 @@ std::optional<ServerPolicy::SelectedServerPosition> chashed(const ServerPolicy::
   return chashedFromHash(servers, dq->ids.qname.hash(hashPerturbation));
 }
 
-std::optional<ServerPolicy::SelectedServerPosition> roundrobin(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq)
+std::optional<ServerPolicy::SelectedServerPosition> roundrobin(const ServerPolicy::NumberedServerVector& servers, [[maybe_unused]] const DNSQuestion* dnsQuestion)
 {
-  (void)dq;
   if (servers.empty()) {
     return std::nullopt;
   }
index 422dcf4032332d94a4edc90c1f0d483efe9646c1..24af5ce78ba359c1e9870824cf4c352fc20c65ad 100644 (file)
@@ -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 += ", ";
           }