]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Buch of Coverity "Variable copied when it could be moved" cases
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 12 Feb 2025 13:07:51 +0000 (14:07 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 14 Feb 2025 09:30:46 +0000 (10:30 +0100)
pdns/arguments.cc
pdns/lua-base4.cc
pdns/recursordist/syncres.cc
pdns/zonemd.cc

index 72a2c1b99c5593b7f29e8f7ac3ffefd68b49ee38..c84c1fed8f6d2c96dbb0d29093990b31e9bf8d98 100644 (file)
@@ -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());
index a95f8e05afa7803fe5b63b5261991a5040aab346..141996d62d40517768f3ecda7637d9a09f03c3cb 100644 (file)
@@ -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());
index edd7e81fafaf92fd06c5091d29309e3720c3352d..9abf83f8641a7472aba1099e4c2d33105a3c39cc 100644 (file)
@@ -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));
     }
   }
 
index e427f41e80542e0f7c68158cbf3b24cc36664a9f..b320d15726aa9a5f2d02411376a5d5c7da098b2a 100644 (file)
@@ -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;