From 0b0882f5d6457a0fae0d2acbb1085fab027b43b0 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Sep 2023 08:41:48 +0000 Subject: [PATCH 1/2] remove make_tuple and make_pair Not needed Signed-off-by: Rosen Penev --- modules/lmdbbackend/lmdbbackend.cc | 10 +++++----- pdns/bpf-filter.cc | 4 ++-- pdns/channel.hh | 2 +- pdns/dnsdist-dynbpf.cc | 2 +- pdns/dnsdist-lua.cc | 6 +++--- pdns/dnsdistdist/dnsdist-lbpolicies.cc | 4 ++-- pdns/gss_context.cc | 4 ++-- pdns/libssl.cc | 2 +- pdns/lua-auth4.cc | 2 +- pdns/lua-record.cc | 4 ++-- pdns/pdnsutil.cc | 4 ++-- pdns/recursordist/rec-lua-conf.cc | 2 +- pdns/recursordist/rec-zonetocache.cc | 6 +++--- pdns/recursordist/rec_channel_rec.cc | 10 +++++----- pdns/recursordist/recursor_cache.cc | 8 ++++---- pdns/recursordist/syncres.cc | 14 +++++++------- pdns/shuffle.cc | 2 +- pdns/signingpipe.cc | 4 ++-- pdns/slavecommunicator.cc | 4 ++-- pdns/statbag.hh | 2 +- pdns/test-ueberbackend_cc.cc | 10 +++++----- pdns/validate.cc | 2 +- 22 files changed, 54 insertions(+), 54 deletions(-) diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index 11168f326677..9b600f137064 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -88,7 +88,7 @@ std::pair LMDBBackend::getSchemaVersionAndShards(std::string if ((rc = mdb_env_open(env, filename.c_str(), MDB_NOSUBDIR | MDB_RDONLY, 0600)) != 0) { if (rc == ENOENT) { // we don't have a database yet! report schema 0, with 0 shards - return std::make_pair(0, 0); + return {0u, 0u}; } mdb_env_close(env); throw std::runtime_error("mdb_env_open failed"); @@ -109,7 +109,7 @@ std::pair LMDBBackend::getSchemaVersionAndShards(std::string // we pretend this means 5 mdb_txn_abort(txn); mdb_env_close(env); - return std::make_pair(5, 0); + return {5u, 0u}; } mdb_txn_abort(txn); mdb_env_close(env); @@ -127,7 +127,7 @@ std::pair LMDBBackend::getSchemaVersionAndShards(std::string // we pretend this means 5 mdb_txn_abort(txn); mdb_env_close(env); - return std::make_pair(5, 0); + return {5u, 0u}; } throw std::runtime_error("mdb_get pdns.schemaversion failed"); @@ -183,7 +183,7 @@ std::pair LMDBBackend::getSchemaVersionAndShards(std::string mdb_txn_abort(txn); mdb_env_close(env); - return std::make_pair(schemaversion, shards); + return {schemaversion, shards}; } namespace @@ -1702,7 +1702,7 @@ void LMDBBackend::getAllDomainsFiltered(vector* domains, const std:: di.id = iter.getID(); di.backend = this; - if (!zonemap.insert(std::make_pair(di.zone, di)).second) { + if (!zonemap.emplace(di.zone, di).second) { dups.insert(di.zone); } } diff --git a/pdns/bpf-filter.cc b/pdns/bpf-filter.cc index bb0c58e01d9c..ec6bd05c5528 100644 --- a/pdns/bpf-filter.cc +++ b/pdns/bpf-filter.cc @@ -832,7 +832,7 @@ std::vector > BPFFilter::getQNameStats() while (res == 0) { if (bpf_lookup_elem(map.d_fd.getHandle(), &nextKey, &value) == 0) { nextKey.qname[sizeof(nextKey.qname) - 1 ] = '\0'; - result.push_back(std::make_tuple(DNSName(reinterpret_cast(nextKey.qname), sizeof(nextKey.qname), 0, false), value.qtype, value.counter)); + result.emplace_back(DNSName(reinterpret_cast(nextKey.qname), sizeof(nextKey.qname), 0, false), value.qtype, value.counter); } res = bpf_get_next_key(map.d_fd.getHandle(), &nextKey, &nextKey); @@ -853,7 +853,7 @@ std::vector > BPFFilter::getQNameStats() while (res == 0) { if (bpf_lookup_elem(map.d_fd.getHandle(), &nextKey, &value) == 0) { nextKey.qname[sizeof(nextKey.qname) - 1 ] = '\0'; - result.push_back(std::make_tuple(DNSName(reinterpret_cast(nextKey.qname), sizeof(nextKey.qname), 0, false), key.qtype, value.counter)); + result.emplace_back(DNSName(reinterpret_cast(nextKey.qname), sizeof(nextKey.qname), 0, false), key.qtype, value.counter); } res = bpf_get_next_key(map.d_fd.getHandle(), &nextKey, &nextKey); diff --git a/pdns/channel.hh b/pdns/channel.hh index 2d848fc9eee3..d5a1ed6d7349 100644 --- a/pdns/channel.hh +++ b/pdns/channel.hh @@ -341,7 +341,7 @@ namespace channel setPipeBufferSize(receiver.getHandle(), pipeBufferSize); } - return std::pair(Sender(std::move(sender)), Receiver(std::move(receiver), throwOnEOF)); + return {Sender(std::move(sender)), Receiver(std::move(receiver), throwOnEOF)}; } } } diff --git a/pdns/dnsdist-dynbpf.cc b/pdns/dnsdist-dynbpf.cc index c19844de73de..9ede03fabf86 100644 --- a/pdns/dnsdist-dynbpf.cc +++ b/pdns/dnsdist-dynbpf.cc @@ -78,7 +78,7 @@ std::vector > DynBPFFilter:: for (const auto& stat : stats) { const container_t::iterator it = data->d_entries.find(stat.first); if (it != data->d_entries.end()) { - result.push_back(std::make_tuple(stat.first, stat.second, it->d_until)); + result.emplace_back(stat.first, stat.second, it->d_until); } } return result; diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index dcd7a5c3f5c4..34a6aaf51bb8 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -942,7 +942,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) LuaArray> ret; int count = 1; for (const auto& s : g_dstates.getCopy()) { - ret.push_back(make_pair(count++, s)); + ret.emplace_back(count++, s); } return ret; }); @@ -1683,7 +1683,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) const auto localPools = g_pools.getCopy(); for (const auto& entry : localPools) { const string& name = entry.first; - ret.push_back(make_pair(count++, name)); + ret.emplace_back(count++, name); } return ret; }); @@ -2380,7 +2380,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) LuaAssociativeTable customResponseHeaders; if (getOptionalValue(vars, "customResponseHeaders", customResponseHeaders) > 0) { for (auto const& headerMap : customResponseHeaders) { - std::pair headerResponse = std::make_pair(boost::to_lower_copy(headerMap.first), headerMap.second); + auto headerResponse = std::pair(boost::to_lower_copy(headerMap.first), headerMap.second); frontend->d_customResponseHeaders.insert(headerResponse); } } diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.cc b/pdns/dnsdistdist/dnsdist-lbpolicies.cc index 3aed13d54ab1..2a890f2e554a 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.cc +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.cc @@ -41,7 +41,7 @@ template static std::shared_ptr getLeastOutstanding(c size_t usableServers = 0; for (const auto& d : servers) { if (d.second->isUp()) { - poss[usableServers] = std::make_pair(std::make_tuple(d.second->outstanding.load(), d.second->d_config.order, d.second->getRelevantLatencyUsec()), d.first); + poss[usableServers] = std::pair(std::tuple(d.second->outstanding.load(), d.second->d_config.order, d.second->getRelevantLatencyUsec()), d.first); usableServers++; } } @@ -101,7 +101,7 @@ template static std::shared_ptr getValRandom(const Se sum += d.second->d_config.d_weight; } - poss[usableServers] = std::make_pair(sum, d.first); + poss[usableServers] = std::pair(sum, d.first); usableServers++; } } diff --git a/pdns/gss_context.cc b/pdns/gss_context.cc index b76ca1a21845..4d5b7e7412af 100644 --- a/pdns/gss_context.cc +++ b/pdns/gss_context.cc @@ -25,7 +25,7 @@ #ifndef ENABLE_GSS_TSIG -std::tuple GssContext::getCounts() { return std::make_tuple(0, 0, 0); } +std::tuple GssContext::getCounts() { return std::tuple(0, 0, 0); } bool GssContext::supported() { return false; } GssContext::GssContext() : d_error(GSS_CONTEXT_UNSUPPORTED), d_type(GSS_CONTEXT_NONE) {} @@ -490,7 +490,7 @@ bool GssContext::getPeerPrincipal(std::string& name) std::tuple GssContext::getCounts() { - return std::make_tuple(s_gss_init_creds.lock()->size(), s_gss_accept_creds.lock()->size(), s_gss_sec_context.lock()->size()); + return {s_gss_init_creds.lock()->size(), s_gss_accept_creds.lock()->size(), s_gss_sec_context.lock()->size()}; } void GssContext::processError(const std::string& method, OM_uint32 maj, OM_uint32 min) diff --git a/pdns/libssl.cc b/pdns/libssl.cc index 84610832a8d2..7be834826195 100644 --- a/pdns/libssl.cc +++ b/pdns/libssl.cc @@ -1032,7 +1032,7 @@ std::pair, std::vectorregisterFunction("getRealRemote", [](DNSPacket &p) { return p.getRealRemote(); }); d_lw->registerFunction("getLocal", [](DNSPacket &p) { return p.getLocal(); }); d_lw->registerFunction("getRemotePort", [](DNSPacket &p) { return p.getInnerRemote().getPort(); }); - d_lw->registerFunction()>("getQuestion", [](DNSPacket &p) { return std::make_tuple(p.qdomain.toString(), static_cast(p.qtype.getCode())); }); + d_lw->registerFunction()>("getQuestion", [](DNSPacket &p) { return std::tuple(p.qdomain.toString(), static_cast(p.qtype.getCode())); }); d_lw->registerFunction("setA", [](DNSPacket &p, bool a) { return p.setA(a); }); d_lw->registerFunction("setID", [](DNSPacket &p, unsigned int id) { return p.setID(static_cast(id)); }); d_lw->registerFunction("setRA", [](DNSPacket &p, bool ra) { return p.setRA(ra); }); diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index af27031a032a..e3c7f52c0b2f 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -60,8 +60,8 @@ class IsUpOracle for(const auto& m : rhs.opts) rhsoopts[m.first]=m.second; - return std::make_tuple(rem, url, oopts) < - std::make_tuple(rhs.rem, rhs.url, rhsoopts); + return std::tuple(rem, url, oopts) < + std::tuple(rhs.rem, rhs.url, rhsoopts); } }; struct CheckState diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index bdf0d3347b97..078ebe5d1136 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -484,7 +484,7 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, con } svcbAliases.insert(rr.qname); } - svcbTargets.emplace(std::make_tuple(rr.qname, svcbrc->getPriority(), svcbrc->getTarget(), svcbrc->autoHint(SvcParam::ipv4hint), svcbrc->autoHint(SvcParam::ipv6hint))); + svcbTargets.emplace(rr.qname, svcbrc->getPriority(), svcbrc->getTarget(), svcbrc->autoHint(SvcParam::ipv4hint), svcbrc->autoHint(SvcParam::ipv6hint)); svcbRecords.insert(rr.qname); break; case QType::HTTPS: @@ -495,7 +495,7 @@ static int checkZone(DNSSECKeeper &dk, UeberBackend &B, const DNSName& zone, con } httpsAliases.insert(rr.qname); } - httpsTargets.emplace(std::make_tuple(rr.qname, svcbrc->getPriority(), svcbrc->getTarget(), svcbrc->autoHint(SvcParam::ipv4hint), svcbrc->autoHint(SvcParam::ipv6hint))); + httpsTargets.emplace(rr.qname, svcbrc->getPriority(), svcbrc->getTarget(), svcbrc->autoHint(SvcParam::ipv4hint), svcbrc->autoHint(SvcParam::ipv6hint)); httpsRecords.insert(rr.qname); break; } diff --git a/pdns/recursordist/rec-lua-conf.cc b/pdns/recursordist/rec-lua-conf.cc index c53c95829a6a..ec169e454421 100644 --- a/pdns/recursordist/rec-lua-conf.cc +++ b/pdns/recursordist/rec-lua-conf.cc @@ -386,7 +386,7 @@ static void rpzPrimary(LuaConfigItems& lci, luaConfigDelayedThreads& delayedThre exit(1); // FIXME proper exit code? } - delayedThreads.rpzPrimaryThreads.push_back(std::make_tuple(primaries, defpol, defpolOverrideLocal, maxTTL, zoneIdx, tt, maxReceivedXFRMBytes, localAddress, axfrTimeout, refresh, sr, dumpFile)); + delayedThreads.rpzPrimaryThreads.emplace_back(primaries, defpol, defpolOverrideLocal, maxTTL, zoneIdx, tt, maxReceivedXFRMBytes, localAddress, axfrTimeout, refresh, sr, dumpFile); } // A wrapper class that loads the standard Lua defintions into the context, so that we can use things like pdns.A diff --git a/pdns/recursordist/rec-zonetocache.cc b/pdns/recursordist/rec-zonetocache.cc index 2f2cbfabec4e..408f486eacd3 100644 --- a/pdns/recursordist/rec-zonetocache.cc +++ b/pdns/recursordist/rec-zonetocache.cc @@ -289,7 +289,7 @@ vState ZoneData::dnssecValidate(pdns::ZoneMD& zonemd, size_t& zonemdCount) const if (nsecs.records.size() > 0 && nsecs.signatures.size() > 0) { // Valdidate the NSEC nsecValidationStatus = validateWithKeySet(d_now, d_zone, nsecs.records, nsecs.signatures, validKeys, std::nullopt); - csp.emplace(std::make_pair(d_zone, QType::NSEC), nsecs); + csp.emplace(std::pair(d_zone, QType::NSEC), nsecs); } else if (nsec3s.records.size() > 0 && nsec3s.signatures.size() > 0) { // Validate NSEC3PARAMS @@ -304,7 +304,7 @@ vState ZoneData::dnssecValidate(pdns::ZoneMD& zonemd, size_t& zonemdCount) const } // Valdidate the NSEC3 nsecValidationStatus = validateWithKeySet(d_now, zonemd.getNSEC3Label(), nsec3s.records, nsec3s.signatures, validKeys, std::nullopt); - csp.emplace(std::make_pair(zonemd.getNSEC3Label(), QType::NSEC3), nsec3s); + csp.emplace(std::pair(zonemd.getNSEC3Label(), QType::NSEC3), nsec3s); } else { d_log->info("No NSEC(3) records and/or RRSIGS found to deny ZONEMD"); @@ -438,7 +438,7 @@ void RecZoneToCache::maintainStates(const map& configs, mapemplace(std::make_pair(key, ProxyMappingCounts{entry.stats.netmaskMatches, entry.stats.suffixMatches})); + ret->emplace(key, ProxyMappingCounts{entry.stats.netmaskMatches, entry.stats.suffixMatches}); } } return ret; @@ -925,7 +925,7 @@ static RemoteLoggerStats_t* pleaseGetRemoteLoggerStats() if (t_protobufServers.servers) { for (const auto& server : *t_protobufServers.servers) { - ret->emplace(std::make_pair(server->address(), server->getStats())); + ret->emplace(server->address(), server->getStats()); } } return ret.release(); @@ -948,7 +948,7 @@ static RemoteLoggerStats_t* pleaseGetOutgoingRemoteLoggerStats() if (t_outgoingProtobufServers.servers) { for (const auto& server : *t_outgoingProtobufServers.servers) { - ret->emplace(std::make_pair(server->address(), server->getStats())); + ret->emplace(server->address(), server->getStats()); } } return ret.release(); @@ -961,7 +961,7 @@ static RemoteLoggerStats_t* pleaseGetFramestreamLoggerStats() if (t_frameStreamServersInfo.servers) { for (const auto& server : *t_frameStreamServersInfo.servers) { - ret->emplace(std::make_pair(server->address(), server->getStats())); + ret->emplace(server->address(), server->getStats()); } } return ret.release(); @@ -973,7 +973,7 @@ static RemoteLoggerStats_t* pleaseGetNODFramestreamLoggerStats() if (t_nodFrameStreamServersInfo.servers) { for (const auto& server : *t_nodFrameStreamServersInfo.servers) { - ret->emplace(std::make_pair(server->address(), server->getStats())); + ret->emplace(server->address(), server->getStats()); } } return ret.release(); diff --git a/pdns/recursordist/recursor_cache.cc b/pdns/recursordist/recursor_cache.cc index 0d237cd75089..60116e9ff141 100644 --- a/pdns/recursordist/recursor_cache.cc +++ b/pdns/recursordist/recursor_cache.cc @@ -240,7 +240,7 @@ MemRecursorCache::cache_t::const_iterator MemRecursorCache::getEntryUsingECSInde /* we have nothing more specific for you */ break; } - auto key = std::make_tuple(qname, qtype, boost::none, best); + auto key = std::tuple(qname, qtype, boost::none, best); auto entry = map.d_map.find(key); if (entry == map.d_map.end()) { /* ecsIndex is not up-to-date */ @@ -274,7 +274,7 @@ MemRecursorCache::cache_t::const_iterator MemRecursorCache::getEntryUsingECSInde } /* we have nothing specific, let's see if we have a generic one */ - auto key = std::make_tuple(qname, qtype, boost::none, Netmask()); + auto key = std::tuple(qname, qtype, boost::none, Netmask()); auto entry = map.d_map.find(key); if (entry != map.d_map.end()) { handleServeStaleBookkeeping(now, serveStale, entry); @@ -543,7 +543,7 @@ void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qt, // We only store with a tag if we have an ednsmask and the tag is available // We only store an ednsmask if we do not have a tag and we do have a mask. - auto key = std::make_tuple(qname, qt.getCode(), ednsmask ? routingTag : boost::none, (ednsmask && !routingTag) ? *ednsmask : Netmask()); + auto key = std::tuple(qname, qt.getCode(), ednsmask ? routingTag : boost::none, (ednsmask && !routingTag) ? *ednsmask : Netmask()); bool isNew = false; cache_t::iterator stored = lockedShard->d_map.find(key); if (stored == lockedShard->d_map.end()) { @@ -560,7 +560,7 @@ void MemRecursorCache::replace(time_t now, const DNSName& qname, const QType qt, if (isNew || stored->d_ttd <= now) { /* don't bother building an ecsIndex if we don't have any netmask-specific entries */ if (!routingTag && ednsmask && !ednsmask->empty()) { - auto ecsIndexKey = std::make_tuple(qname, qt.getCode()); + auto ecsIndexKey = std::tuple(qname, qt.getCode()); auto ecsIndex = lockedShard->d_ecsIndex.find(ecsIndexKey); if (ecsIndex == lockedShard->d_ecsIndex.end()) { ecsIndex = lockedShard->d_ecsIndex.insert(ECSIndexEntry(qname, qt.getCode())).first; diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index d6825567e775..2a5b46ae4eb3 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -878,7 +878,7 @@ bool SyncRes::doSpecialNamesResolve(const DNSName& qname, const QType qtype, con //! This is the 'out of band resolver', in other words, the authoritative server void SyncRes::AuthDomain::addSOA(std::vector& records) const { - SyncRes::AuthDomain::records_t::const_iterator ziter = d_records.find(std::make_tuple(getName(), QType::SOA)); + SyncRes::AuthDomain::records_t::const_iterator ziter = d_records.find(std::tuple(getName(), QType::SOA)); if (ziter != d_records.end()) { DNSRecord dr = *ziter; dr.d_place = DNSResourceRecord::AUTHORITY; @@ -958,7 +958,7 @@ int SyncRes::AuthDomain::getRecords(const DNSName& qname, const QType qtype, std DNSName wcarddomain(qname); while (wcarddomain != getName() && wcarddomain.chopOff()) { - range = d_records.equal_range(std::make_tuple(g_wildcarddnsname + wcarddomain)); + range = d_records.equal_range(std::tuple(g_wildcarddnsname + wcarddomain)); if (range.first == range.second) continue; @@ -982,7 +982,7 @@ int SyncRes::AuthDomain::getRecords(const DNSName& qname, const QType qtype, std /* Nothing for this name, no wildcard, let's see if there is some NS */ DNSName nsdomain(qname); while (nsdomain.chopOff() && nsdomain != getName()) { - range = d_records.equal_range(std::make_tuple(nsdomain, QType::NS)); + range = d_records.equal_range(std::tuple(nsdomain, QType::NS)); if (range.first == range.second) continue; @@ -1230,22 +1230,22 @@ void SyncRes::clearThrottle() bool SyncRes::isThrottled(time_t now, const ComboAddress& server, const DNSName& target, QType qtype) { - return s_throttle.lock()->shouldThrottle(now, std::make_tuple(server, target, qtype)); + return s_throttle.lock()->shouldThrottle(now, std::tuple(server, target, qtype)); } bool SyncRes::isThrottled(time_t now, const ComboAddress& server) { - return s_throttle.lock()->shouldThrottle(now, std::make_tuple(server, g_rootdnsname, 0)); + return s_throttle.lock()->shouldThrottle(now, std::tuple(server, g_rootdnsname, 0)); } void SyncRes::doThrottle(time_t now, const ComboAddress& server, time_t duration, unsigned int tries) { - s_throttle.lock()->throttle(now, std::make_tuple(server, g_rootdnsname, 0), duration, tries); + s_throttle.lock()->throttle(now, std::tuple(server, g_rootdnsname, 0), duration, tries); } void SyncRes::doThrottle(time_t now, const ComboAddress& server, const DNSName& name, QType qtype, time_t duration, unsigned int tries) { - s_throttle.lock()->throttle(now, std::make_tuple(server, name, qtype), duration, tries); + s_throttle.lock()->throttle(now, std::tuple(server, name, qtype), duration, tries); } uint64_t SyncRes::doDumpThrottleMap(int fd) diff --git a/pdns/shuffle.cc b/pdns/shuffle.cc index 0b890376550a..5f96fcd39bac 100644 --- a/pdns/shuffle.cc +++ b/pdns/shuffle.cc @@ -130,7 +130,7 @@ static uint16_t mapTypesToOrder(uint16_t type) void pdns::orderAndShuffle(vector& rrs, bool includingAdditionals) { std::stable_sort(rrs.begin(), rrs.end(), [](const DNSRecord& a, const DNSRecord& b) { - return std::make_tuple(a.d_place, mapTypesToOrder(a.d_type)) < std::make_tuple(b.d_place, mapTypesToOrder(b.d_type)); + return std::tuple(a.d_place, mapTypesToOrder(a.d_type)) < std::tuple(b.d_place, mapTypesToOrder(b.d_type)); }); shuffle(rrs, includingAdditionals); } diff --git a/pdns/signingpipe.cc b/pdns/signingpipe.cc index 2da3db7a24b6..0e0556056427 100644 --- a/pdns/signingpipe.cc +++ b/pdns/signingpipe.cc @@ -100,12 +100,12 @@ namespace { bool dedupLessThan(const DNSZoneRecord& a, const DNSZoneRecord &b) { - return std::make_tuple(a.dr.getContent()->getZoneRepresentation(), a.dr.d_ttl) < std::make_tuple(b.dr.getContent()->getZoneRepresentation(), b.dr.d_ttl); // XXX SLOW SLOW SLOW + return std::tuple(a.dr.getContent()->getZoneRepresentation(), a.dr.d_ttl) < std::tuple(b.dr.getContent()->getZoneRepresentation(), b.dr.d_ttl); // XXX SLOW SLOW SLOW } bool dedupEqual(const DNSZoneRecord& a, const DNSZoneRecord &b) { - return std::make_tuple(a.dr.getContent()->getZoneRepresentation(), a.dr.d_ttl) == std::make_tuple(b.dr.getContent()->getZoneRepresentation(), b.dr.d_ttl); // XXX SLOW SLOW SLOW + return std::tuple(a.dr.getContent()->getZoneRepresentation(), a.dr.d_ttl) == std::tuple(b.dr.getContent()->getZoneRepresentation(), b.dr.d_ttl); // XXX SLOW SLOW SLOW } } diff --git a/pdns/slavecommunicator.cc b/pdns/slavecommunicator.cc index e4a1ffc8d0cc..5029708ee67c 100644 --- a/pdns/slavecommunicator.cc +++ b/pdns/slavecommunicator.cc @@ -1052,7 +1052,7 @@ struct SlaveSenderReceiver { shuffle(dni.di.masters.begin(), dni.di.masters.end(), pdns::dns_random_engine()); try { - return std::make_tuple(dni.di.zone, + return {dni.di.zone, *dni.di.masters.begin(), d_resolver.sendResolve(*dni.di.masters.begin(), dni.localaddr, @@ -1060,7 +1060,7 @@ struct SlaveSenderReceiver QType::SOA, nullptr, dni.dnssecOk, dni.tsigkeyname, dni.tsigalgname, dni.tsigsecret) - ); + }; } catch(PDNSException& e) { throw runtime_error("While attempting to query freshness of '"+dni.di.zone.toLogString()+"': "+e.reason); diff --git a/pdns/statbag.hh b/pdns/statbag.hh index 7836e3c950ef..3e54e682d81b 100644 --- a/pdns/statbag.hh +++ b/pdns/statbag.hh @@ -121,7 +121,7 @@ public: if (it == d_dnsnameqtyperings.end()) { throw runtime_error("Attempting to account to nonexistent dnsname+qtype ring '"+std::string(name)+"'"); } - it->second.lock()->account(std::make_tuple(dnsname, qtype)); + it->second.lock()->account(std::tuple(dnsname, qtype)); } } diff --git a/pdns/test-ueberbackend_cc.cc b/pdns/test-ueberbackend_cc.cc index b11219a4a501..4a13aafad050 100644 --- a/pdns/test-ueberbackend_cc.cc +++ b/pdns/test-ueberbackend_cc.cc @@ -153,7 +153,7 @@ class SimpleBackend : public DNSBackend d_end = range.second; } else { - auto range = idx.equal_range(std::make_tuple(qdomain, qtype.getCode())); + auto range = idx.equal_range(std::tuple(qdomain, qtype.getCode())); d_iter = range.first; d_end = range.second; } @@ -200,7 +200,7 @@ class SimpleBackend : public DNSBackend bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override { const auto& idx = boost::multi_index::get(s_metadata.at(d_backendId)); - auto it = idx.find(std::make_tuple(name, kind)); + auto it = idx.find(std::tuple(name, kind)); if (it == idx.end()) { /* funnily enough, we are expected to return true even though we might not know that zone */ return true; @@ -213,7 +213,7 @@ class SimpleBackend : public DNSBackend bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) override { auto& idx = boost::multi_index::get(s_metadata.at(d_backendId)); - auto it = idx.find(std::make_tuple(name, kind)); + auto it = idx.find(std::tuple(name, kind)); if (it == idx.end()) { s_metadata.at(d_backendId).insert(SimpleMetaData(name, kind, meta)); return true; @@ -258,7 +258,7 @@ class SimpleBackendBestAuth : public SimpleBackend } auto& idx = records->get(); - auto range = idx.equal_range(std::make_tuple(best, QType::SOA)); + auto range = idx.equal_range(std::tuple(best, QType::SOA)); if (range.first == range.second) { return false; } @@ -1155,7 +1155,7 @@ BOOST_AUTO_TEST_CASE(test_multi_backends_metadata) { { // check that it has not been updated in the second backend - const auto& it = SimpleBackend::s_metadata[2].find(std::make_tuple(DNSName("powerdns.org."), "test-data-b")); + const auto& it = SimpleBackend::s_metadata[2].find(std::tuple(DNSName("powerdns.org."), "test-data-b")); BOOST_REQUIRE(it != SimpleBackend::s_metadata[2].end()); BOOST_REQUIRE_EQUAL(it->d_values.size(), 2U); BOOST_CHECK_EQUAL(it->d_values.at(0), "value1"); diff --git a/pdns/validate.cc b/pdns/validate.cc index eb96ca6bd426..decc2f3f64f8 100644 --- a/pdns/validate.cc +++ b/pdns/validate.cc @@ -118,7 +118,7 @@ static std::string getHashFromNSEC3(const DNSName& qname, const NSEC3RecordConte return result; } - auto key = std::make_tuple(qname, nsec3.d_salt, nsec3.d_iterations); + auto key = std::tuple(qname, nsec3.d_salt, nsec3.d_iterations); auto iter = cache.find(key); if (iter != cache.end()) { From 5ee090c322039a47717115674fb7cdd409b6a1fa Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 5 Sep 2023 12:40:50 +0200 Subject: [PATCH 2/2] Use at(i) instead of [i] --- pdns/dnsdistdist/dnsdist-lbpolicies.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pdns/dnsdistdist/dnsdist-lbpolicies.cc b/pdns/dnsdistdist/dnsdist-lbpolicies.cc index 2a890f2e554a..783b5ae21ae8 100644 --- a/pdns/dnsdistdist/dnsdist-lbpolicies.cc +++ b/pdns/dnsdistdist/dnsdist-lbpolicies.cc @@ -41,7 +41,7 @@ template static std::shared_ptr getLeastOutstanding(c size_t usableServers = 0; for (const auto& d : servers) { if (d.second->isUp()) { - poss[usableServers] = std::pair(std::tuple(d.second->outstanding.load(), d.second->d_config.order, d.second->getRelevantLatencyUsec()), d.first); + poss.at(usableServers) = std::pair(std::tuple(d.second->outstanding.load(), d.second->d_config.order, d.second->getRelevantLatencyUsec()), d.first); usableServers++; } } @@ -101,7 +101,7 @@ template static std::shared_ptr getValRandom(const Se sum += d.second->d_config.d_weight; } - poss[usableServers] = std::pair(sum, d.first); + poss.at(usableServers) = std::pair(sum, d.first); usableServers++; } }