]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
clang-tidy: use const reference
authorRosen Penev <rosenp@gmail.com>
Thu, 5 Nov 2020 08:58:21 +0000 (00:58 -0800)
committerRosen Penev <rosenp@gmail.com>
Fri, 5 Feb 2021 01:23:24 +0000 (17:23 -0800)
Found with performance-for-range-copy

Signed-off-by: Rosen Penev <rosenp@gmail.com>
pdns/opensslsigners.cc
pdns/pdnsutil.cc
pdns/ws-auth.cc

index f2e319a9a7aa9686e090aae847b0b2c16a1d870a..e47e2705f1c381de4409d3212719b15c4d9fc1f0 100644 (file)
@@ -288,7 +288,7 @@ DNSCryptoKeyEngine::storvector_t OpenSSLRSADNSCryptoKeyEngine::convertToISCVecto
   }
   storvect.push_back(make_pair("Algorithm", algorithm));
 
-  for(outputs_t::value_type value :  outputs) {
+  for(const outputs_t::value_type& value :  outputs) {
     std::string tmp;
     tmp.resize(BN_num_bytes(value.second));
     int len = BN_bn2bin(value.second, reinterpret_cast<unsigned char*>(&tmp.at(0)));
index 19eb368a8e9e28da9ebbe8306335d16b556eb21d..a1fed7739cf8e4a8b8c81d23c545e432c0954faa 100644 (file)
@@ -224,7 +224,7 @@ static bool rectifyAllZones(DNSSECKeeper &dk, bool quiet = false)
   bool result = true;
 
   B.getAllDomains(&domainInfo);
-  for(DomainInfo di :  domainInfo) {
+  for(const DomainInfo& di :  domainInfo) {
     if (!quiet) {
       cerr<<"Rectifying "<<di.zone<<": ";
     }
@@ -1824,7 +1824,7 @@ static bool showZone(DNSSECKeeper& dk, const DNSName& zone, bool exportDS = fals
       cout << "keys: "<<endl;
     }
 
-    for(DNSSECKeeper::keyset_t::value_type value :  keyset) {
+    for(const DNSSECKeeper::keyset_t::value_type& value :  keyset) {
       string algname = DNSSECKeeper::algorithm2name(value.first.d_algorithm);
       if (!exportDS) {
         cout<<"ID = "<<value.second.id<<" ("<<DNSSECKeeper::keyTypeToString(value.second.keyType)<<")";
@@ -2751,7 +2751,7 @@ try
     B.getAllDomains(&domainInfo);
 
     unsigned int zonesSecured=0, zoneErrors=0;
-    for(DomainInfo di :  domainInfo) {
+    for(const DomainInfo& di :  domainInfo) {
       if(!dk.isSecuredZone(di.zone)) {
         cout<<"Securing "<<di.zone<<": ";
         if (secureZone(dk, di.zone)) {
@@ -3215,7 +3215,7 @@ try
        return 1;
      }
      bool found = false;
-     for(std::string tmpname :  meta) {
+     for(const std::string& tmpname :  meta) {
           if (tmpname == name) { found = true; break; }
      }
      if (!found) meta.push_back(name);
index 1a136da98232fec8306ee51dc0bd766b4220847f..5ff8b79ba65f90d068556195c7710c4e3e56e4e7 100644 (file)
@@ -562,7 +562,7 @@ static void gatherComments(const Json container, const DNSName& qname, const QTy
   c.qtype = qtype;
 
   time_t now = time(nullptr);
-  for (auto comment : container["comments"].array_items()) {
+  for (const auto& comment : container["comments"].array_items()) {
     c.modified_at = intFromJson(comment, "modified_at", now);
     c.content = stringFromJson(comment, "content");
     c.account = stringFromJson(comment, "account");
@@ -607,7 +607,7 @@ static void extractDomainInfoFromDocument(const Json document, boost::optional<D
 
   if (document["masters"].is_array()) {
     masters = vector<ComboAddress>();
-    for(auto value : document["masters"].array_items()) {
+    for(const auto& value : document["masters"].array_items()) {
       string master = value.string_value();
       if (master.empty())
         throw ApiException("Master can not be an empty string");
@@ -795,7 +795,7 @@ static void updateDomainSettingsFromDocument(UeberBackend& B, const DomainInfo&
 
   if (!document["master_tsig_key_ids"].is_null()) {
     vector<string> metadata;
-    for(auto value : document["master_tsig_key_ids"].array_items()) {
+    for(const auto& value : document["master_tsig_key_ids"].array_items()) {
       auto keyname(apiZoneIdToName(value.string_value()));
       DNSName keyAlgo;
       string keyContent;
@@ -811,7 +811,7 @@ static void updateDomainSettingsFromDocument(UeberBackend& B, const DomainInfo&
   }
   if (!document["slave_tsig_key_ids"].is_null()) {
     vector<string> metadata;
-    for(auto value : document["slave_tsig_key_ids"].array_items()) {
+    for(const auto& value : document["slave_tsig_key_ids"].array_items()) {
       auto keyname(apiZoneIdToName(value.string_value()));
       DNSName keyAlgo;
       string keyContent;
@@ -916,7 +916,7 @@ static void apiZoneMetadata(HttpRequest* req, HttpResponse *resp) {
 
     for (const auto& i : md) {
       Json::array entries;
-      for (string j : i.second)
+      for (const string& j : i.second)
         entries.push_back(j);
 
       Json::object key {
@@ -1657,7 +1657,7 @@ static void apiServerZones(HttpRequest* req, HttpResponse* resp) {
     }
 
     // create NS records if nameservers are given
-    for (auto value : nameservers.array_items()) {
+    for (const auto& value : nameservers.array_items()) {
       const string& nameserver = value.string_value();
       if (nameserver.empty())
         throw ApiException("Nameservers must be non-empty strings");