From: Otto Moerbeek Date: Tue, 27 Sep 2022 11:51:05 +0000 (+0200) Subject: Process comments from review X-Git-Tag: rec-4.9.0-alpha0~22^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=005c00d514bb65f6f364b767e28cb1b5d8378775;p=thirdparty%2Fpdns.git Process comments from review --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index be3792a620..3d68a17523 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1843,10 +1843,10 @@ bool checkForCacheHit(bool qnameParsed, unsigned int tag, const string& data, // This is only to get the proxyMapping suffixMatch stats right i the case of a PC hit if (t_proxyMapping && source != mappedSource) { - if (auto it = t_proxyMapping->lookup(source)) { - if (it->second.suffixMatchNode) { - if (it->second.suffixMatchNode->check(qname)) { - ++it->second.stats.suffixMatches; + if (const auto* found = t_proxyMapping->lookup(source)) { + if (found->second.suffixMatchNode) { + if (found->second.suffixMatchNode->check(qname)) { + ++found->second.stats.suffixMatches; } } } diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 3c96649c2c..a403aeef88 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -942,8 +942,9 @@ static ProxyMappingStats_t* pleaseGetProxyMappingStats() static string doGetProxyMappingStats() { ostringstream ret; - auto m = broadcastAccFunction(pleaseGetProxyMappingStats); - for (const auto& [key, entry] : m) { + ret << "subnet\t\t\tmatches\tsuffixmatches" << endl; + auto proxyMappingStats = broadcastAccFunction(pleaseGetProxyMappingStats); + for (const auto& [key, entry] : proxyMappingStats) { ret << key.toString() << '\t' << entry.netmaskMatches << '\t' << entry.suffixMatches << endl; } return ret.str(); @@ -1164,9 +1165,9 @@ static StatsMap toProxyMappingStatsMap(const string& name) const string pbasename = getPrometheusName(name); StatsMap entries; - auto m = broadcastAccFunction(pleaseGetProxyMappingStats); + auto proxyMappingStats = broadcastAccFunction(pleaseGetProxyMappingStats); size_t count = 0; - for (const auto& [key, entry] : m) { + for (const auto& [key, entry] : proxyMappingStats) { auto keyname = pbasename + "{netmask=\"" + key.toString() + "\",count=\""; auto sname1 = name + "-n-" + std::to_string(count); auto pname1 = keyname + "netmaskmatches\"}"; @@ -1920,7 +1921,7 @@ static void* pleaseSupplantProxyMapping(const ProxyMapping& pm) auto& newentry = newmapping->insert(nm); newentry.second = entry; if (t_proxyMapping) { - if (auto existing = t_proxyMapping->lookup(nm); existing != nullptr) { + if (const auto* existing = t_proxyMapping->lookup(nm); existing != nullptr) { newentry.second.stats = existing->second.stats; } }