]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
clang-tidy the previous clang-tidy run
authorMiod Vallat <miod.vallat@powerdns.com>
Fri, 11 Apr 2025 13:58:11 +0000 (15:58 +0200)
committerMiod Vallat <miod.vallat@powerdns.com>
Fri, 11 Apr 2025 14:40:22 +0000 (16:40 +0200)
modules/bindbackend/bindbackend2.cc
modules/geoipbackend/geoipbackend.cc
modules/lmdbbackend/lmdbbackend.cc
pdns/auth-primarycommunicator.cc
pdns/auth-secondarycommunicator.cc
pdns/dbdnsseckeeper.cc
pdns/dnssecsigner.cc
pdns/test-communicator_hh.cc
pdns/test-ueberbackend_cc.cc

index 77525b7aa7395d61202d0b0b1d490293fe891916..ae53d2e38846acf45e39167d9c42657b66d27685 100644 (file)
@@ -1295,8 +1295,9 @@ bool Bind2Backend::list(const ZoneName& /* target */, int domainId, bool /* incl
 {
   BB2DomainInfo bbd;
 
-  if (!safeGetBBDomainInfo(domainId, &bbd))
+  if (!safeGetBBDomainInfo(domainId, &bbd)) {
     return false;
+  }
 
   d_handle.reset();
   DLOG(g_log << "Bind2Backend constructing handle for list of " << domainId << endl);
@@ -1380,8 +1381,9 @@ bool Bind2Backend::autoPrimaryBackend(const string& ipAddress, const ZoneName& /
   }
   c_if.close();
 
-  if (sip != ipAddress) // ip not found in authorization list - reject
+  if (sip != ipAddress) // ip not found in authorization list - reject
     return false;
+  }
 
   // ip authorized as autoprimary - accept
   *backend = this;
@@ -1443,7 +1445,7 @@ bool Bind2Backend::createSecondaryDomain(const string& ipAddress, const ZoneName
 
   BB2DomainInfo bbd = createDomainEntry(domain, filename);
   bbd.d_kind = DomainInfo::Secondary;
-  bbd.d_primaries.push_back(ComboAddress(ipAddress, 53));
+  bbd.d_primaries.emplace_back(ComboAddress(ipAddress, 53));
   bbd.setCtime();
   safePutBBDomainInfo(bbd);
 
index b096ec012b506efe424b18a2723020ead6263be8..a608f1b4a8e2c86dfda0b9240fff005032212878 100644 (file)
@@ -1112,7 +1112,7 @@ bool GeoIPBackend::activateDomainKey(const ZoneName& name, unsigned int keyId)
         for (size_t i = 0; i < glob_result.gl_pathc; i++) {
           if (regexec(&reg, glob_result.gl_pathv[i], 5, regm, 0) == 0) {
             auto kid = pdns::checked_stoi<unsigned int>(glob_result.gl_pathv[i] + regm[3].rm_so);
-            if (kid == keyId && !strcmp(glob_result.gl_pathv[i] + regm[4].rm_so, "0")) {
+            if (kid == keyId && strcmp(glob_result.gl_pathv[i] + regm[4].rm_so, "0") == 0) { // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
               ostringstream newpath;
               newpath << getArg("dnssec-keydir") << "/" << dom.domain.toStringNoDot() << "." << pdns::checked_stoi<unsigned int>(glob_result.gl_pathv[i] + regm[2].rm_so) << "." << kid << ".1.key";
               if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) {
@@ -1147,7 +1147,7 @@ bool GeoIPBackend::deactivateDomainKey(const ZoneName& name, unsigned int keyId)
         for (size_t i = 0; i < glob_result.gl_pathc; i++) {
           if (regexec(&reg, glob_result.gl_pathv[i], 5, regm, 0) == 0) {
             auto kid = pdns::checked_stoi<unsigned int>(glob_result.gl_pathv[i] + regm[3].rm_so);
-            if (kid == keyId && !strcmp(glob_result.gl_pathv[i] + regm[4].rm_so, "1")) {
+            if (kid == keyId && strcmp(glob_result.gl_pathv[i] + regm[4].rm_so, "1") == 0) { // NOLINT(cppcoreguidelines-pro-bounds-pointer-arithmetic)
               ostringstream newpath;
               newpath << getArg("dnssec-keydir") << "/" << dom.domain.toStringNoDot() << "." << pdns::checked_stoi<unsigned int>(glob_result.gl_pathv[i] + regm[2].rm_so) << "." << kid << ".0.key";
               if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) {
index 69143e4cd6a8282b79fb481296c70fc15b48212e..267816bbcd55db772476825be1e70cf7328a2263 100644 (file)
@@ -1672,7 +1672,7 @@ bool LMDBBackend::getDomainInfo(const ZoneName& domain, DomainInfo& info, bool g
     // if (!found) {
     //   return false;
     // }
-    if (!(info.id = txn.get<0>(domain, info))) {
+    if ((info.id = txn.get<0>(domain, info)) == 0) {
       return false;
     }
 
@@ -2346,7 +2346,7 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zone
   if (cursor.lower_bound(matchkey, key, val)) {
     // cout << "Hit end of database, bummer"<<endl;
     cursor.last(key, val);
-    if (co.getDomainID(key.getNoStripHeader<string_view>()) == domainId) {
+    if (compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) == domainId) {
       before = co.getQName(key.getNoStripHeader<string_view>()) + zonename;
       after = zonename;
     }
@@ -2354,9 +2354,9 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zone
     // cout << "We were at end of database, but this zone is not there?!"<<endl;
     return true;
   }
-  // cout<<"Cursor is at "<<co.getQName(key.get<string_view>()) <<", in zone id "<<co.getDomainID(key.get<string_view>())<< endl;
+  // cout<<"Cursor is at "<<co.getQName(key.get<string_view>()) <<", in zone id "<<compoundOrdername::getDomainID(key.get<string_view>())<< endl;
 
-  if (co.getQType(key.getNoStripHeader<string_view>()).getCode() && co.getDomainID(key.getNoStripHeader<string_view>()) == domainId && co.getQName(key.getNoStripHeader<string_view>()) == qname2) { // don't match ENTs
+  if (compoundOrdername::getQType(key.getNoStripHeader<string_view>()).getCode() != 0 && compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) == domainId && compoundOrdername::getQName(key.getNoStripHeader<string_view>()) == qname2) { // don't match ENTs
     // cout << "Had an exact match!"<<endl;
     before = qname2 + zonename;
     int rc;
@@ -2365,14 +2365,15 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zone
       if (rc)
         break;
 
-      if (co.getDomainID(key.getNoStripHeader<string_view>()) == domainId && key.getNoStripHeader<StringView>().rfind(matchkey, 0) == 0)
+      if (compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) == domainId && key.getNoStripHeader<StringView>().rfind(matchkey, 0) == 0) {
         continue;
+      }
       LMDBResourceRecord lrr;
       deserializeFromBuffer(val.get<StringView>(), lrr);
       if (co.getQType(key.getNoStripHeader<string_view>()).getCode() && (lrr.auth || co.getQType(key.getNoStripHeader<string_view>()).getCode() == QType::NS))
         break;
     }
-    if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
+    if (rc != 0 || compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
       // cout << "We hit the end of the zone or database. 'after' is apex" << endl;
       after = zonename;
       return false;
@@ -2381,7 +2382,7 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zone
     return true;
   }
 
-  if (co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
+  if (compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
     // cout << "Ended up in next zone, 'after' is zonename" <<endl;
     after = zonename;
     // cout << "Now hunting for previous" << endl;
@@ -2393,8 +2394,8 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zone
         return false;
       }
 
-      if (co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
-        // cout<<"Reversed into zone, but found wrong zone id " << co.getDomainID(key.getNoStripHeader<string_view>()) << " != "<<domainId<<endl;
+      if (compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
+        // cout<<"Reversed into zone, but found wrong zone id " << compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) << " != "<<domainId<<endl;
         // "this can't happen"
         return false;
       }
@@ -2425,7 +2426,7 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zone
     int rc = cursor.next(key, val);
     if (!rc)
       ++skips;
-    if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
+    if (rc != 0 || compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
       // cout << "  oops, hit end of database or zone. This means after is apex" <<endl;
       after = zonename;
       break;
@@ -2437,7 +2438,7 @@ bool LMDBBackend::getBeforeAndAfterNames(uint32_t domainId, const ZoneName& zone
 
   for (;;) {
     int rc = cursor.prev(key, val);
-    if (rc || co.getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
+    if (rc != 0 || compoundOrdername::getDomainID(key.getNoStripHeader<string_view>()) != domainId) {
       // XX I don't think this case can happen
       // cout << "We hit the beginning of the zone or database.. now what" << endl;
       return false;
index 577ace0d8405ef07ed273ac4e7178501a66fb7af..e16506df37c5dd45f6ed69caa9985107d73e8d89 100644 (file)
@@ -288,7 +288,7 @@ void CommunicatorClass::sendNotification(int sock, const ZoneName& domain, const
   string tsigsecret64;
   string tsigsecret;
 
-  if (::arg().mustDo("send-signed-notify") && ueber->getDomainMetadata(domain, "TSIG-ALLOW-AXFR", meta) && meta.size() > 0) {
+  if (::arg().mustDo("send-signed-notify") && ueber->getDomainMetadata(domain, "TSIG-ALLOW-AXFR", meta) && !meta.empty()) {
     tsigkeyname = DNSName(meta[0]);
   }
 
@@ -331,13 +331,13 @@ void CommunicatorClass::drillHole(const ZoneName& domain, const string& ipAddres
 bool CommunicatorClass::justNotified(const ZoneName& domain, const string& ipAddress)
 {
   auto holes = d_holes.lock();
-  auto it = holes->find(pair(domain, ipAddress));
-  if (it == holes->end()) {
+  auto iter = holes->find(pair(domain, ipAddress));
+  if (iter == holes->end()) {
     // no hole
     return false;
   }
 
-  if (it->second > time(nullptr) - 900) {
+  if (iter->second > time(nullptr) - 900) {
     // recent hole
     return true;
   }
index 463346fbdc04994eb1b5290f300b951fe58328b8..ec2f1d16c2069170db33bb1b596b9c76435e4eeb 100644 (file)
@@ -84,7 +84,7 @@ struct ZoneStatus
   unsigned int soa_serial{0};
   set<DNSName> nsset, qnames, secured;
   uint32_t domain_id;
-  int numDeltas{0};
+  size_t numDeltas{0};
 };
 
 static bool catalogDiff(const DomainInfo& di, vector<CatalogInfo>& fromXFR, vector<CatalogInfo>& fromDB, const string& logPrefix)
@@ -451,7 +451,7 @@ void CommunicatorClass::ixfrSuck(const ZoneName& domain, const TSIGTriplet& tsig
     soatimes drsoa_soatimes = {di.serial, 0, 0, 0, 0};
     DNSRecord drsoa;
     drsoa.setContent(std::make_shared<SOARecordContent>(g_rootdnsname, g_rootdnsname, drsoa_soatimes));
-    auto deltas = getIXFRDeltas(remote, domain, drsoa, xfrTimeout, false, tsig, laddr.sin4.sin_family ? &laddr : nullptr, ((size_t)::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024);
+    auto deltas = getIXFRDeltas(remote, domain, drsoa, xfrTimeout, false, tsig, laddr.sin4.sin_family != 0 ? &laddr : nullptr, ((size_t)::arg().asNum("xfr-max-received-mbytes")) * 1024 * 1024);
     status.numDeltas = deltas.size();
     //    cout<<"Got "<<deltas.size()<<" deltas from serial "<<di.serial<<", applying.."<<endl;
 
index de797a0d7295ad17a5d3bfcc0ee03cafeff7ac61..0a1018a131097c2f0843a7912682ca39d782e1cd 100644 (file)
@@ -163,8 +163,9 @@ DNSSECPrivateKey DNSSECKeeper::getKeyById(const ZoneName& zname, unsigned int ke
   vector<DNSBackend::KeyData> keys;
   d_keymetadb->getDomainKeys(zname, keys);
   for(const DNSBackend::KeyData& kd :  keys) {
-    if(kd.id != keyId)
+    if(kd.id != keyId) {
       continue;
+    }
 
     DNSKEYRecordContent dkrc;
     auto key = shared_ptr<DNSCryptoKeyEngine>(DNSCryptoKeyEngine::makeFromISCString(dkrc, kd.content));
index e092db02c66c701203eb68a953fa75fed1af81ef..db77a42b8fdab74bd563099e0060014fd56ffd74 100644 (file)
@@ -158,7 +158,7 @@ static void addSignature(DNSSECKeeper& dsk, UeberBackend& ueber, const ZoneName&
     dsk.getPreRRSIGs(ueber, outsigned, origTTL, packet); // does it all
   }
   else {
-    if(getRRSIGsForRRSET(dsk, signer, wildcardname.countLabels() ? wildcardname : signQName, signQType, signTTL, toSign, rrcs) < 0)  {
+    if(getRRSIGsForRRSET(dsk, signer, wildcardname.countLabels() != 0 ? wildcardname : signQName, signQType, signTTL, toSign, rrcs) < 0)  {
       // cerr<<"Error signing a record!"<<endl;
       return;
     }
index 7b3eb70cc2ddd05ea8278cb688884347cf16e772..d9a2401c6eb6ce03bc2da8e985618da78a6cb279 100644 (file)
@@ -87,17 +87,17 @@ BOOST_AUTO_TEST_CASE(test_axfr_queue_insert_and_priority_order_after_modify)
 
   auto res = suckDomains.insert(rr1);
   BOOST_CHECK(!res.second);
-  suckDomains.modify(res.first, [priorityAndOrder = rr1.priorityAndOrder](SuckRequest& so) {
-    if (priorityAndOrder.first < so.priorityAndOrder.first) {
-      so.priorityAndOrder = priorityAndOrder;
+  suckDomains.modify(res.first, [priorityAndOrder = rr1.priorityAndOrder](SuckRequest& request) {
+    if (priorityAndOrder.first < request.priorityAndOrder.first) {
+      request.priorityAndOrder = priorityAndOrder;
     }
   });
 
   res = suckDomains.insert(rr2);
   BOOST_CHECK(!res.second);
-  suckDomains.modify(res.first, [priorityAndOrder = rr2.priorityAndOrder](SuckRequest& so) {
-    if (priorityAndOrder.first < so.priorityAndOrder.first) {
-      so.priorityAndOrder = priorityAndOrder;
+  suckDomains.modify(res.first, [priorityAndOrder = rr2.priorityAndOrder](SuckRequest& request) {
+    if (priorityAndOrder.first < request.priorityAndOrder.first) {
+      request.priorityAndOrder = priorityAndOrder;
     }
   });
 
index 3b42baa09cdbfe97435e39800d6abe802ef29ed0..2607c4e69ecf49a65b8b6d07f86339112167a071 100644 (file)
@@ -271,7 +271,7 @@ public:
       fillSOAData(range.first->d_content, *soadata);
       soadata->ttl = range.first->d_ttl;
       soadata->qname = best;
-      soadata->domain_id = zoneId;
+      soadata->domain_id = static_cast<int>(zoneId);
       return true;
     }