Skip to content

Commit

Permalink
Fix cases mentioned in review, plus a few spotted on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
omoerbeek committed Apr 5, 2023
1 parent 0936b17 commit 3bb98d9
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion pdns/capabilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "capabilities.hh"
#include "misc.hh"

bool dropCapabilities(std::set<std::string> capabilitiesToKeep)
bool dropCapabilities([[maybe_unused]] std::set<std::string> capabilitiesToKeep)
{
#ifdef HAVE_LIBCAP
cap_t caps = cap_get_proc();
Expand Down
2 changes: 1 addition & 1 deletion pdns/iputils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions pdns/minicurl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down
14 changes: 7 additions & 7 deletions pdns/misc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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");
Expand Down Expand Up @@ -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<std::string, std::string> keys = {
Expand Down Expand Up @@ -1545,7 +1545,7 @@ bool isSettingThreadCPUAffinitySupported()
#endif
}

int mapThreadToCPUList(pthread_t tid, const std::set<int>& cpus)
int mapThreadToCPUList([[maybe_unused]] pthread_t tid, [[maybe_unused]] const std::set<int>& cpus)
{
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
# ifdef __NetBSD__
Expand Down Expand Up @@ -1613,7 +1613,7 @@ std::vector<ComboAddress> 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);
Expand All @@ -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<size_t>(std::numeric_limits<int>::max())) {
Expand Down
2 changes: 1 addition & 1 deletion pdns/opensslsigners.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1843,7 +1843,7 @@ int OpenSSLEDDSADNSCryptoKeyEngine::getBits() const
return (int)d_len << 3;
}

bool OpenSSLEDDSADNSCryptoKeyEngine::checkKey(std::optional<std::reference_wrapper<std::vector<std::string>>> errorMessages) const
bool OpenSSLEDDSADNSCryptoKeyEngine::checkKey([[maybe_unused]] std::optional<std::reference_wrapper<std::vector<std::string>>> 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};
Expand Down
6 changes: 4 additions & 2 deletions pdns/recursordist/aggressive_nsec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<DNSRecord>& 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<DNSRecord>& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nextCloser, const DNSName& wildcardName, const OptLog& log)
{
vState cachedState;

Expand All @@ -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<DNSRecord>& 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<DNSRecord>& ret, int& res, bool doDNSSEC, ZoneEntry::CacheEntry& nsec, const DNSName& wildcardName, const OptLog& log)
{
vState cachedState;

Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions pdns/recursordist/lwres.cc
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static void logIncomingResponse(const std::shared_ptr<std::vector<std::unique_pt
}
}

static bool tcpconnect(const struct timeval& now, const ComboAddress& ip, TCPOutConnectionManager::Connection& connection, bool& dnsOverTLS, const std::string& nsName)
static bool tcpconnect(const ComboAddress& ip, TCPOutConnectionManager::Connection& connection, bool& dnsOverTLS, const std::string& nsName)
{
dnsOverTLS = SyncRes::s_dot_to_port_853 && ip.getPort() == 853;

Expand Down Expand Up @@ -510,7 +510,7 @@ static LWResult::Result asyncresolve(const ComboAddress& ip, const DNSName& doma
if (context && !context->d_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) {
Expand Down
2 changes: 1 addition & 1 deletion pdns/recursordist/rec-main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion pdns/recursordist/rec-tcp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pdns/recursordist/recpacketcache.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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<HashTag>::type::iterator& iter, const std::string& queryPacket, const DNSName& qname, uint16_t qtype, uint16_t qclass);
Expand All @@ -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 */)
{
}
};
2 changes: 1 addition & 1 deletion pdns/recursordist/test-syncres_cc10.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Netmask>& srcmask, boost::optional<const ResolveContext&> 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<Netmask>& /* srcmask */, boost::optional<const ResolveContext&> /* context */, LWResult* res, bool* /* chained */) {
/* this will cause issue with qname minimization if we ever implement it */

if (downServers.find(ip) != downServers.end()) {
Expand Down
4 changes: 2 additions & 2 deletions pdns/recursordist/test-syncres_cc7.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Netmask>& srcmask, boost::optional<const ResolveContext&> 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<Netmask>& /* srcmask */, boost::optional<const ResolveContext&> /* context */, LWResult* res, bool* /* chained */) {
queriesCount++;

if (type == QType::DS || type == QType::DNSKEY) {
Expand Down Expand Up @@ -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<Netmask>& srcmask, boost::optional<const ResolveContext&> 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<Netmask>& /* srcmask */, boost::optional<const ResolveContext&> /* context */, LWResult* res, bool* /* chained */) {
queriesCount++;

if (type == QType::DS || type == QType::DNSKEY) {
Expand Down
6 changes: 3 additions & 3 deletions pdns/unix_utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 3bb98d9

Please sign in to comment.