From: Rosen Penev Date: Mon, 9 Dec 2024 00:51:27 +0000 (-0800) Subject: clang-tidy: convert to range for loop X-Git-Tag: dnsdist-2.0.0-alpha1~132^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=224fb70e987068a643660d9ea79f0e49fd922306;p=thirdparty%2Fpdns.git clang-tidy: convert to range for loop Found with modernize-loop-convert Signed-off-by: Rosen Penev --- diff --git a/pdns/mplexer.hh b/pdns/mplexer.hh index 13748fb59e..e23982d785 100644 --- a/pdns/mplexer.hh +++ b/pdns/mplexer.hh @@ -221,11 +221,11 @@ public: const auto tied = std::tie(tv.tv_sec, tv.tv_usec); auto& idx = writes ? d_writeCallbacks.get() : d_readCallbacks.get(); - for (auto it = idx.begin(); it != idx.end(); ++it) { - if (it->d_ttd.tv_sec == 0 || tied <= std::tie(it->d_ttd.tv_sec, it->d_ttd.tv_usec)) { + for (const auto& t : idx) { + if (t.d_ttd.tv_sec == 0 || tied <= std::tie(t.d_ttd.tv_sec, t.d_ttd.tv_usec)) { break; } - ret.emplace_back(it->d_fd, it->d_parameter); + ret.emplace_back(t.d_fd, t.d_parameter); } return ret; diff --git a/pdns/packethandler.cc b/pdns/packethandler.cc index 8483814d19..e63a5d9c8a 100644 --- a/pdns/packethandler.cc +++ b/pdns/packethandler.cc @@ -139,8 +139,7 @@ bool PacketHandler::addCDNSKEY(DNSPacket& p, std::unique_ptr& r) } bool haveOne=false; - DNSSECKeeper::keyset_t entryPoints = d_dk.getEntryPoints(p.qdomain); - for(const auto& value: entryPoints) { + for (const auto& value : d_dk.getEntryPoints(p.qdomain)) { if (!value.second.published) { continue; } @@ -173,8 +172,7 @@ bool PacketHandler::addDNSKEY(DNSPacket& p, std::unique_ptr& r) DNSZoneRecord rr; bool haveOne=false; - DNSSECKeeper::keyset_t keyset = d_dk.getKeys(p.qdomain); - for(const auto& value: keyset) { + for (const auto& value : d_dk.getKeys(p.qdomain)) { if (!value.second.published) { continue; } @@ -232,9 +230,7 @@ bool PacketHandler::addCDS(DNSPacket& p, std::unique_ptr& r) bool haveOne=false; - DNSSECKeeper::keyset_t keyset = d_dk.getEntryPoints(p.qdomain); - - for(auto const &value : keyset) { + for (const auto& value : d_dk.getEntryPoints(p.qdomain)) { if (!value.second.published) { continue; } @@ -1283,9 +1279,9 @@ bool PacketHandler::tryDNAME(DNSPacket& p, std::unique_ptr& r, DNSNam try { getBestDNAMESynth(p, target, rrset); if(!rrset.empty()) { - for(size_t i = 0; i < rrset.size(); i++) { - rrset.at(i).dr.d_place = DNSResourceRecord::ANSWER; - r->addRecord(std::move(rrset.at(i))); + for (auto& record : rrset) { + record.dr.d_place = DNSResourceRecord::ANSWER; + r->addRecord(std::move(record)); } return true; } @@ -1293,9 +1289,9 @@ bool PacketHandler::tryDNAME(DNSPacket& p, std::unique_ptr& r, DNSNam // Add the DNAME regardless, but throw to let the caller know we could not // synthesize a CNAME if(!rrset.empty()) { - for(size_t i = 0; i < rrset.size(); i++) { - rrset.at(i).dr.d_place = DNSResourceRecord::ANSWER; - r->addRecord(std::move(rrset.at(i))); + for (auto& record : rrset) { + record.dr.d_place = DNSResourceRecord::ANSWER; + r->addRecord(std::move(record)); } } throw e;