From 3bb98d9719c66bb8756f2b033335e7ef81806306 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 4 Apr 2023 16:23:20 +0200 Subject: [PATCH] Fix cases mentioned in review, plus a few spotted on macOS --- pdns/capabilities.cc | 2 +- pdns/iputils.cc | 2 +- pdns/minicurl.cc | 4 ++-- pdns/misc.cc | 14 +++++++------- pdns/opensslsigners.cc | 2 +- pdns/recursordist/aggressive_nsec.cc | 6 ++++-- pdns/recursordist/lwres.cc | 4 ++-- pdns/recursordist/rec-main.cc | 2 +- pdns/recursordist/rec-tcp.cc | 2 +- pdns/recursordist/recpacketcache.hh | 4 ++-- pdns/recursordist/test-syncres_cc10.cc | 2 +- pdns/recursordist/test-syncres_cc7.cc | 4 ++-- pdns/unix_utility.cc | 6 +++--- 13 files changed, 28 insertions(+), 26 deletions(-) diff --git a/pdns/capabilities.cc b/pdns/capabilities.cc index e073d2c77bd6..2747fc93f57e 100644 --- a/pdns/capabilities.cc +++ b/pdns/capabilities.cc @@ -33,7 +33,7 @@ #include "capabilities.hh" #include "misc.hh" -bool dropCapabilities(std::set capabilitiesToKeep) +bool dropCapabilities([[maybe_unused]] std::set capabilitiesToKeep) { #ifdef HAVE_LIBCAP cap_t caps = cap_get_proc(); diff --git a/pdns/iputils.cc b/pdns/iputils.cc index e0c7218f775c..31ac2a9773e3 100644 --- a/pdns/iputils.cc +++ b/pdns/iputils.cc @@ -147,7 +147,7 @@ int SSetsockopt(int sockfd, int level, int opname, int value) return ret; } -void setSocketIgnorePMTU(int sockfd, int family) +void setSocketIgnorePMTU([[maybe_unused]] int sockfd, [[maybe_unused]] int family) { if (family == AF_INET) { #if defined(IP_MTU_DISCOVER) && defined(IP_PMTUDISC_DONT) diff --git a/pdns/minicurl.cc b/pdns/minicurl.cc index 5d45406f1e5c..c1e16b810c7a 100644 --- a/pdns/minicurl.cc +++ b/pdns/minicurl.cc @@ -116,7 +116,7 @@ static string extractHostFromURL(const std::string& url) return url.substr(pos, endpos-pos); } -void MiniCurl::setupURL(const std::string& str, const ComboAddress* rem, const ComboAddress* src, int timeout, size_t byteslimit, bool fastopen, bool verify) +void MiniCurl::setupURL(const std::string& str, const ComboAddress* rem, const ComboAddress* src, int timeout, size_t byteslimit, [[maybe_unused]] bool fastopen, bool verify) { if (!d_fresh) { curl_easy_reset(getCURLPtr(d_curl)); @@ -198,7 +198,7 @@ void MiniCurl::setupURL(const std::string& str, const ComboAddress* rem, const C d_data.clear(); } -std::string MiniCurl::getURL(const std::string& str, const ComboAddress* rem, const ComboAddress* src, int timeout, bool fastopen, bool verify, size_t byteslimit) +std::string MiniCurl::getURL(const std::string& str, const ComboAddress* rem, const ComboAddress* src, int timeout, [[maybe_unused]] bool fastopen, bool verify, size_t byteslimit) { setupURL(str, rem, src, timeout, byteslimit, fastopen, verify); auto res = curl_easy_perform(getCURLPtr(d_curl)); diff --git a/pdns/misc.cc b/pdns/misc.cc index b28b4a2b0c7a..4cfe6d4196cc 100644 --- a/pdns/misc.cc +++ b/pdns/misc.cc @@ -1014,7 +1014,7 @@ bool isNonBlocking(int sock) return flags & O_NONBLOCK; } -bool setReceiveSocketErrors(int sock, int af) +bool setReceiveSocketErrors([[maybe_unused]] int sock, [[maybe_unused]] int af) { #ifdef __linux__ int tmp = 1, ret; @@ -1159,7 +1159,7 @@ int getMACAddress(const ComboAddress& ca, char* dest, size_t destLen) return foundMAC ? 0 : ENOENT; } #else -int getMACAddress(const ComboAddress& ca, char* dest, size_t len) +int getMACAddress(const ComboAddress& /* ca */, char* /* dest */, size_t /* len */) { return ENOENT; } @@ -1175,7 +1175,7 @@ string getMACAddress(const ComboAddress& ca) return ret; } -uint64_t udpErrorStats(const std::string& str) +uint64_t udpErrorStats([[maybe_unused]] const std::string& str) { #ifdef __linux__ ifstream ifs("/proc/net/snmp"); @@ -1217,7 +1217,7 @@ uint64_t udpErrorStats(const std::string& str) return 0; } -uint64_t udp6ErrorStats(const std::string& str) +uint64_t udp6ErrorStats([[maybe_unused]] const std::string& str) { #ifdef __linux__ const std::map keys = { @@ -1545,7 +1545,7 @@ bool isSettingThreadCPUAffinitySupported() #endif } -int mapThreadToCPUList(pthread_t tid, const std::set& cpus) +int mapThreadToCPUList([[maybe_unused]] pthread_t tid, [[maybe_unused]] const std::set& cpus) { #ifdef HAVE_PTHREAD_SETAFFINITY_NP # ifdef __NetBSD__ @@ -1613,7 +1613,7 @@ std::vector getResolvers(const std::string& resolvConfPath) return results; } -size_t getPipeBufferSize(int fd) +size_t getPipeBufferSize([[maybe_unused]] int fd) { #ifdef F_GETPIPE_SZ int res = fcntl(fd, F_GETPIPE_SZ); @@ -1627,7 +1627,7 @@ size_t getPipeBufferSize(int fd) #endif /* F_GETPIPE_SZ */ } -bool setPipeBufferSize(int fd, size_t size) +bool setPipeBufferSize([[maybe_unused]] int fd, [[maybe_unused]] size_t size) { #ifdef F_SETPIPE_SZ if (size > static_cast(std::numeric_limits::max())) { diff --git a/pdns/opensslsigners.cc b/pdns/opensslsigners.cc index f734089e9dd4..a8ca7c071262 100644 --- a/pdns/opensslsigners.cc +++ b/pdns/opensslsigners.cc @@ -1843,7 +1843,7 @@ int OpenSSLEDDSADNSCryptoKeyEngine::getBits() const return (int)d_len << 3; } -bool OpenSSLEDDSADNSCryptoKeyEngine::checkKey(std::optional>> errorMessages) const +bool OpenSSLEDDSADNSCryptoKeyEngine::checkKey([[maybe_unused]] std::optional>> errorMessages) const { #if OPENSSL_VERSION_MAJOR >= 3 auto ctx = KeyContext{EVP_PKEY_CTX_new_from_pkey(nullptr, d_edkey.get(), nullptr), EVP_PKEY_CTX_free}; diff --git a/pdns/recursordist/aggressive_nsec.cc b/pdns/recursordist/aggressive_nsec.cc index 58c2cc56c7d8..1b947a6601d1 100644 --- a/pdns/recursordist/aggressive_nsec.cc +++ b/pdns/recursordist/aggressive_nsec.cc @@ -488,7 +488,7 @@ static void addRecordToRRSet(time_t /* now */, const DNSName& owner, const QType } } -bool AggressiveNSECCache::synthesizeFromNSEC3Wildcard(time_t now, const DNSName& name, const QType& type, std::vector& ret, int& /* res */, bool doDNSSEC, ZoneEntry::CacheEntry& nextCloser, const DNSName& wildcardName, const OptLog& log) +bool AggressiveNSECCache::synthesizeFromNSEC3Wildcard(time_t now, const DNSName& name, const QType& type, std::vector& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nextCloser, const DNSName& wildcardName, const OptLog& log) { vState cachedState; @@ -507,10 +507,11 @@ bool AggressiveNSECCache::synthesizeFromNSEC3Wildcard(time_t now, const DNSName& VLOG(log, name << ": Synthesized valid answer from NSEC3s and wildcard!" << endl); ++d_nsec3WildcardHits; + res = RCode::NoError; return true; } -bool AggressiveNSECCache::synthesizeFromNSECWildcard(time_t now, const DNSName& name, const QType& type, std::vector& ret, int& /* res */, bool doDNSSEC, ZoneEntry::CacheEntry& nsec, const DNSName& wildcardName, const OptLog& log) +bool AggressiveNSECCache::synthesizeFromNSECWildcard(time_t now, const DNSName& name, const QType& type, std::vector& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nsec, const DNSName& wildcardName, const OptLog& log) { vState cachedState; @@ -527,6 +528,7 @@ bool AggressiveNSECCache::synthesizeFromNSECWildcard(time_t now, const DNSName& VLOG(log, name << ": Synthesized valid answer from NSECs and wildcard!" << endl); ++d_nsecWildcardHits; + res = RCode::NoError; return true; } diff --git a/pdns/recursordist/lwres.cc b/pdns/recursordist/lwres.cc index 0d520669400c..833ae7ffc148 100644 --- a/pdns/recursordist/lwres.cc +++ b/pdns/recursordist/lwres.cc @@ -282,7 +282,7 @@ static void logIncomingResponse(const std::shared_ptrd_nsName.empty()) { nsName = context->d_nsName.toStringNoDot(); } - isNew = tcpconnect(*now, ip, connection, dnsOverTLS, nsName); + isNew = tcpconnect(ip, connection, dnsOverTLS, nsName); ret = tcpsendrecv(ip, connection, localip, vpacket, len, buf); #ifdef HAVE_FSTRM if (fstrmQEnabled) { diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index f13c7ff27472..36401172383a 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -832,7 +832,7 @@ static void usr2Handler(int) ::arg().set("quiet") = g_quiet ? "" : "no"; } -static void checkLinuxIPv6Limits(Logr::log_t log) +static void checkLinuxIPv6Limits([[maybe_unused]] Logr::log_t log) { #ifdef __linux__ string line; diff --git a/pdns/recursordist/rec-tcp.cc b/pdns/recursordist/rec-tcp.cc index fb78c064c0aa..3da26229019c 100644 --- a/pdns/recursordist/rec-tcp.cc +++ b/pdns/recursordist/rec-tcp.cc @@ -858,7 +858,7 @@ static void TCPIOHandlerIO(int fd, FDMultiplexer::funcparam_t& var) TCPIOHandlerStateChange(pid->lowState, newstate, pid); } -void checkFastOpenSysctl(bool active, Logr::log_t log) +void checkFastOpenSysctl([[maybe_unused]] bool active, [[maybe_unused]] Logr::log_t log) { #ifdef __linux__ string line; diff --git a/pdns/recursordist/recpacketcache.hh b/pdns/recursordist/recpacketcache.hh index d082aec04180..5ff974fefdce 100644 --- a/pdns/recursordist/recpacketcache.hh +++ b/pdns/recursordist/recpacketcache.hh @@ -204,7 +204,7 @@ private: [[nodiscard]] const MapCombo& getMap(unsigned int tag, uint32_t hash, bool tcp) const { - return d_maps.at(combine(hash, hash, tcp) % d_maps.size()); + return d_maps.at(combine(tag, hash, tcp) % d_maps.size()); } static bool qrMatch(const packetCache_t::index::type::iterator& iter, const std::string& queryPacket, const DNSName& qname, uint16_t qtype, uint16_t qclass); @@ -213,7 +213,7 @@ private: void setShardSizes(size_t shardSize); public: - void preRemoval(MapCombo::LockedContent& map, const Entry& entry) + void preRemoval(MapCombo::LockedContent& /* map */, const Entry& /* entry */) { } }; diff --git a/pdns/recursordist/test-syncres_cc10.cc b/pdns/recursordist/test-syncres_cc10.cc index 0218cf39ffbe..4353d843fc44 100644 --- a/pdns/recursordist/test-syncres_cc10.cc +++ b/pdns/recursordist/test-syncres_cc10.cc @@ -1642,7 +1642,7 @@ BOOST_AUTO_TEST_CASE(test_servestale_immediateservfail) const int theTTL = 5; - sr->setAsyncCallback([&downServers, &downCount, &lookupCount, target](const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, LWResult* res, bool* chained) { + sr->setAsyncCallback([&downServers, &downCount, &lookupCount, target](const ComboAddress& ip, const DNSName& /* domain */, int /* type */, bool /* doTCP */, bool /* sendRDQuery */, int /* EDNS0Level */, struct timeval* /* now */, boost::optional& /* srcmask */, boost::optional /* context */, LWResult* res, bool* /* chained */) { /* this will cause issue with qname minimization if we ever implement it */ if (downServers.find(ip) != downServers.end()) { diff --git a/pdns/recursordist/test-syncres_cc7.cc b/pdns/recursordist/test-syncres_cc7.cc index cac1e94e3945..df5fb0850aac 100644 --- a/pdns/recursordist/test-syncres_cc7.cc +++ b/pdns/recursordist/test-syncres_cc7.cc @@ -1448,7 +1448,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_insecure_missing_soa_on_nodata) size_t queriesCount = 0; - sr->setAsyncCallback([target, &queriesCount, keys](const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, LWResult* res, bool* chained) { + sr->setAsyncCallback([target, &queriesCount, keys](const ComboAddress& ip, const DNSName& domain, int type, bool /* doTCP */, bool /* sendRDQuery */, int /* EDNS0Level */, struct timeval* /* now */, boost::optional& /* srcmask */, boost::optional /* context */, LWResult* res, bool* /* chained */) { queriesCount++; if (type == QType::DS || type == QType::DNSKEY) { @@ -1523,7 +1523,7 @@ BOOST_AUTO_TEST_CASE(test_dnssec_insecure_missing_soa_on_nxd) size_t queriesCount = 0; - sr->setAsyncCallback([target, &queriesCount, keys](const ComboAddress& ip, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional& srcmask, boost::optional context, LWResult* res, bool* chained) { + sr->setAsyncCallback([target, &queriesCount, keys](const ComboAddress& ip, const DNSName& domain, int type, bool /* doTCP */, bool /* sendRDQuery */, int /* EDNS0Level */, struct timeval* /* now */, boost::optional& /* srcmask */, boost::optional /* context */, LWResult* res, bool* /* chained */) { queriesCount++; if (type == QType::DS || type == QType::DNSKEY) { diff --git a/pdns/unix_utility.cc b/pdns/unix_utility.cc index b3e95ad51f4c..26c0782e1c53 100644 --- a/pdns/unix_utility.cc +++ b/pdns/unix_utility.cc @@ -78,7 +78,7 @@ int Utility::timed_connect( Utility::sock_t sock, -void Utility::setBindAny(int af, sock_t sock) +void Utility::setBindAny([[maybe_unused]] int af, [[maybe_unused]] sock_t sock) { const int one = 1; @@ -199,9 +199,9 @@ Utility::pid_t Utility::getpid( ) // Returns the current time. -int Utility::gettimeofday( struct timeval *tv, void *tz ) +int Utility::gettimeofday( struct timeval *tv, void * /* tz */) { - return ::gettimeofday(tv,nullptr); + return ::gettimeofday(tv, nullptr); } // Sets the random seed.