From 913209416877319307d5cfb9e3a8fbc5ca548f16 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Wed, 12 Feb 2025 14:07:51 +0100 Subject: [PATCH] Buch of Coverity "Variable copied when it could be moved" cases --- pdns/arguments.cc | 4 ++-- pdns/lua-base4.cc | 4 ++-- pdns/recursordist/syncres.cc | 2 +- pdns/zonemd.cc | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pdns/arguments.cc b/pdns/arguments.cc index 72a2c1b99c55..c84c1fed8f6d 100644 --- a/pdns/arguments.cc +++ b/pdns/arguments.cc @@ -588,7 +588,7 @@ void ArgvMap::gatherIncludes(const std::string& directory, const std::string& su string msg = fullName + " is not a regular file"; SLOG(g_log << Logger::Error << msg << std::endl, d_log->info(Logr::Error, "Unable to open non-regular file", "name", Logging::Loggable(fullName))); - throw ArgException(msg); + throw ArgException(std::move(msg)); } vec.emplace_back(fullName); } @@ -600,7 +600,7 @@ void ArgvMap::gatherIncludes(const std::string& directory, const std::string& su string msg = directory + " is not accessible: " + stringerror(err); SLOG(g_log << Logger::Error << msg << std::endl, d_log->error(Logr::Error, err, "Directory is not accessible", "name", Logging::Loggable(directory))); - throw ArgException(msg); + throw ArgException(std::move(msg)); } std::sort(vec.begin(), vec.end(), CIStringComparePOSIX()); diff --git a/pdns/lua-base4.cc b/pdns/lua-base4.cc index a95f8e05afa7..141996d62d40 100644 --- a/pdns/lua-base4.cc +++ b/pdns/lua-base4.cc @@ -52,7 +52,7 @@ void BaseLua4::includePath(const std::string& directory) { if (stat(fullName.c_str(), &statInfo) != 0 || !S_ISREG(statInfo.st_mode)) { string msg = fullName + " is not a regular file"; g_log << Logger::Error << msg << std::endl; - throw PDNSException(msg); + throw PDNSException(std::move(msg)); } vec.emplace_back(fullName); } @@ -63,7 +63,7 @@ void BaseLua4::includePath(const std::string& directory) { int err = errno; string msg = directory + " is not accessible: " + stringerror(err); g_log << Logger::Error << msg << std::endl; - throw PDNSException(msg); + throw PDNSException(std::move(msg)); } std::sort(vec.begin(), vec.end(), CIStringComparePOSIX()); diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index edd7e81fafaf..9abf83f8641a 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -1000,7 +1000,7 @@ int SyncRes::AuthDomain::getRecords(const DNSName& qname, const QType qtype, std // we hit a delegation point! DNSRecord dnsRecord = *ziter; dnsRecord.d_place = DNSResourceRecord::AUTHORITY; - records.push_back(dnsRecord); + records.push_back(std::move(dnsRecord)); } } diff --git a/pdns/zonemd.cc b/pdns/zonemd.cc index e427f41e8054..b320d15726aa 100644 --- a/pdns/zonemd.cc +++ b/pdns/zonemd.cc @@ -17,11 +17,11 @@ void pdns::ZoneMD::readRecords(ZoneParserTNG& zpt) } catch (const PDNSException& pe) { std::string err = "Bad record content in record for '" + dnsResourceRecord.qname.toStringNoDot() + "'|" + dnsResourceRecord.qtype.toString() + ": " + pe.reason; - throw PDNSException(err); + throw PDNSException(std::move(err)); } catch (const std::exception& e) { std::string err = "Bad record content in record for '" + dnsResourceRecord.qname.toStringNoDot() + "|" + dnsResourceRecord.qtype.toString() + "': " + e.what(); - throw PDNSException(err); + throw PDNSException(std::move(err)); } DNSRecord rec; rec.d_name = dnsResourceRecord.qname;