From: Oliver Chen Date: Fri, 13 Jun 2025 13:30:11 +0000 (+0000) Subject: Make clang-tidy checks happy X-Git-Tag: dnsdist-2.0.0-beta1~14^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bf87c8531927d149f0ad464cb1c1dc6f44c62655;p=thirdparty%2Fpdns.git Make clang-tidy checks happy --- diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.cc b/pdns/dnsdistdist/dnsdist-lbpolicies.cc index 2da5fe7675..97d51e7c5a 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.cc +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.cc @@ -259,10 +259,10 @@ shared_ptr roundrobin(const ServerPolicy::NumberedServerVector& return servers.at(candidates.at((counter++) % candidates.size()) - 1).second; } -shared_ptr orderedWrandUntag(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq) +shared_ptr orderedWrandUntag(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dnsq) { if (servers.empty()) { - return shared_ptr(); + return {}; } ServerPolicy::NumberedServerVector candidates; @@ -272,23 +272,23 @@ shared_ptr orderedWrandUntag(const ServerPolicy::NumberedServer unsigned int startIndex = 0; unsigned int curNumber = 1; - for (auto& d : servers) { - if (d.second->isUp() && d.second->d_config.order <= curOrder && (!dq->ids.qTag || dq->ids.qTag->count(d.second->getNameWithAddr()) == 0)) { - if (d.second->d_config.order < curOrder) { - curOrder = d.second->d_config.order; + for (const auto& svr : servers) { + if (svr.second->isUp() && svr.second->d_config.order <= curOrder && (!dnsq->ids.qTag || dnsq->ids.qTag->count(svr.second->getNameWithAddr()) == 0)) { + if (svr.second->d_config.order < curOrder) { + curOrder = svr.second->d_config.order; startIndex = candidates.end() - candidates.begin(); curNumber = 1; } - candidates.push_back(ServerPolicy::NumberedServer(curNumber++, d.second)); + candidates.push_back(ServerPolicy::NumberedServer(curNumber++, svr.second)); } } if (candidates.empty()) { - return shared_ptr(); + return {}; } ServerPolicy::NumberedServerVector selected(candidates.begin() + startIndex, candidates.end()); - return wrandom(selected, dq); + return wrandom(selected, dnsq); } std::shared_ptr getDownstreamCandidates(const std::string& poolName) diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.hh b/pdns/dnsdistdist/dnsdist-lbpolicies.hh index c8770580bd..291fa754ef 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.hh +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.hh @@ -109,7 +109,7 @@ std::shared_ptr whashedFromHash(const ServerPolicy::NumberedSer std::shared_ptr chashed(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq); std::shared_ptr chashedFromHash(const ServerPolicy::NumberedServerVector& servers, size_t hash); std::shared_ptr roundrobin(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq); -std::shared_ptr orderedWrandUntag(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dq); +std::shared_ptr orderedWrandUntag(const ServerPolicy::NumberedServerVector& servers, const DNSQuestion* dnsq); #include