Skip to content

Commit

Permalink
clang-tidy: convert to range for loop
Browse files Browse the repository at this point in the history
Found with modernize-loop-convert

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Jan 22, 2025
1 parent 3d4ddfb commit 224fb70
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
6 changes: 3 additions & 3 deletions pdns/mplexer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,11 @@ public:
const auto tied = std::tie(tv.tv_sec, tv.tv_usec);
auto& idx = writes ? d_writeCallbacks.get<TTDOrderedTag>() : d_readCallbacks.get<TTDOrderedTag>();

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;
Expand Down
22 changes: 9 additions & 13 deletions pdns/packethandler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ bool PacketHandler::addCDNSKEY(DNSPacket& p, std::unique_ptr<DNSPacket>& 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;
}
Expand Down Expand Up @@ -173,8 +172,7 @@ bool PacketHandler::addDNSKEY(DNSPacket& p, std::unique_ptr<DNSPacket>& 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;
}
Expand Down Expand Up @@ -232,9 +230,7 @@ bool PacketHandler::addCDS(DNSPacket& p, std::unique_ptr<DNSPacket>& 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;
}
Expand Down Expand Up @@ -1283,19 +1279,19 @@ bool PacketHandler::tryDNAME(DNSPacket& p, std::unique_ptr<DNSPacket>& 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;
}
} catch (const std::range_error &e) {
// 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;
Expand Down

0 comments on commit 224fb70

Please sign in to comment.