Skip to content

Commit

Permalink
std::get removals
Browse files Browse the repository at this point in the history
Can be replaced by structured bindings.

Signed-off-by: Rosen Penev <[email protected]>
  • Loading branch information
neheb committed Jan 9, 2024
1 parent 002da8e commit 74d8517
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
12 changes: 4 additions & 8 deletions pdns/lua-auth4.cc
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,11 @@ void AuthLua4::postLoad() {
}

bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const DNSResourceRecord& in, vector<DNSResourceRecord>& out) {
luacall_axfr_filter_t::result_type ret;
int rcode;

if (d_axfr_filter == nullptr) return false;
if (!d_axfr_filter) {
return false;
}

ret = d_axfr_filter(remote, zone, in);
rcode = std::get<0>(ret);
const auto& [rcode, rows] = d_axfr_filter(remote, zone, in);
if (rcode < 0) {
// no modification, handle normally
return false;
Expand All @@ -114,8 +112,6 @@ bool AuthLua4::axfrfilter(const ComboAddress& remote, const DNSName& zone, const
else
throw PDNSException("Cannot understand return code "+std::to_string(rcode)+" in axfr filter response");

const auto& rows = std::get<1>(ret);

try {
for(const auto& row: rows) {
DNSResourceRecord rec;
Expand Down
16 changes: 2 additions & 14 deletions pdns/pdnsutil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,7 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, con
}
}

for (const auto &svcb : svcbTargets) {
const auto& name = std::get<0>(svcb);
const auto& target = std::get<2>(svcb);
auto prio = std::get<1>(svcb);
auto v4hintsAuto = std::get<3>(svcb);
auto v6hintsAuto = std::get<4>(svcb);

for (const auto& [name, prio, target, v4hintsAuto, v6hintsAuto] : svcbTargets) {
if (name == target) {
cout<<"[Error] SVCB record "<<name<<" has itself as target."<<endl;
numerrors++;
Expand Down Expand Up @@ -690,13 +684,7 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, con
}
}

for (const auto &httpsRecord : httpsTargets) {
const auto& name = std::get<0>(httpsRecord);
const auto& target = std::get<2>(httpsRecord);
auto prio = std::get<1>(httpsRecord);
auto v4hintsAuto = std::get<3>(httpsRecord);
auto v6hintsAuto = std::get<4>(httpsRecord);

for (const auto& [name, prio, target, v4hintsAuto, v6hintsAuto] : httpsTargets) {
if (name == target) {
cout<<"[Error] HTTPS record "<<name<<" has itself as target."<<endl;
numerrors++;
Expand Down
11 changes: 4 additions & 7 deletions pdns/statbag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,12 @@ vector<pair<string, unsigned int> > StatBag::getRing(const string &name)
vector<pair<string, unsigned int> > ret;

if (d_comboRings.count(name)) {
typedef pair<SComboAddress, unsigned int> stor_t;
vector<stor_t> raw =d_comboRings[name].lock()->get();
for(const stor_t& stor : raw) {
ret.emplace_back(stor.first.ca.toString(), stor.second);
for (const auto& [addr, num] : d_comboRings[name].lock()->get()) {
ret.emplace_back(addr.ca.toString(), num);
}
} else if (d_dnsnameqtyperings.count(name)) {
auto raw = d_dnsnameqtyperings[name].lock()->get();
for (auto const &e : raw) {
ret.emplace_back(std::get<0>(e.first).toLogString() + "/" + std::get<1>(e.first).toString(), e.second);
for (auto const& [d, t] : d_dnsnameqtyperings[name].lock()->get()) {
ret.emplace_back(std::get<0>(d).toLogString() + "/" + std::get<1>(d).toString(), t);
}
}
return ret;
Expand Down

0 comments on commit 74d8517

Please sign in to comment.