From: Otto Moerbeek Date: Mon, 20 Nov 2023 16:06:35 +0000 (+0100) Subject: Another set of coverity fixes X-Git-Tag: dnsdist-1.9.0-alpha4~20^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c5a50dce9c57eb5e517313d71969deea16292be;p=thirdparty%2Fpdns.git Another set of coverity fixes --- diff --git a/pdns/ixfr.cc b/pdns/ixfr.cc index f2a6bcf7c4..ac041cb009 100644 --- a/pdns/ixfr.cc +++ b/pdns/ixfr.cc @@ -272,7 +272,7 @@ vector, vector>> getIXFRDeltas(const ComboAddr // we are up to date return ret; } - primarySOA = sr; + primarySOA = std::move(sr); ++primarySOACount; } else if (r.first.d_type == QType::SOA) { auto sr = getRR(r.first); diff --git a/pdns/recursordist/aggressive_nsec.cc b/pdns/recursordist/aggressive_nsec.cc index f31d2a7704..a91f644575 100644 --- a/pdns/recursordist/aggressive_nsec.cc +++ b/pdns/recursordist/aggressive_nsec.cc @@ -345,7 +345,7 @@ void AggressiveNSECCache::insertNSEC(const DNSName& zone, const DNSName& owner, ++d_entriesCount; } else { - zoneEntry->d_entries.replace(pair.first, {record.getContent(), signatures, realOwner, next, record.d_ttl}); + zoneEntry->d_entries.replace(pair.first, {record.getContent(), signatures, std::move(realOwner), next, record.d_ttl}); } } else { @@ -354,7 +354,7 @@ void AggressiveNSECCache::insertNSEC(const DNSName& zone, const DNSName& owner, ++d_entriesCount; } else { - zoneEntry->d_entries.replace(pair.first, {record.getContent(), signatures, owner, next, record.d_ttl}); + zoneEntry->d_entries.replace(pair.first, {record.getContent(), signatures, owner, std::move(next), record.d_ttl}); } } } @@ -503,7 +503,7 @@ bool AggressiveNSECCache::synthesizeFromNSEC3Wildcard(time_t now, const DNSName& return false; } - addToRRSet(now, wcSet, wcSignatures, name, doDNSSEC, ret, DNSResourceRecord::ANSWER); + addToRRSet(now, wcSet, std::move(wcSignatures), name, doDNSSEC, ret, DNSResourceRecord::ANSWER); /* no need for closest encloser proof, the wildcard is there */ // coverity[store_truncates_time_t] addRecordToRRSet(nextCloser.d_owner, QType::NSEC3, nextCloser.d_ttd - now, nextCloser.d_record, nextCloser.d_signatures, doDNSSEC, ret); @@ -527,7 +527,7 @@ bool AggressiveNSECCache::synthesizeFromNSECWildcard(time_t now, const DNSName& return false; } - addToRRSet(now, wcSet, wcSignatures, name, doDNSSEC, ret, DNSResourceRecord::ANSWER); + addToRRSet(now, wcSet, std::move(wcSignatures), name, doDNSSEC, ret, DNSResourceRecord::ANSWER); // coverity[store_truncates_time_t] addRecordToRRSet(nsec.d_owner, QType::NSEC, nsec.d_ttd - now, nsec.d_record, nsec.d_signatures, doDNSSEC, ret); @@ -883,7 +883,7 @@ bool AggressiveNSECCache::getDenial(time_t now, const DNSName& name, const QType ret.reserve(ret.size() + soaSet.size() + soaSignatures.size() + /* NSEC */ 1 + entry.d_signatures.size() + (needWildcard ? (/* NSEC */ 1 + wcEntry.d_signatures.size()) : 0)); - addToRRSet(now, soaSet, soaSignatures, zone, doDNSSEC, ret); + addToRRSet(now, soaSet, std::move(soaSignatures), zone, doDNSSEC, ret); addRecordToRRSet(entry.d_owner, QType::NSEC, entry.d_ttd - now, entry.d_record, entry.d_signatures, doDNSSEC, ret); if (needWildcard) { diff --git a/pdns/recursordist/lwres.cc b/pdns/recursordist/lwres.cc index d02e51eb54..010eaf4800 100644 --- a/pdns/recursordist/lwres.cc +++ b/pdns/recursordist/lwres.cc @@ -59,32 +59,29 @@ thread_local TCPOutConnectionManager t_tcp_manager; std::shared_ptr g_slogout; bool g_paddingOutgoing; -void remoteLoggerQueueData(RemoteLoggerInterface& r, const std::string& data) +void remoteLoggerQueueData(RemoteLoggerInterface& rli, const std::string& data) { - auto ret = r.queueData(data); + auto ret = rli.queueData(data); switch (ret) { case RemoteLoggerInterface::Result::Queued: break; case RemoteLoggerInterface::Result::PipeFull: { - const auto msg = RemoteLoggerInterface::toErrorString(ret); - const auto name = r.name(); - SLOG(g_log << Logger::Debug << name << ": " << msg << std::endl, - g_slog->withName(name)->info(Logr::Debug, msg)); + const auto& msg = RemoteLoggerInterface::toErrorString(ret); + SLOG(g_log << Logger::Debug << rli.name() << ": " << msg << std::endl, + g_slog->withName(rli.name())->info(Logr::Debug, msg)); break; } case RemoteLoggerInterface::Result::TooLarge: { - const auto msg = RemoteLoggerInterface::toErrorString(ret); - const auto name = r.name(); - SLOG(g_log << Logger::Notice << name << ": " << msg << endl, - g_slog->withName(name)->info(Logr::Debug, msg)); + const auto& msg = RemoteLoggerInterface::toErrorString(ret); + SLOG(g_log << Logger::Notice << rli.name() << ": " << msg << endl, + g_slog->withName(rli.name())->info(Logr::Debug, msg)); break; } case RemoteLoggerInterface::Result::OtherError: { - const auto msg = RemoteLoggerInterface::toErrorString(ret); - const auto name = r.name(); - SLOG(g_log << Logger::Warning << name << ": " << msg << std::endl, - g_slog->withName(name)->info(Logr::Warning, msg)); + const auto& msg = RemoteLoggerInterface::toErrorString(ret); + SLOG(g_log << Logger::Warning << rli.name() << ": " << msg << std::endl, + g_slog->withName(rli.name())->info(Logr::Warning, msg)); break; } } diff --git a/pdns/recursordist/negcache.cc b/pdns/recursordist/negcache.cc index 9b0b347180..5bea1a06b9 100644 --- a/pdns/recursordist/negcache.cc +++ b/pdns/recursordist/negcache.cc @@ -65,7 +65,7 @@ bool NegCache::getRootNXTrust(const DNSName& qname, const struct timeval& now, N // An 'ENT' QType entry, used as "whole name" in the neg-cache context. auto exists = get(lastLabel, QType::ENT, now, found, true, serveStale, refresh); if (exists && found.d_auth.isRoot()) { - negEntry = found; + negEntry = std::move(found); return true; } return false; diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index 9435f555e5..6409d6a0bf 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -2351,9 +2351,9 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr if (t_protobufServers.servers || t_outgoingProtobufServers.servers) { comboWriter->d_uuid = uniqueId; } - comboWriter->d_requestorId = requestorId; - comboWriter->d_deviceId = deviceId; - comboWriter->d_deviceName = deviceName; + comboWriter->d_requestorId = std::move(requestorId); + comboWriter->d_deviceId = std::move(deviceId); + comboWriter->d_deviceName = std::move(deviceName); comboWriter->d_kernelTimestamp = tval; comboWriter->d_proxyProtocolValues = std::move(proxyProtocolValues); comboWriter->d_routingTag = std::move(routingTag); diff --git a/pdns/recursordist/rec-lua-conf.cc b/pdns/recursordist/rec-lua-conf.cc index 83c48cd432..6b45c54a81 100644 --- a/pdns/recursordist/rec-lua-conf.cc +++ b/pdns/recursordist/rec-lua-conf.cc @@ -134,7 +134,7 @@ static void parseRPZParameters(rpzOptions_t& have, std::shared_ptr>>(have["tags"]); + const auto& tagsTable = boost::get>>(have["tags"]); std::unordered_set tags; for (const auto& tag : tagsTable) { tags.insert(tag.second); @@ -463,7 +463,7 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de log->info(Logr::Info, "Loading RPZ from file")); zone->setName(polName); loadRPZFromFile(filename, zone, defpol, defpolOverrideLocal, maxTTL); - lci.dfe.addZone(zone); + lci.dfe.addZone(std::move(zone)); SLOG(g_log << Logger::Warning << "Done loading RPZ from file '" << filename << "'" << endl, log->info(Logr::Info, "Done loading RPZ from file")); } @@ -557,7 +557,7 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de } } - lci.ztcConfigs[validZoneName] = conf; + lci.ztcConfigs[validZoneName] = std::move(conf); } catch (const std::exception& e) { SLOG(g_log << Logger::Error << "Problem configuring zoneToCache for zone '" << zoneName << "': " << e.what() << endl, diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 9cc1cde07a..478839ea41 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -590,7 +590,7 @@ void protobufLogResponse(const struct dnsheader* header, LocalStateHolderprotobufMaskV4 : luaconfsLocal->protobufMaskV6); - auto requestor = requestorNM.getMaskedNetwork(); + const auto& requestor = requestorNM.getMaskedNetwork(); pbMessage.setFrom(requestor); pbMessage.setFromPort(mappedSource.getPort()); } @@ -1348,12 +1348,12 @@ void parseACLs() } g_initialAllowFrom = allowFrom; - broadcastFunction([=] { return pleaseSupplantAllowFrom(allowFrom); }); + broadcastFunction([=] { return pleaseSupplantAllowFrom(std::move(allowFrom)); }); auto allowNotifyFrom = parseACL("allow-notify-from-file", "allow-notify-from", log); g_initialAllowNotifyFrom = allowNotifyFrom; - broadcastFunction([=] { return pleaseSupplantAllowNotifyFrom(allowNotifyFrom); }); + broadcastFunction([=] { return pleaseSupplantAllowNotifyFrom(std::move(allowNotifyFrom)); }); l_initialized = true; } diff --git a/pdns/recursordist/rec-tcp.cc b/pdns/recursordist/rec-tcp.cc index 7d1a8bb3d1..0eac47653b 100644 --- a/pdns/recursordist/rec-tcp.cc +++ b/pdns/recursordist/rec-tcp.cc @@ -362,9 +362,9 @@ static void doProcessTCPQuestion(std::unique_ptr& comboWriter, s const struct dnsheader* dnsheader = headerdata.get(); if (t_protobufServers.servers || t_outgoingProtobufServers.servers) { - comboWriter->d_requestorId = requestorId; - comboWriter->d_deviceId = deviceId; - comboWriter->d_deviceName = deviceName; + comboWriter->d_requestorId = std::move(requestorId); + comboWriter->d_deviceId = std::move(deviceId); + comboWriter->d_deviceName = std::move(deviceName); comboWriter->d_uuid = getUniqueID(); } diff --git a/pdns/recursordist/rec_channel.cc b/pdns/recursordist/rec_channel.cc index 3d78cd96c1..6abab97a35 100644 --- a/pdns/recursordist/rec_channel.cc +++ b/pdns/recursordist/rec_channel.cc @@ -217,5 +217,5 @@ RecursorControlChannel::Answer RecursorControlChannel::recv(int fd, unsigned int str.append(buffer, recvd); } - return {err, str}; + return {err, std::move(str)}; } diff --git a/pdns/recursordist/rec_channel_rec.cc b/pdns/recursordist/rec_channel_rec.cc index 186befa61c..b096e2d9ce 100644 --- a/pdns/recursordist/rec_channel_rec.cc +++ b/pdns/recursordist/rec_channel_rec.cc @@ -152,7 +152,7 @@ std::atomic* getDynMetric(const std::string& str, const std::stri name = getPrometheusName(name); } - auto ret = dynmetrics{new std::atomic(), name}; + auto ret = dynmetrics{new std::atomic(), std::move(name)}; (*dm)[str] = ret; return ret.d_ptr; } @@ -1208,7 +1208,7 @@ static StatsMap toRPZStatsMap(const string& name, const std::unordered_map