From: Miod Vallat Date: Fri, 11 Apr 2025 13:58:11 +0000 (+0200) Subject: clang-tidy the previous clang-tidy run X-Git-Tag: dnsdist-2.0.0-alpha2~80^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f4d4310150762cff939423719b18e4e376e917f1;p=thirdparty%2Fpdns.git clang-tidy the previous clang-tidy run --- diff --git a/modules/bindbackend/bindbackend2.cc b/modules/bindbackend/bindbackend2.cc index 77525b7aa7..ae53d2e388 100644 --- a/modules/bindbackend/bindbackend2.cc +++ b/modules/bindbackend/bindbackend2.cc @@ -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); diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index b096ec012b..a608f1b4a8 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -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(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) { auto kid = pdns::checked_stoi(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(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(®, glob_result.gl_pathv[i], 5, regm, 0) == 0) { auto kid = pdns::checked_stoi(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(glob_result.gl_pathv[i] + regm[2].rm_so) << "." << kid << ".0.key"; if (rename(glob_result.gl_pathv[i], newpath.str().c_str())) { diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index 69143e4cd6..267816bbcd 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -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"<()) == domainId) { + if (compoundOrdername::getDomainID(key.getNoStripHeader()) == domainId) { before = co.getQName(key.getNoStripHeader()) + 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?!"<()) <<", in zone id "<())<< endl; + // cout<<"Cursor is at "<()) <<", in zone id "<())<< endl; - if (co.getQType(key.getNoStripHeader()).getCode() && co.getDomainID(key.getNoStripHeader()) == domainId && co.getQName(key.getNoStripHeader()) == qname2) { // don't match ENTs + if (compoundOrdername::getQType(key.getNoStripHeader()).getCode() != 0 && compoundOrdername::getDomainID(key.getNoStripHeader()) == domainId && compoundOrdername::getQName(key.getNoStripHeader()) == qname2) { // don't match ENTs // cout << "Had an exact match!"<()) == domainId && key.getNoStripHeader().rfind(matchkey, 0) == 0) + if (compoundOrdername::getDomainID(key.getNoStripHeader()) == domainId && key.getNoStripHeader().rfind(matchkey, 0) == 0) { continue; + } LMDBResourceRecord lrr; deserializeFromBuffer(val.get(), lrr); if (co.getQType(key.getNoStripHeader()).getCode() && (lrr.auth || co.getQType(key.getNoStripHeader()).getCode() == QType::NS)) break; } - if (rc || co.getDomainID(key.getNoStripHeader()) != domainId) { + if (rc != 0 || compoundOrdername::getDomainID(key.getNoStripHeader()) != 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()) != domainId) { + if (compoundOrdername::getDomainID(key.getNoStripHeader()) != domainId) { // cout << "Ended up in next zone, 'after' is zonename" <()) != domainId) { - // cout<<"Reversed into zone, but found wrong zone id " << co.getDomainID(key.getNoStripHeader()) << " != "<()) != domainId) { + // cout<<"Reversed into zone, but found wrong zone id " << compoundOrdername::getDomainID(key.getNoStripHeader()) << " != "<()) != domainId) { + if (rc != 0 || compoundOrdername::getDomainID(key.getNoStripHeader()) != domainId) { // cout << " oops, hit end of database or zone. This means after is apex" <()) != domainId) { + if (rc != 0 || compoundOrdername::getDomainID(key.getNoStripHeader()) != 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; diff --git a/pdns/auth-primarycommunicator.cc b/pdns/auth-primarycommunicator.cc index 577ace0d84..e16506df37 100644 --- a/pdns/auth-primarycommunicator.cc +++ b/pdns/auth-primarycommunicator.cc @@ -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; } diff --git a/pdns/auth-secondarycommunicator.cc b/pdns/auth-secondarycommunicator.cc index 463346fbdc..ec2f1d16c2 100644 --- a/pdns/auth-secondarycommunicator.cc +++ b/pdns/auth-secondarycommunicator.cc @@ -84,7 +84,7 @@ struct ZoneStatus unsigned int soa_serial{0}; set nsset, qnames, secured; uint32_t domain_id; - int numDeltas{0}; + size_t numDeltas{0}; }; static bool catalogDiff(const DomainInfo& di, vector& fromXFR, vector& 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(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 "< 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::makeFromISCString(dkrc, kd.content)); diff --git a/pdns/dnssecsigner.cc b/pdns/dnssecsigner.cc index e092db02c6..db77a42b8f 100644 --- a/pdns/dnssecsigner.cc +++ b/pdns/dnssecsigner.cc @@ -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!"<d_content, *soadata); soadata->ttl = range.first->d_ttl; soadata->qname = best; - soadata->domain_id = zoneId; + soadata->domain_id = static_cast(zoneId); return true; }