]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Various move vs copy improvements pointed by Coverity.
authorMiod Vallat <miod.vallat@powerdns.com>
Fri, 25 Apr 2025 07:39:38 +0000 (09:39 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Fri, 25 Apr 2025 10:37:19 +0000 (12:37 +0200)
modules/bindbackend/bindbackend2.cc
modules/geoipbackend/geoipbackend.cc
modules/lmdbbackend/lmdbbackend.cc
modules/lua2backend/lua2api2.hh
modules/remotebackend/remotebackend.cc
pdns/auth-primarycommunicator.cc
pdns/auth-secondarycommunicator.cc
pdns/communicator.hh
pdns/dbdnsseckeeper.cc
pdns/dnssecsigner.cc
pdns/tcpreceiver.cc

index 359aa50224430391e12be89256b8883bdd83c8cf..9b0f1fc075c01714be48f3b92f82941a12e82304 100644 (file)
@@ -540,8 +540,7 @@ void Bind2Backend::insertRecord(std::shared_ptr<recordstorage_t>& records, const
       g_log << Logger::Warning << msg << " ignored" << endl;
       return;
     }
-    else
-      throw PDNSException(msg);
+    throw PDNSException(std::move(msg));
   }
 
   //  bdr.qname.swap(bdr.qname);
index adcf60f1e6fbc62b3554818a499968f6cb5f3874..a7360b1b2656ddb3800ca348c0f0b180078279e2 100644 (file)
@@ -1009,7 +1009,7 @@ bool GeoIPBackend::getDomainKeys(const ZoneName& name, std::vector<DNSBackend::K
             }
             ifs.close();
             kd.content = content.str();
-            keys.push_back(kd);
+            keys.emplace_back(std::move(kd));
           }
         }
       }
index 0bfb41265c101634fb24aeac50fd997593b7a042..10ca370f4c371df3048b4bb95a29549114dabe28 100644 (file)
@@ -1582,7 +1582,7 @@ void LMDBBackend::lookupInternal(const QType& type, const DNSName& qdomain, int
     g_log << Logger::Warning << "Query " << ((long)(void*)this) << ": " << d_dtime.udiffNoReset() << " us to execute" << endl;
   }
 
-  d_lookupdomain = hunt;
+  d_lookupdomain = std::move(hunt);
 
   // Make sure we start with fresh data
   d_currentrrset.clear();
@@ -2049,7 +2049,7 @@ bool LMDBBackend::getDomainKeys(const ZoneName& name, std::vector<KeyData>& keys
   for (auto id : ids) {
     if (txn.get(id, key)) {
       KeyData kd{key.content, id, key.flags, key.active, key.published};
-      keys.push_back(kd);
+      keys.emplace_back(std::move(kd));
     }
   }
 
index 03289ef046e38ec8b7abd4f2ab3c6ce34d1be077..05882eaee8431ad71a61b0f87e93dc1775b2de5f 100644 (file)
@@ -387,7 +387,7 @@ public:
           g_log << Logger::Warning << "[" << getPrefix() << "] Unsupported key '" << item.first << "' in keydata result" << endl;
       }
       logResult("id=" << key.id << ",flags=" << key.flags << ",active=" << (key.active ? "true" : "false") << ",published=" << (key.published ? "true" : "false"));
-      keys.push_back(key);
+      keys.emplace_back(std::move(key));
     }
 
     return true;
index 8e05d651c88fb16ee8a76dcf1b16df8dedd43002..53804e34ab9f28d006fa4c0b560b0d0358a26318 100644 (file)
@@ -432,7 +432,7 @@ bool RemoteBackend::getDomainKeys(const ZoneName& name, std::vector<DNSBackend::
     key.active = asBool(jsonKey["active"]);
     key.published = boolFromJson(jsonKey, "published", true);
     key.content = stringFromJson(jsonKey, "content");
-    keys.push_back(key);
+    keys.emplace_back(std::move(key));
   }
 
   return true;
index 1513a958f623168b7999abccb9b34c1e5be55097..9f76d8913bda7eedf17c9f196761d3e34042fe07 100644 (file)
@@ -304,10 +304,12 @@ void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const
       return;
     }
     TSIGRecordContent trc;
