]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Another bunch of coverity fixes
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 20 Nov 2023 15:36:11 +0000 (16:36 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 20 Nov 2023 15:36:11 +0000 (16:36 +0100)
pdns/recursordist/filterpo.hh
pdns/recursordist/reczones.cc
pdns/recursordist/secpoll-recursor.cc
pdns/recursordist/settings/cxxsupport.cc
pdns/recursordist/validate-recursor.cc
pdns/recursordist/ws-recursor.cc
pdns/tcounters.hh

index b5aa306bf737023d7e89f6d6ea0d66cbfb06f5f9..19bdcb87077b0a6996fcc17d04baa076d5081d45 100644 (file)
@@ -142,7 +142,7 @@ public:
         newZoneData = std::make_shared<PolicyZoneData>();
       }
       newZoneData->d_name = name;
-      d_zoneData = newZoneData;
+      d_zoneData = std::move(newZoneData);
     }
 
     const std::unordered_set<std::string>& getTags() const
@@ -420,7 +420,7 @@ public:
     if (newZone) {
       assureZones(zoneIdx);
       newZone->setPriority(zoneIdx);
-      d_zones[zoneIdx] = newZone;
+      d_zones[zoneIdx] = std::move(newZone);
     }
   }
 
index 8e09f19cbfd9447df86e19bedbeaf6d521aefaa5..fa763cd9ad704821ba47889c532a50be000b8d8b 100644 (file)
@@ -335,7 +335,7 @@ static void processApiZonesFile(shared_ptr<SyncRes::domainmap_t>& newMap, shared
 
 static void processForwardZonesFile(shared_ptr<SyncRes::domainmap_t>& newMap, shared_ptr<notifyset_t>& newSet, Logr::log_t log)
 {
-  const auto filename = ::arg()["forward-zones-file"];
+  const auto& filename = ::arg()["forward-zones-file"];
   if (filename.empty()) {
     return;
   }
@@ -493,7 +493,7 @@ static void processAllowNotifyFor(shared_ptr<notifyset_t>& newSet)
 
 static void processAllowNotifyForFile(shared_ptr<notifyset_t>& newSet, Logr::log_t log)
 {
-  const auto filename = ::arg()["allow-notify-for-file"];
+  const auto& filename = ::arg()["allow-notify-for-file"];
   if (filename.empty()) {
     return;
   }
index 9c165cb82179ba16d0674cc6a88b194915b79310..b54ae7dc5c71ca74d40a80f979160196d268a47c 100644 (file)
@@ -89,7 +89,7 @@ void doSecPoll(time_t* last_secpoll, Logr::log_t log)
     return;
   }
 
-  g_security_message = security_message;
+  g_security_message = std::move(security_message);
 
   auto rlog = vlog->withValues("securitymessage", Logging::Loggable(g_security_message), "status", Logging::Loggable(security_status));
   if (g_security_status != 1 && security_status == 1) {
index 2e58343bf4fd0ccc06c9772b36d4f6735576aab6..8a9e331ff52e1cad22932575adbdcf21df98e5d6 100644 (file)
@@ -95,7 +95,7 @@ void pdns::settings::rec::oldStyleForwardsFileToBridgeStruct(const std::string&
     }
     ::rust::Vec<::rust::String> addresses;
     stringtok(addresses, instructions, ",; ");
-    ForwardZone forwardzone{domain, addresses, recurse, allowNotify};
+    ForwardZone forwardzone{domain, std::move(addresses), recurse, allowNotify};
     vec.push_back(std::move(forwardzone));
   }
 }
@@ -320,7 +320,7 @@ pdns::settings::rec::YamlSettingsStatus pdns::settings::rec::readYamlSettings(co
       mergeYamlSubFile(yamlfile, yamlstruct, false, log);
     }
     yamlstruct.validate();
-    settings = yamlstruct;
+    settings = std::move(yamlstruct);
     return YamlSettingsStatus::OK;
   }
   catch (const ::rust::Error& ex) {
@@ -348,7 +348,7 @@ void pdns::settings::rec::readYamlAllowFromFile(const std::string& filename, ::r
   auto data = string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
   auto yamlvec = pdns::rust::settings::rec::parse_yaml_string_to_allow_from(data);
   pdns::rust::settings::rec::validate_allow_from(filename, yamlvec);
-  vec = yamlvec;
+  vec = std::move(yamlvec);
 }
 
 void pdns::settings::rec::readYamlForwardZonesFile(const std::string& filename, ::rust::Vec<pdns::rust::settings::rec::ForwardZone>& vec, Logr::log_t log)
@@ -362,7 +362,7 @@ void pdns::settings::rec::readYamlForwardZonesFile(const std::string& filename,
   auto data = string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
   auto yamlvec = pdns::rust::settings::rec::parse_yaml_string_to_forward_zones(data);
   pdns::rust::settings::rec::validate_forward_zones("forward_zones", yamlvec);
-  vec = yamlvec;
+  vec = std::move(yamlvec);
 }
 
 void pdns::settings::rec::readYamlAllowNotifyForFile(const std::string& filename, ::rust::Vec<::rust::String>& vec, Logr::log_t log)
@@ -376,7 +376,7 @@ void pdns::settings::rec::readYamlAllowNotifyForFile(const std::string& filename
   auto data = string(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
   auto yamlvec = pdns::rust::settings::rec::parse_yaml_string_to_allow_notify_for(data);
   pdns::rust::settings::rec::validate_allow_notify_for("allow-notify-for", yamlvec);
-  vec = yamlvec;
+  vec = std::move(yamlvec);
 }
 
 std::string pdns::settings::rec::to_arg(const AuthZone& authzone)
@@ -467,7 +467,7 @@ void pdns::settings::rec::to_yaml(::rust::Vec<ForwardZone>& field, const std::st
     boost::trim(headers.second);
     ::rust::Vec<::rust::String> addresses;
     stringtok(addresses, headers.second, " ;");
-    ForwardZone forwardzone{headers.first, addresses, recurse, false};
+    ForwardZone forwardzone{headers.first, std::move(addresses), recurse, false};
     field.push_back(std::move(forwardzone));
   }
 }
@@ -521,7 +521,7 @@ static void processLine(const std::string& arg, FieldMap& map, bool mainFile)
   pdns::rust::settings::rec::Value rustvalue = {false, 0, 0.0, "", {}, {}, {}};
   if (pdns::settings::rec::oldKVToBridgeStruct(var, val, section, fieldname, type_name, rustvalue)) {
     auto overriding = !mainFile && !incremental && !simpleRustType(type_name);
-    auto [existing, inserted] = map.emplace(std::pair{std::pair{section, fieldname}, pdns::rust::settings::rec::OldStyle{section, fieldname, var, type_name, rustvalue, overriding}});
+    auto [existing, inserted] = map.emplace(std::pair{std::pair{section, fieldname}, pdns::rust::settings::rec::OldStyle{section, fieldname, var, std::move(type_name), rustvalue, overriding}});
     if (!inserted) {
       // Simple values overwrite always
       existing->second.value.bool_val = rustvalue.bool_val;
@@ -622,7 +622,7 @@ std::string pdns::settings::rec::defaultsToYaml()
     string name = var;
     string val = arg().getDefault(var);
     if (pdns::settings::rec::oldKVToBridgeStruct(name, val, section, fieldname, type_name, rustvalue)) {
-      map.emplace(std::pair{std::pair{section, fieldname}, pdns::rust::settings::rec::OldStyle{section, fieldname, name, type_name, rustvalue, false}});
+      map.emplace(std::pair{std::pair{section, fieldname}, pdns::rust::settings::rec::OldStyle{section, fieldname, name, std::move(type_name), std::move(rustvalue), false}});
     }
   }
   // Convert the map to a vector, as CXX does not have any dictionary like support.
index 1a676792a9925478161ad4d6aea910670a292ed5..d7f2b99c909f983dcb3e1567e6141cd4d1a2bf35 100644 (file)
@@ -75,7 +75,7 @@ bool updateTrustAnchorsFromFile(const std::string& fname, map<DNSName, dsmap_t>&
     }
     SLOG(g_log << Logger::Info << "Read changed Trust Anchors from file, updating" << endl,
          log->info(Logr::Info, "Read changed Trust Anchors from file, updating"));
-    dsAnchors = newDSAnchors;
+    dsAnchors = std::move(newDSAnchors);
     return true;
   }
   catch (const std::exception& e) {
index 64c027da55bf006e99d6d4ba1f70b28742c2acc8..9baba3c5c69cdd51049578442b129a7f8d28ec65 100644 (file)
@@ -260,7 +260,7 @@ static void doCreateZone(const Json& document)
       pdns::rust::settings::rec::AuthZone authzone;
       authzone.zone = zonename;
       authzone.file = zonefilename;
-      pdns::rust::settings::rec::api_add_auth_zone(yamlAPiZonesFile, authzone);
+      pdns::rust::settings::rec::api_add_auth_zone(yamlAPiZonesFile, std::move(authzone));
     }
     else {
       apiWriteConfigFile(confbasename, "auth-zones+=" + zonename + "=" + zonefilename);
@@ -275,7 +275,7 @@ static void doCreateZone(const Json& document)
       for (const auto& value : document["servers"].array_items()) {
         forward.forwarders.emplace_back(value.string_value());
       }
-      pdns::rust::settings::rec::api_add_forward_zone(yamlAPiZonesFile, forward);
+      pdns::rust::settings::rec::api_add_forward_zone(yamlAPiZonesFile, std::move(forward));
     }
     else {
       string serverlist;
index 9689de4669961330387df3dc6af8301d6507bdaf..5225d725ddd51078305801224069c4f8f663f028 100644 (file)
@@ -151,6 +151,7 @@ public:
   }
 
   template <typename Enum>
+  // coverity[auto_causes_copy]
   auto snapAt(Enum index)
   {
     return d_snapshot.lock()->at(index);