-    if (tsigalgorithm.toStringNoDot() == "hmac-md5")
+    if (tsigalgorithm.toStringNoDot() == "hmac-md5") {
       trc.d_algoName = DNSName(tsigalgorithm.toStringNoDot() + ".sig-alg.reg.int.");
-    else
-      trc.d_algoName = tsigalgorithm;
+    }
+    else {
+      trc.d_algoName = std::move(tsigalgorithm);
+    }
     trc.d_time = time(nullptr);
     trc.d_fudge = 300;
     trc.d_origID = ntohs(notificationId);
index e63355af6ca09b45cd6c202a95ce5e465fcdab62..05a3679fe134ee5b6d5e76b2025085daa67819fb 100644 (file)
@@ -515,7 +515,7 @@ void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tsig
             status.soa_serial = sr->d_st.serial;
           }
 
-          replacement.push_back(rr);
+          replacement.emplace_back(std::move(rr));
         }
 
         di.backend->replaceRRSet(di.id, g.first.first.operator const DNSName&() + domain.operator const DNSName&(), QType(g.first.second), replacement);
@@ -772,7 +772,7 @@ void CommunicatorClass::suck(const ZoneName& domain, const ComboAddress& remote,
               auto sd = getRR<SOARecordContent>(dr);
               zs.soa_serial = sd->d_st.serial;
             }
-            rrs.push_back(rr);
+            rrs.emplace_back(std::move(rr));
           }
         }
         else {
index 2ff0e2d56c9ca0feaff8fcc5a026ad3baf864ffa..e95181c1186bd699aeb75ab0abe95a5cf94424c6 100644 (file)
@@ -91,7 +91,7 @@ public:
     nr.id = dns_random_uint16();
     nr.next = time(nullptr) + delay;
 
-    d_nqueue.push_back(nr);
+    d_nqueue.push_back(std::move(nr));
   }
 
   bool removeIf(const ComboAddress& remote, uint16_t id, const ZoneName& domain)
index c8ec62d910d049aebb3ae6ee919a446e3a200821..908fe8e09137a05065c202c3950ada8b57997433 100644 (file)
@@ -394,7 +394,7 @@ bool DNSSECKeeper::setNSEC3PARAM(const ZoneName& zname, const NSEC3PARAMRecordCo
 
   string descr = ns3p.getZoneRepresentation();
   vector<string> meta;
-  meta.push_back(descr);
+  meta.emplace_back(std::move(descr));
   if (d_keymetadb->setDomainMetadata(zname, "NSEC3PARAM", meta)) {
     meta.clear();
 
index 4b5032561bb5829fdcb66b7b54867a0a1d099938..a708dd9035b2e13e185074a712fc9fcb4ce1fa7d 100644 (file)
@@ -196,7 +196,7 @@ static bool getBestAuthFromSet(const set<ZoneName>& authSet, const DNSName& name
   ZoneName sname(name);
   do {
     if(authSet.find(sname) != authSet.end()) {
-      signer = sname;
+      signer = std::move(sname);
       return true;
     }
   }
index b5d22eea86a670fa6d158b66680b15eb76b35072..d5615e2c107a7c5ed13bfe3d8de308ce7b4ceefb 100644 (file)
@@ -1011,7 +1011,8 @@ send:
   typedef map<DNSName, NSECXEntry, CanonDNSNameCompare> nsecxrepo_t;
   nsecxrepo_t nsecxrepo;
 
-  ChunkedSigningPipe csp(targetZone, (securedZone && !presignedZone), ::arg().asNum("signing-threads", 1), ::arg().mustDo("workaround-11804") ? 1 : 100);
+  // std::move(targetZone) below is ok as it is no longer used afterwards
+  ChunkedSigningPipe csp(std::move(targetZone), (securedZone && !presignedZone), ::arg().asNum("signing-threads", 1), ::arg().mustDo("workaround-11804") ? 1 : 100);
 
   DNSName keyname;
   unsigned int udiff;