From: Remi Gacogne Date: Mon, 14 Oct 2024 13:20:16 +0000 (+0200) Subject: dnsdist: Fix a lot of "unused parameter" warnings X-Git-Tag: dnsdist-2.0.0-alpha1~128^2~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2f2f83d29fa7ff8f992855484c3d8baf7967dd6;p=thirdparty%2Fpdns.git dnsdist: Fix a lot of "unused parameter" warnings --- diff --git a/ext/lmdb-safe/lmdb-safe.hh b/ext/lmdb-safe/lmdb-safe.hh index 07e96cffc1..0c14a2f133 100644 --- a/ext/lmdb-safe/lmdb-safe.hh +++ b/ext/lmdb-safe/lmdb-safe.hh @@ -594,6 +594,9 @@ private: // * so let's go back } #else /* ifndef DNSDIST */ + (void)key; + (void)data; + (void)op; return rc; #endif } diff --git a/pdns/dnsdistdist/dnsdist-carbon.cc b/pdns/dnsdistdist/dnsdist-carbon.cc index 66ec734250..d0dab784fc 100644 --- a/pdns/dnsdistdist/dnsdist-carbon.cc +++ b/pdns/dnsdistdist/dnsdist-carbon.cc @@ -367,9 +367,10 @@ void Carbon::run(const std::vector& endpoints) } #endif /* DISABLE_CARBON */ -static time_t s_start = time(nullptr); +static const time_t s_start = time(nullptr); uint64_t uptimeOfProcess(const std::string& str) { + (void)str; return time(nullptr) - s_start; } diff --git a/pdns/dnsdistdist/dnsdist-console.cc b/pdns/dnsdistdist/dnsdist-console.cc index 1ad865573b..dc92a02be4 100644 --- a/pdns/dnsdistdist/dnsdist-console.cc +++ b/pdns/dnsdistdist/dnsdist-console.cc @@ -886,6 +886,7 @@ extern "C" static char** dnsdist_completion_callback(const char* text, int start, int end) { + (void)end; char** matches = nullptr; if (start == 0) { // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast): readline diff --git a/pdns/dnsdistdist/dnsdist-downstream-connection.hh b/pdns/dnsdistdist/dnsdist-downstream-connection.hh index 8d50de369f..aba6cd23c6 100644 --- a/pdns/dnsdistdist/dnsdist-downstream-connection.hh +++ b/pdns/dnsdistdist/dnsdist-downstream-connection.hh @@ -62,7 +62,7 @@ public: const auto& it = d_downstreamConnections.find(backendId); if (it != d_downstreamConnections.end()) { /* first scan idle connections, more recent first */ - auto entry = findUsableConnectionInList(now, freshCutOff, it->second.d_idles, true); + auto entry = findUsableConnectionInList(freshCutOff, it->second.d_idles, true); if (entry) { ++ds->tcpReusedConnections; it->second.d_actives.insert(entry); @@ -70,7 +70,7 @@ public: } /* then scan actives ones, more recent first as well */ - entry = findUsableConnectionInList(now, freshCutOff, it->second.d_actives, false); + entry = findUsableConnectionInList(freshCutOff, it->second.d_actives, false); if (entry) { ++ds->tcpReusedConnections; return entry; @@ -107,8 +107,8 @@ public: idleCutOff.tv_sec -= s_maxIdleTime; for (auto dsIt = d_downstreamConnections.begin(); dsIt != d_downstreamConnections.end();) { - cleanUpList(dsIt->second.d_idles, now, freshCutOff, idleCutOff); - cleanUpList(dsIt->second.d_actives, now, freshCutOff, idleCutOff); + cleanUpList(dsIt->second.d_idles, freshCutOff, idleCutOff); + cleanUpList(dsIt->second.d_actives, freshCutOff, idleCutOff); if (dsIt->second.d_idles.empty() && dsIt->second.d_actives.empty()) { dsIt = d_downstreamConnections.erase(dsIt); @@ -212,7 +212,7 @@ public: } protected: - void cleanUpList(list_t& list, const struct timeval& now, const struct timeval& freshCutOff, const struct timeval& idleCutOff) + void cleanUpList(list_t& list, const struct timeval& freshCutOff, const struct timeval& idleCutOff) { auto& sidx = list.template get(); for (auto connIt = sidx.begin(); connIt != sidx.end();) { @@ -248,7 +248,7 @@ protected: } } - std::shared_ptr findUsableConnectionInList(const struct timeval& now, const struct timeval& freshCutOff, list_t& list, bool removeIfFound) + std::shared_ptr findUsableConnectionInList(const struct timeval& freshCutOff, list_t& list, bool removeIfFound) { auto& sidx = list.template get(); for (auto listIt = sidx.begin(); listIt != sidx.end();) { @@ -258,7 +258,7 @@ protected: } auto& entry = *listIt; - if (isConnectionUsable(entry, now, freshCutOff)) { + if (isConnectionUsable(entry, freshCutOff)) { entry->setReused(); // make a copy since the iterator will be invalidated after erasing auto result = entry; @@ -280,7 +280,7 @@ protected: return nullptr; } - bool isConnectionUsable(const std::shared_ptr& conn, const struct timeval& now, const struct timeval& freshCutOff) + bool isConnectionUsable(const std::shared_ptr& conn, const struct timeval& freshCutOff) { if (!conn->canBeReused()) { return false; diff --git a/pdns/dnsdistdist/dnsdist-healthchecks.cc b/pdns/dnsdistdist/dnsdist-healthchecks.cc index 7f02b24f76..647cfa23e4 100644 --- a/pdns/dnsdistdist/dnsdist-healthchecks.cc +++ b/pdns/dnsdistdist/dnsdist-healthchecks.cc @@ -159,17 +159,22 @@ public: void handleResponse(const struct timeval& now, TCPResponse&& response) override { + (void)now; d_data->d_buffer = std::move(response.d_buffer); d_data->d_ds->submitHealthCheckResult(d_data->d_initial, ::handleResponse(d_data)); } void handleXFRResponse(const struct timeval& now, TCPResponse&& response) override { + (void)now; + (void)response; throw std::runtime_error("Unexpected XFR reponse to a health check query"); } void notifyIOError(const struct timeval& now, [[maybe_unused]] TCPResponse&& response) override { + (void)now; + (void)response; ++d_data->d_ds->d_healthCheckMetrics.d_networkErrors; d_data->d_ds->submitHealthCheckResult(d_data->d_initial, false); } @@ -231,6 +236,7 @@ static void healthCheckUDPCallback(int descriptor, FDMultiplexer::funcparam_t& p static void healthCheckTCPCallback(int descriptor, FDMultiplexer::funcparam_t& param) { + (void)descriptor; auto data = boost::any_cast>(param); IOStateGuard ioGuard(data->d_ioState); diff --git a/pdns/dnsdistdist/dnsdist-kvs.hh b/pdns/dnsdistdist/dnsdist-kvs.hh index 764a45c35c..5672986e82 100644 --- a/pdns/dnsdistdist/dnsdist-kvs.hh +++ b/pdns/dnsdistdist/dnsdist-kvs.hh @@ -160,6 +160,8 @@ public: // This requires that the underlying store supports ordered keys, which is true for LMDB but not for CDB, for example. virtual bool getRangeValue(const std::string& key, std::string& value) { + (void)key; + (void)value; throw std::runtime_error("range-based lookups are not implemented for this Key-Value Store"); } virtual bool reload() diff --git a/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc b/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc index 8ae0d81704..479b337191 100644 --- a/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc +++ b/pdns/dnsdistdist/dnsdist-lua-bindings-dnsquestion.cc @@ -36,13 +36,13 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) /* DNSQuestion */ /* PowerDNS DNSQuestion compat */ luaCtx.registerMember( - "localaddr", [](const DNSQuestion& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origDest; }, [](DNSQuestion& dnsQuestion, const ComboAddress newLocal) { (void)newLocal; }); + "localaddr", [](const DNSQuestion& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origDest; }, [](DNSQuestion& dnsQuestion, const ComboAddress newLocal) { (void)dnsQuestion; (void)newLocal; }); luaCtx.registerMember( - "qname", [](const DNSQuestion& dnsQuestion) -> DNSName { return dnsQuestion.ids.qname; }, [](DNSQuestion& dnsQuestion, const DNSName& newName) { (void)newName; }); + "qname", [](const DNSQuestion& dnsQuestion) -> DNSName { return dnsQuestion.ids.qname; }, [](DNSQuestion& dnsQuestion, const DNSName& newName) { (void)dnsQuestion; (void)newName; }); luaCtx.registerMember( - "qtype", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qtype; }, [](DNSQuestion& dnsQuestion, uint16_t newType) { (void)newType; }); + "qtype", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qtype; }, [](DNSQuestion& dnsQuestion, uint16_t newType) { (void)dnsQuestion; (void)newType; }); luaCtx.registerMember( - "qclass", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qclass; }, [](DNSQuestion& dnsQuestion, uint16_t newClass) { (void)newClass; }); + "qclass", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qclass; }, [](DNSQuestion& dnsQuestion, uint16_t newClass) { (void)dnsQuestion; (void)newClass; }); luaCtx.registerMember( "rcode", [](const DNSQuestion& dnsQuestion) -> int { @@ -55,7 +55,7 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) }); }); luaCtx.registerMember( - "remoteaddr", [](const DNSQuestion& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origRemote; }, [](DNSQuestion& dnsQuestion, const ComboAddress newRemote) { (void)newRemote; }); + "remoteaddr", [](const DNSQuestion& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origRemote; }, [](DNSQuestion& dnsQuestion, const ComboAddress newRemote) { (void)dnsQuestion; (void)newRemote; }); /* DNSDist DNSQuestion */ luaCtx.registerMember( "dh", @@ -71,9 +71,9 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) luaCtx.registerMember( "len", [](const DNSQuestion& dnsQuestion) -> uint16_t { return dnsQuestion.getData().size(); }, [](DNSQuestion& dnsQuestion, uint16_t newlen) { dnsQuestion.getMutableData().resize(newlen); }); luaCtx.registerMember( - "opcode", [](const DNSQuestion& dnsQuestion) -> uint8_t { return dnsQuestion.getHeader()->opcode; }, [](DNSQuestion& dnsQuestion, uint8_t newOpcode) { (void)newOpcode; }); + "opcode", [](const DNSQuestion& dnsQuestion) -> uint8_t { return dnsQuestion.getHeader()->opcode; }, [](DNSQuestion& dnsQuestion, uint8_t newOpcode) { (void)dnsQuestion; (void)newOpcode; }); luaCtx.registerMember( - "tcp", [](const DNSQuestion& dnsQuestion) -> bool { return dnsQuestion.overTCP(); }, [](DNSQuestion& dnsQuestion, bool newTcp) { (void)newTcp; }); + "tcp", [](const DNSQuestion& dnsQuestion) -> bool { return dnsQuestion.overTCP(); }, [](DNSQuestion& dnsQuestion, bool newTcp) { (void)dnsQuestion; (void)newTcp; }); luaCtx.registerMember( "skipCache", [](const DNSQuestion& dnsQuestion) -> bool { return dnsQuestion.ids.skipCache; }, [](DNSQuestion& dnsQuestion, bool newSkipCache) { dnsQuestion.ids.skipCache = newSkipCache; }); luaCtx.registerMember( @@ -379,13 +379,13 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) /* LuaWrapper doesn't support inheritance */ luaCtx.registerMember( - "localaddr", [](const DNSResponse& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origDest; }, [](DNSResponse& dnsQuestion, const ComboAddress newLocal) { (void)newLocal; }); + "localaddr", [](const DNSResponse& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origDest; }, [](DNSResponse& dnsQuestion, const ComboAddress newLocal) { (void)dnsQuestion; (void)newLocal; }); luaCtx.registerMember( - "qname", [](const DNSResponse& dnsQuestion) -> DNSName { return dnsQuestion.ids.qname; }, [](DNSResponse& dnsQuestion, const DNSName& newName) { (void)newName; }); + "qname", [](const DNSResponse& dnsQuestion) -> DNSName { return dnsQuestion.ids.qname; }, [](DNSResponse& dnsQuestion, const DNSName& newName) { (void)dnsQuestion; (void)newName; }); luaCtx.registerMember( - "qtype", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qtype; }, [](DNSResponse& dnsQuestion, uint16_t newType) { (void)newType; }); + "qtype", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qtype; }, [](DNSResponse& dnsQuestion, uint16_t newType) { (void)dnsQuestion; (void)newType; }); luaCtx.registerMember( - "qclass", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qclass; }, [](DNSResponse& dnsQuestion, uint16_t newClass) { (void)newClass; }); + "qclass", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.ids.qclass; }, [](DNSResponse& dnsQuestion, uint16_t newClass) { (void)dnsQuestion; (void)newClass; }); luaCtx.registerMember( "rcode", [](const DNSResponse& dnsQuestion) -> int { @@ -398,7 +398,7 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) }); }); luaCtx.registerMember( - "remoteaddr", [](const DNSResponse& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origRemote; }, [](DNSResponse& dnsQuestion, const ComboAddress newRemote) { (void)newRemote; }); + "remoteaddr", [](const DNSResponse& dnsQuestion) -> ComboAddress { return dnsQuestion.ids.origRemote; }, [](DNSResponse& dnsQuestion, const ComboAddress newRemote) { (void)dnsQuestion; (void)newRemote; }); luaCtx.registerMember( "dh", [](const DNSResponse& dnsResponse) -> dnsheader* { @@ -413,9 +413,9 @@ void setupLuaBindingsDNSQuestion(LuaContext& luaCtx) luaCtx.registerMember( "len", [](const DNSResponse& dnsQuestion) -> uint16_t { return dnsQuestion.getData().size(); }, [](DNSResponse& dnsQuestion, uint16_t newlen) { dnsQuestion.getMutableData().resize(newlen); }); luaCtx.registerMember( - "opcode", [](const DNSResponse& dnsQuestion) -> uint8_t { return dnsQuestion.getHeader()->opcode; }, [](DNSResponse& dnsQuestion, uint8_t newOpcode) { (void)newOpcode; }); + "opcode", [](const DNSResponse& dnsQuestion) -> uint8_t { return dnsQuestion.getHeader()->opcode; }, [](DNSResponse& dnsQuestion, uint8_t newOpcode) { (void)dnsQuestion; (void)newOpcode; }); luaCtx.registerMember( - "tcp", [](const DNSResponse& dnsQuestion) -> bool { return dnsQuestion.overTCP(); }, [](DNSResponse& dnsQuestion, bool newTcp) { (void)newTcp; }); + "tcp", [](const DNSResponse& dnsQuestion) -> bool { return dnsQuestion.overTCP(); }, [](DNSResponse& dnsQuestion, bool newTcp) { (void)dnsQuestion; (void)newTcp; }); luaCtx.registerMember( "skipCache", [](const DNSResponse& dnsQuestion) -> bool { return dnsQuestion.ids.skipCache; }, [](DNSResponse& dnsQuestion, bool newSkipCache) { dnsQuestion.ids.skipCache = newSkipCache; }); luaCtx.registerMember( diff --git a/pdns/dnsdistdist/dnsdist-lua-ffi.cc b/pdns/dnsdistdist/dnsdist-lua-ffi.cc index 54886c6b8d..dfee7d3567 100644 --- a/pdns/dnsdistdist/dnsdist-lua-ffi.cc +++ b/pdns/dnsdistdist/dnsdist-lua-ffi.cc @@ -729,12 +729,14 @@ static size_t dnsdist_ffi_servers_get_index_from_server(const ServerPolicy::Numb size_t dnsdist_ffi_servers_list_chashed(const dnsdist_ffi_servers_list_t* list, const dnsdist_ffi_dnsquestion_t* dq, size_t hash) { + (void)dq; auto server = chashedFromHash(list->servers, hash); return dnsdist_ffi_servers_get_index_from_server(list->servers, server); } size_t dnsdist_ffi_servers_list_whashed(const dnsdist_ffi_servers_list_t* list, const dnsdist_ffi_dnsquestion_t* dq, size_t hash) { + (void)dq; auto server = whashedFromHash(list->servers, hash); return dnsdist_ffi_servers_get_index_from_server(list->servers, server); } @@ -1881,6 +1883,7 @@ void dnsdist_ffi_metric_set(const char* metricName, size_t metricNameLen, double double dnsdist_ffi_metric_get(const char* metricName, size_t metricNameLen, bool isCounter) { + (void)isCounter; auto result = dnsdist::metrics::getCustomMetric(std::string_view(metricName, metricNameLen), {}); if (std::get_if(&result) != nullptr) { return 0.; diff --git a/pdns/dnsdistdist/dnsdist-lua-hooks.cc b/pdns/dnsdistdist/dnsdist-lua-hooks.cc index 8bdff2e17c..1f92e0ccf3 100644 --- a/pdns/dnsdistdist/dnsdist-lua-hooks.cc +++ b/pdns/dnsdistdist/dnsdist-lua-hooks.cc @@ -32,6 +32,7 @@ void clearMaintenanceHooks() static void setTicketsKeyAddedHook(const LuaContext& context, const TicketsKeyAddedHook& hook) { + (void)context; TLSCtx::setTicketsKeyAddedHook([hook](const std::string& key) { try { auto lua = g_lua.lock(); diff --git a/pdns/dnsdistdist/dnsdist-lua-inspection.cc b/pdns/dnsdistdist/dnsdist-lua-inspection.cc index 391f2b32e6..77ee1e2671 100644 --- a/pdns/dnsdistdist/dnsdist-lua-inspection.cc +++ b/pdns/dnsdistdist/dnsdist-lua-inspection.cc @@ -1084,9 +1084,9 @@ void setupLuaInspection(LuaContext& luaCtx) nowRealTime.tv_nsec -= 1000000000; } - return nowRealTime; }, [](DynBlock& block, [[maybe_unused]] timespec until) {}); + return nowRealTime; }, []([[maybe_unused]] DynBlock& block, [[maybe_unused]] timespec until) {}); luaCtx.registerMember( - "blocks", [](const DynBlock& block) { return block.blocks.load(); }, [](DynBlock& block, [[maybe_unused]] unsigned int blocks) {}); + "blocks", [](const DynBlock& block) { return block.blocks.load(); }, []([[maybe_unused]] DynBlock& block, [[maybe_unused]] unsigned int blocks) {}); luaCtx.registerMember("action", &DynBlock::action); luaCtx.registerMember("warning", &DynBlock::warning); luaCtx.registerMember("bpf", &DynBlock::bpf); diff --git a/pdns/dnsdistdist/dnsdist-lua-web.cc b/pdns/dnsdistdist/dnsdist-lua-web.cc index cd7e47f91e..5785a4c5c2 100644 --- a/pdns/dnsdistdist/dnsdist-lua-web.cc +++ b/pdns/dnsdistdist/dnsdist-lua-web.cc @@ -38,31 +38,31 @@ void setupLuaWeb(LuaContext& luaCtx) dnsdist::webserver::registerWebHandler(path, [handler](const YaHTTP::Request& req, YaHTTP::Response& resp) { handler(&req, &resp); }, true); }); - luaCtx.registerMember("path", [](const YaHTTP::Request& req) -> std::string { return req.url.path; }, [](YaHTTP::Request& req, const std::string& path) { (void) path; }); - luaCtx.registerMember("version", [](const YaHTTP::Request& req) -> int { return req.version; }, [](YaHTTP::Request& req, int version) { (void) version; }); - luaCtx.registerMember("method", [](const YaHTTP::Request& req) -> std::string { return req.method; }, [](YaHTTP::Request& req, const std::string& method) { (void) method; }); - luaCtx.registerMember("body", [](const YaHTTP::Request& req) -> const std::string { return req.body; }, [](YaHTTP::Request& req, const std::string& body) { (void) body; }); + luaCtx.registerMember("path", [](const YaHTTP::Request& req) -> std::string { return req.url.path; }, [](YaHTTP::Request& req, const std::string& path) { (void)req; (void) path; }); + luaCtx.registerMember("version", [](const YaHTTP::Request& req) -> int { return req.version; }, [](YaHTTP::Request& req, int version) { (void)req; (void)version; }); + luaCtx.registerMember("method", [](const YaHTTP::Request& req) -> std::string { return req.method; }, [](YaHTTP::Request& req, const std::string& method) { (void)req; (void) method; }); + luaCtx.registerMember("body", [](const YaHTTP::Request& req) -> const std::string { return req.body; }, [](YaHTTP::Request& req, const std::string& body) { (void)req; (void)body; }); luaCtx.registerMember(YaHTTP::Request::*)>("getvars", [](const YaHTTP::Request& req) { LuaAssociativeTable values; for (const auto& entry : req.getvars) { values.insert({entry.first, entry.second}); } return values; - }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void) values; }); + }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void)req; (void)values; }); luaCtx.registerMember(YaHTTP::Request::*)>("postvars", [](const YaHTTP::Request& req) { LuaAssociativeTable values; for (const auto& entry : req.postvars) { values.insert({entry.first, entry.second}); } return values; - }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void) values; }); + }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void)req; (void)values; }); luaCtx.registerMember(YaHTTP::Request::*)>("headers", [](const YaHTTP::Request& req) { LuaAssociativeTable values; for (const auto& entry : req.headers) { values.insert({entry.first, entry.second}); } return values; - }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void) values; }); + }, [](YaHTTP::Request& req, const LuaAssociativeTable& values) { (void)req; (void)values; }); /* Response */ luaCtx.registerMember("body", [](const YaHTTP::Response& resp) -> const std::string { return resp.body; }, [](YaHTTP::Response& resp, const std::string& body) { resp.body = body; }); diff --git a/pdns/dnsdistdist/dnsdist-nghttp2-in.cc b/pdns/dnsdistdist/dnsdist-nghttp2-in.cc index 2b19ecdeb2..c80da661fc 100644 --- a/pdns/dnsdistdist/dnsdist-nghttp2-in.cc +++ b/pdns/dnsdistdist/dnsdist-nghttp2-in.cc @@ -480,6 +480,8 @@ void IncomingHTTP2Connection::writeToSocket(bool socketReady) ssize_t IncomingHTTP2Connection::send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); if (conn->d_connectionDied) { return static_cast(length); @@ -550,6 +552,7 @@ void NGHTTP2Headers::addDynamicHeader(std::vector& headers, NGHTTP2H IOState IncomingHTTP2Connection::sendResponse(const struct timeval& now, TCPResponse&& response) { + (void)now; if (response.d_idstate.d_streamID == -1) { throw std::runtime_error("Invalid DoH stream ID while sending response"); } @@ -601,6 +604,7 @@ bool IncomingHTTP2Connection::sendResponse(IncomingHTTP2Connection::StreamID str data_provider.source.ptr = this; data_provider.read_callback = [](nghttp2_session*, IncomingHTTP2Connection::StreamID stream_id, uint8_t* buf, size_t length, uint32_t* data_flags, nghttp2_data_source* source, void* cb_data) -> ssize_t { + (void)source; auto* connection = static_cast(cb_data); auto& obj = connection->d_currentStreams.at(stream_id); size_t toCopy = 0; @@ -907,6 +911,7 @@ void IncomingHTTP2Connection::handleIncomingQuery(IncomingHTTP2Connection::Pendi int IncomingHTTP2Connection::on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; auto* conn = static_cast(user_data); /* is this the last frame for this stream? */ if ((frame->hd.type == NGHTTP2_HEADERS || frame->hd.type == NGHTTP2_DATA) && (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) != 0) { @@ -929,6 +934,8 @@ int IncomingHTTP2Connection::on_frame_recv_callback(nghttp2_session* session, co int IncomingHTTP2Connection::on_stream_close_callback(nghttp2_session* session, IncomingHTTP2Connection::StreamID stream_id, uint32_t error_code, void* user_data) { + (void)session; + (void)error_code; auto* conn = static_cast(user_data); conn->d_currentStreams.erase(stream_id); @@ -937,6 +944,7 @@ int IncomingHTTP2Connection::on_stream_close_callback(nghttp2_session* session, int IncomingHTTP2Connection::on_begin_headers_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; if (frame->hd.type != NGHTTP2_HEADERS || frame->headers.cat != NGHTTP2_HCAT_REQUEST) { return 0; } @@ -973,6 +981,8 @@ static std::string::size_type getLengthOfPathWithoutParameters(const std::string int IncomingHTTP2Connection::on_header_callback(nghttp2_session* session, const nghttp2_frame* frame, const uint8_t* name, size_t nameLen, const uint8_t* value, size_t valuelen, uint8_t flags, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); if (frame->hd.type == NGHTTP2_HEADERS && frame->headers.cat == NGHTTP2_HCAT_REQUEST) { @@ -1054,6 +1064,8 @@ int IncomingHTTP2Connection::on_header_callback(nghttp2_session* session, const int IncomingHTTP2Connection::on_data_chunk_recv_callback(nghttp2_session* session, uint8_t flags, IncomingHTTP2Connection::StreamID stream_id, const uint8_t* data, size_t len, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); auto stream = conn->d_currentStreams.find(stream_id); if (stream == conn->d_currentStreams.end()) { @@ -1073,9 +1085,10 @@ int IncomingHTTP2Connection::on_data_chunk_recv_callback(nghttp2_session* sessio int IncomingHTTP2Connection::on_error_callback(nghttp2_session* session, int lib_error_code, const char* msg, size_t len, void* user_data) { + (void)session; auto* conn = static_cast(user_data); - vinfolog("Error in HTTP/2 connection from %d: %s", conn->d_ci.remote.toStringWithPort(), std::string(msg, len)); + vinfolog("Error in HTTP/2 connection from %s: %s (%d)", conn->d_ci.remote.toStringWithPort(), std::string(msg, len), lib_error_code); conn->d_connectionClosing = true; conn->d_needFlush = true; nghttp2_session_terminate_session(conn->d_session.get(), NGHTTP2_NO_ERROR); diff --git a/pdns/dnsdistdist/dnsdist-nghttp2.cc b/pdns/dnsdistdist/dnsdist-nghttp2.cc index e42ff741af..3ce8c376f2 100644 --- a/pdns/dnsdistdist/dnsdist-nghttp2.cc +++ b/pdns/dnsdistdist/dnsdist-nghttp2.cc @@ -197,6 +197,7 @@ void DoHConnectionToBackend::handleIOError() void DoHConnectionToBackend::handleTimeout(const struct timeval& now, bool write) { + (void)now; if (write) { if (d_firstWrite) { ++d_ds->tcpConnectTimeouts; @@ -301,6 +302,8 @@ void DoHConnectionToBackend::queueQuery(std::shared_ptr& sender, data_provider.source.ptr = this; data_provider.read_callback = [](nghttp2_session* session, int32_t stream_id, uint8_t* buf, size_t length, uint32_t* data_flags, nghttp2_data_source* source, void* user_data) -> ssize_t { + (void)session; + (void)source; auto* conn = static_cast(user_data); auto& request = conn->d_currentStreams.at(stream_id); size_t toCopy = 0; @@ -513,6 +516,8 @@ void DoHConnectionToBackend::watchForRemoteHostClosingConnection() ssize_t DoHConnectionToBackend::send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data) { + (void)session; + (void)flags; DoHConnectionToBackend* conn = reinterpret_cast(user_data); bool bufferWasEmpty = conn->d_out.empty(); if (!conn->d_proxyProtocolPayloadSent && !conn->d_proxyProtocolPayload.empty()) { @@ -555,6 +560,7 @@ ssize_t DoHConnectionToBackend::send_callback(nghttp2_session* session, const ui int DoHConnectionToBackend::on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; DoHConnectionToBackend* conn = reinterpret_cast(user_data); // cerr<<"Frame type is "<hd.type)<(user_data); // cerr<<"Got data of size "<d_currentStreams.find(stream_id); @@ -676,6 +684,7 @@ int DoHConnectionToBackend::on_data_chunk_recv_callback(nghttp2_session* session int DoHConnectionToBackend::on_stream_close_callback(nghttp2_session* session, int32_t stream_id, uint32_t error_code, void* user_data) { + (void)session; DoHConnectionToBackend* conn = reinterpret_cast(user_data); if (error_code == 0) { @@ -724,6 +733,8 @@ int DoHConnectionToBackend::on_stream_close_callback(nghttp2_session* session, i int DoHConnectionToBackend::on_header_callback(nghttp2_session* session, const nghttp2_frame* frame, const uint8_t* name, size_t namelen, const uint8_t* value, size_t valuelen, uint8_t flags, void* user_data) { + (void)session; + (void)flags; DoHConnectionToBackend* conn = reinterpret_cast(user_data); const std::string status(":status"); @@ -754,7 +765,8 @@ int DoHConnectionToBackend::on_header_callback(nghttp2_session* session, const n int DoHConnectionToBackend::on_error_callback(nghttp2_session* session, int lib_error_code, const char* msg, size_t len, void* user_data) { - vinfolog("Error in HTTP/2 connection: %s", std::string(msg, len)); + (void)session; + vinfolog("Error in HTTP/2 connection: %s (%d)", std::string(msg, len), lib_error_code); DoHConnectionToBackend* conn = reinterpret_cast(user_data); conn->d_connectionDied = true; @@ -821,6 +833,7 @@ DoHConnectionToBackend::DoHConnectionToBackend(const std::shared_ptr(param); std::unique_ptr cpq{nullptr}; diff --git a/pdns/dnsdistdist/dnsdist-snmp.cc b/pdns/dnsdistdist/dnsdist-snmp.cc index cbd8c619d9..c32399fbad 100644 --- a/pdns/dnsdistdist/dnsdist-snmp.cc +++ b/pdns/dnsdistdist/dnsdist-snmp.cc @@ -80,6 +80,7 @@ static int handleCounter64Stats(netsnmp_mib_handler* handler, netsnmp_agent_request_info* reqinfo, netsnmp_request_info* requests) { + (void)handler; if (reqinfo->mode != MODE_GET) { return SNMP_ERR_GENERR; } @@ -126,6 +127,7 @@ static int handleFloatStats(netsnmp_mib_handler* handler, netsnmp_agent_request_info* reqinfo, netsnmp_request_info* requests) { + (void)handler; if (reqinfo->mode != MODE_GET) { return SNMP_ERR_GENERR; } @@ -177,6 +179,7 @@ static int handleGauge64Stats(netsnmp_mib_handler* handler, netsnmp_agent_request_info* reqinfo, netsnmp_request_info* requests) { + (void)handler; if (reqinfo->mode != MODE_GET) { return SNMP_ERR_GENERR; } @@ -259,6 +262,8 @@ static netsnmp_variable_list* backendStatTable_get_next_data_point(void** loop_c netsnmp_variable_list* put_index_data, netsnmp_iterator_info* mydata) { + (void)loop_context; + (void)mydata; if (s_currentServerIdx >= s_servers.size()) { return nullptr; } @@ -297,6 +302,8 @@ static int backendStatTable_handler(netsnmp_mib_handler* handler, netsnmp_agent_request_info* reqinfo, netsnmp_request_info* requests) { + (void)handler; + (void)reginfo; netsnmp_request_info* request{nullptr}; switch (reqinfo->mode) { diff --git a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc index 5c269695f6..d23350b4d1 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc +++ b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc @@ -224,17 +224,12 @@ static void editPayloadID(PacketBuffer& payload, uint16_t newId, size_t proxyPro memcpy(&payload.at(startOfHeaderOffset), &id, sizeof(id)); } -enum class QueryState : uint8_t { - hasSizePrepended, - noSize -}; - enum class ConnectionState : uint8_t { needProxy, proxySent }; -static void prepareQueryForSending(TCPQuery& query, uint16_t id, QueryState queryState, ConnectionState connectionState) +static void prepareQueryForSending(TCPQuery& query, uint16_t id, ConnectionState connectionState) { if (connectionState == ConnectionState::needProxy) { if (query.d_proxyProtocolPayload.size() > 0 && !query.d_proxyProtocolPayloadAdded) { @@ -266,7 +261,7 @@ IOState TCPConnectionToBackend::queueNextQuery(std::shared_ptrd_currentQuery = std::move(conn->d_pendingQueries.front()); uint16_t id = conn->d_highestStreamID; - prepareQueryForSending(conn->d_currentQuery.d_query, id, QueryState::hasSizePrepended, conn->needProxyProtocolPayload() ? ConnectionState::needProxy : ConnectionState::proxySent); + prepareQueryForSending(conn->d_currentQuery.d_query, id, conn->needProxyProtocolPayload() ? ConnectionState::needProxy : ConnectionState::proxySent); conn->d_pendingQueries.pop_front(); conn->d_state = State::sendingQueryToBackend; @@ -277,6 +272,7 @@ IOState TCPConnectionToBackend::queueNextQuery(std::shared_ptr& conn, const struct timeval& now) { + (void)now; DEBUGLOG("sending query to backend "<getDS()->getNameWithAddr()<<" over FD "<d_handler->getDescriptor()); IOState state = conn->d_handler->tryWrite(conn->d_currentQuery.d_query.d_buffer, conn->d_currentPos, conn->d_currentQuery.d_query.d_buffer.size()); @@ -428,7 +424,7 @@ void TCPConnectionToBackend::handleIO(std::shared_ptr& c /* we need to edit this query so it has the correct ID */ auto query = std::move(conn->d_currentQuery); uint16_t id = conn->d_highestStreamID; - prepareQueryForSending(query.d_query, id, QueryState::hasSizePrepended, ConnectionState::needProxy); + prepareQueryForSending(query.d_query, id, ConnectionState::needProxy); conn->d_currentQuery = std::move(query); } @@ -542,7 +538,7 @@ void TCPConnectionToBackend::queueQuery(std::shared_ptr& sender, uint16_t id = d_highestStreamID; d_currentQuery = PendingRequest({sender, std::move(query)}); - prepareQueryForSending(d_currentQuery.d_query, id, QueryState::hasSizePrepended, needProxyProtocolPayload() ? ConnectionState::needProxy : ConnectionState::proxySent); + prepareQueryForSending(d_currentQuery.d_query, id, needProxyProtocolPayload() ? ConnectionState::needProxy : ConnectionState::proxySent); struct timeval now; gettimeofday(&now, 0); diff --git a/pdns/dnsdistdist/dnsdist-tcp-upstream.hh b/pdns/dnsdistdist/dnsdist-tcp-upstream.hh index df177c8778..e7c3a1a3b9 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-upstream.hh +++ b/pdns/dnsdistdist/dnsdist-tcp-upstream.hh @@ -165,6 +165,7 @@ public: } virtual std::unique_ptr getDOHUnit(uint32_t streamID) { + (void)streamID; throw std::runtime_error("Getting a DOHUnit state from a generic TCP/DoT connection is not supported"); } virtual void restoreDOHUnit(std::unique_ptr&&) diff --git a/pdns/dnsdistdist/dnsdist-tcp.cc b/pdns/dnsdistdist/dnsdist-tcp.cc index d251635214..5454a156a8 100644 --- a/pdns/dnsdistdist/dnsdist-tcp.cc +++ b/pdns/dnsdistdist/dnsdist-tcp.cc @@ -288,6 +288,7 @@ void IncomingTCPConnectionState::registerOwnedDownstreamConnection(std::shared_p /* called when the buffer has been set and the rules have been processed, and only from handleIO (sometimes indirectly via handleQuery) */ IOState IncomingTCPConnectionState::sendResponse(const struct timeval& now, TCPResponse&& response) { + (void)now; d_state = State::sendingResponse; const auto responseSize = static_cast(response.d_buffer.size()); @@ -1208,7 +1209,7 @@ void IncomingTCPConnectionState::notifyIOError(const struct timeval& now, TCPRes } } -static bool processXFRResponse(PacketBuffer& response, DNSResponse& dnsResponse) +static bool processXFRResponse(DNSResponse& dnsResponse) { const auto& chains = dnsdist::configuration::getCurrentRuntimeConfiguration().d_ruleChains; const auto& xfrRespRuleActions = dnsdist::rules::getResponseRuleChain(chains, dnsdist::rules::ResponseRuleChain::XFRResponseRules); @@ -1242,7 +1243,7 @@ void IncomingTCPConnectionState::handleXFRResponse(const struct timeval& now, TC dnsResponse.d_incomingTCPState = state; memcpy(&response.d_cleartextDH, dnsResponse.getHeader().get(), sizeof(response.d_cleartextDH)); - if (!processXFRResponse(response.d_buffer, dnsResponse)) { + if (!processXFRResponse(dnsResponse)) { state->terminateClientConnection(); return; } @@ -1270,6 +1271,7 @@ void IncomingTCPConnectionState::handleTimeout(std::shared_ptr(param); std::unique_ptr citmp{nullptr}; @@ -1303,6 +1305,7 @@ static void handleIncomingTCPQuery(int pipefd, FDMultiplexer::funcparam_t& param static void handleCrossProtocolQuery(int pipefd, FDMultiplexer::funcparam_t& param) { + (void)pipefd; auto* threadData = boost::any_cast(param); std::unique_ptr cpq{nullptr}; @@ -1340,6 +1343,7 @@ static void handleCrossProtocolQuery(int pipefd, FDMultiplexer::funcparam_t& par static void handleCrossProtocolResponse(int pipefd, FDMultiplexer::funcparam_t& param) { + (void)pipefd; auto* threadData = boost::any_cast(param); std::unique_ptr cpr{nullptr}; @@ -1509,6 +1513,7 @@ static void tcpClientThread(pdns::channel::Receiver&& queryRecei } auto acceptCallback = [&data](int socket, FDMultiplexer::funcparam_t& funcparam) { + (void)socket; const auto* acceptorParam = boost::any_cast(funcparam); acceptNewConnection(*acceptorParam, &data); }; @@ -1671,6 +1676,7 @@ void tcpAcceptorThread(const std::vector& states) } else { auto acceptCallback = [](int socket, FDMultiplexer::funcparam_t& funcparam) { + (void)socket; const auto* acceptorParam = boost::any_cast(funcparam); acceptNewConnection(*acceptorParam, nullptr); }; diff --git a/pdns/dnsdistdist/dnsdist-web.cc b/pdns/dnsdistdist/dnsdist-web.cc index 94db95c31a..fc529283ea 100644 --- a/pdns/dnsdistdist/dnsdist-web.cc +++ b/pdns/dnsdistdist/dnsdist-web.cc @@ -1737,7 +1737,7 @@ void clearWebHandlers() #ifndef DISABLE_BUILTIN_HTML #include "htmlfiles.h" -static void redirectToIndex(const YaHTTP::Request& req, YaHTTP::Response& resp) +static void redirectToIndex([[maybe_unused]] const YaHTTP::Request& req, YaHTTP::Response& resp) { const string charset = "; charset=utf-8"; resp.body.assign(s_urlmap.at("index.html")); diff --git a/pdns/dnsdistdist/dnsdist.cc b/pdns/dnsdistdist/dnsdist.cc index e54005a991..22ae585217 100644 --- a/pdns/dnsdistdist/dnsdist.cc +++ b/pdns/dnsdistdist/dnsdist.cc @@ -1310,7 +1310,7 @@ bool checkQueryHeaders(const struct dnsheader& dnsHeader, ClientState& clientSta } #if !defined(DISABLE_RECVMMSG) && defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) -static void queueResponse(const ClientState& clientState, const PacketBuffer& response, const ComboAddress& dest, const ComboAddress& remote, struct mmsghdr& outMsg, struct iovec* iov, cmsgbuf_aligned* cbuf) +static void queueResponse(const PacketBuffer& response, const ComboAddress& dest, const ComboAddress& remote, struct mmsghdr& outMsg, struct iovec* iov, cmsgbuf_aligned* cbuf) { outMsg.msg_len = 0; // NOLINTNEXTLINE(cppcoreguidelines-pro-type-const-cast,cppcoreguidelines-pro-type-reinterpret-cast): API @@ -1579,6 +1579,7 @@ public: void handleResponse(const struct timeval& now, TCPResponse&& response) override { + (void)now; if (!response.d_ds && !response.d_idstate.selfGenerated) { throw std::runtime_error("Passing a cross-protocol answer originated from UDP without a valid downstream"); } @@ -1833,7 +1834,7 @@ static void processUDPQuery(ClientState& clientState, const struct msghdr* msgh, #ifndef DISABLE_RECVMMSG #if defined(HAVE_RECVMMSG) && defined(HAVE_SENDMMSG) && defined(MSG_WAITFORONE) if (dnsQuestion.ids.delayMsec == 0 && responsesVect != nullptr) { - queueResponse(clientState, query, dest, remote, (*responsesVect)[*queuedResponses], respIOV, respCBuf); + queueResponse(query, dest, remote, (*responsesVect)[*queuedResponses], respIOV, respCBuf); (*queuedResponses)++; handleResponseSent(dnsQuestion.ids.qname, dnsQuestion.ids.qtype, 0., remote, ComboAddress(), query.size(), *dnsHeader, dnsdist::Protocol::DoUDP, dnsdist::Protocol::DoUDP, false); return; @@ -2173,6 +2174,7 @@ static void udpClientThread(std::vector states) } else { auto callback = [&remote, &msgh, &iov, &packet, &handleOnePacket, initialBufferSize](int socket, FDMultiplexer::funcparam_t& funcparam) { + (void)socket; const auto* param = boost::any_cast(funcparam); try { remote.sin4.sin_family = param->cs->local.sin4.sin_family; @@ -2369,7 +2371,7 @@ static void healthChecksThread() } } -static void bindAny(int addressFamily, int sock) +static void bindAny([[maybe_unused]] int addressFamily, int sock) { __attribute__((unused)) int one = 1; diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc index 739684477b..f59298e2f3 100644 --- a/pdns/dnsdistdist/doh.cc +++ b/pdns/dnsdistdist/doh.cc @@ -485,6 +485,7 @@ public: void handleResponse(const struct timeval& now, TCPResponse&& response) override { + (void)now; if (!response.d_idstate.du) { return; } @@ -546,6 +547,7 @@ public: void notifyIOError(const struct timeval& now, TCPResponse&& response) override { + (void)now; auto& query = response.d_idstate; if (!query.du) { return; @@ -856,6 +858,7 @@ static void processDOHQuery(DOHUnitUniquePtr&& unit, bool inMainThread = false) /* called when a HTTP response is about to be sent, from the main DoH thread */ static void on_response_ready_cb(struct st_h2o_filter_t *self, h2o_req_t *req, h2o_ostream_t **slot) { + (void)self; if (req == nullptr) { return; } @@ -1294,6 +1297,7 @@ static void dnsdistclient(pdns::channel::Receiver&& receiver) */ static void on_dnsdist(h2o_socket_t *listener, const char *err) { + (void)err; /* we want to read as many responses from the pipe as possible before giving up. Even if we are overloaded and fighting with the DoH connections for the CPU, the first thing we need to do is to send responses to free slots diff --git a/pdns/dnsdistdist/doh3.cc b/pdns/dnsdistdist/doh3.cc index edd08934d1..c67f053db9 100644 --- a/pdns/dnsdistdist/doh3.cc +++ b/pdns/dnsdistdist/doh3.cc @@ -780,7 +780,7 @@ static void processH3HeaderEvent(ClientState& clientState, DOH3Frontend& fronten handleImmediateError("Unsupported HTTP method"); } -static void processH3DataEvent(ClientState& clientState, DOH3Frontend& frontend, H3Connection& conn, const ComboAddress& client, const PacketBuffer& serverConnID, const uint64_t streamID, quiche_h3_event* event, PacketBuffer& buffer) +static void processH3DataEvent(ClientState& clientState, DOH3Frontend& frontend, H3Connection& conn, const ComboAddress& client, const PacketBuffer& serverConnID, const uint64_t streamID, PacketBuffer& buffer) { auto handleImmediateError = [&clientState, &frontend, &conn, streamID](const char* msg) { DEBUGLOG(msg); @@ -854,7 +854,7 @@ static void processH3Events(ClientState& clientState, DOH3Frontend& frontend, H3 break; } case QUICHE_H3_EVENT_DATA: { - processH3DataEvent(clientState, frontend, conn, client, serverConnID, streamID, event, buffer); + processH3DataEvent(clientState, frontend, conn, client, serverConnID, streamID, buffer); break; } case QUICHE_H3_EVENT_FINISHED: diff --git a/pdns/dnsdistdist/test-dnsdist-connections-cache.cc b/pdns/dnsdistdist/test-dnsdist-connections-cache.cc index fa113aa83a..00e879af2d 100644 --- a/pdns/dnsdistdist/test-dnsdist-connections-cache.cc +++ b/pdns/dnsdistdist/test-dnsdist-connections-cache.cc @@ -71,8 +71,9 @@ public: { } - void release(bool removeFomCache) + void release(bool removeFromCache) { + (void)removeFromCache; } std::shared_ptr getDS() const diff --git a/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc b/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc index 014764974a..f1145625f6 100644 --- a/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc +++ b/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc @@ -37,6 +37,7 @@ bool dnsdist::webserver::addMetricDefinition(const dnsdist::prometheus::PrometheusMetricDefinition& def) { + (void)def; return true; } diff --git a/pdns/dnsdistdist/test-dnsdist_cc.cc b/pdns/dnsdistdist/test-dnsdist_cc.cc index 38dbd916d3..63288e26d8 100644 --- a/pdns/dnsdistdist/test-dnsdist_cc.cc +++ b/pdns/dnsdistdist/test-dnsdist_cc.cc @@ -45,26 +45,43 @@ ProcessQueryResult processQueryAfterRules(DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) { + (void)dnsQuestion; + (void)selectedBackend; return ProcessQueryResult::Drop; } bool processResponseAfterRules(PacketBuffer& response, DNSResponse& dnsResponse, bool muted) { + (void)response; + (void)dnsResponse; + (void)muted; return false; } bool applyRulesToResponse(const std::vector& respRuleActions, DNSResponse& dnsResponse) { + (void)respRuleActions; + (void)dnsResponse; return true; } bool sendUDPResponse(int origFD, const PacketBuffer& response, const int delayMsec, const ComboAddress& origDest, const ComboAddress& origRemote) { + (void)origFD; + (void)response; + (void)delayMsec; + (void)origDest; + (void)origRemote; return false; } bool assignOutgoingUDPQueryToBackend(std::shared_ptr& downstream, uint16_t queryID, DNSQuestion& dnsQuestion, PacketBuffer& query, bool actuallySend) { + (void)downstream; + (void)queryID; + (void)dnsQuestion; + (void)query; + (void)actuallySend; return true; } @@ -72,6 +89,8 @@ namespace dnsdist { std::unique_ptr getInternalQueryFromDQ(DNSQuestion& dnsQuestion, bool isResponse) { + (void)dnsQuestion; + (void)isResponse; return nullptr; } } @@ -87,6 +106,8 @@ namespace dnsdist::xsk { bool XskProcessQuery(ClientState& clientState, XskPacket& packet) { + (void)clientState; + (void)packet; return false; } } @@ -94,6 +115,9 @@ bool XskProcessQuery(ClientState& clientState, XskPacket& packet) bool processResponderPacket(std::shared_ptr& dss, PacketBuffer& response, InternalQueryState&& ids) { + (void)dss; + (void)response; + (void)ids; return false; } diff --git a/pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc b/pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc index 388389f66f..4038655e10 100644 --- a/pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc +++ b/pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc @@ -1295,6 +1295,8 @@ BOOST_FIXTURE_TEST_CASE(test_DynBlockRulesMetricsCache_GetTopN, TestFixture) { { DynBlockRulesGroup::DynBlockRule rule(reason, blockDuration, 0, 0, numberOfSeconds, action); dbrg.setSuffixMatchRule(std::move(rule), [](const StatNode& node, const StatNode::Stat& self, const StatNode::Stat& children) { + (void)node; + (void)children; if (self.queries > 0) { return std::tuple, boost::optional>(true, boost::none, boost::none); } @@ -1355,6 +1357,8 @@ BOOST_FIXTURE_TEST_CASE(test_DynBlockRulesMetricsCache_GetTopN, TestFixture) { { DynBlockRulesGroup::DynBlockRule rule(reason, blockDuration, 0, 0, numberOfSeconds, action); dbrg.setSuffixMatchRule(std::move(rule), [](const StatNode& node, const StatNode::Stat& self, const StatNode::Stat& children) { + (void)node; + (void)children; if (self.queries > 0) { return std::tuple, boost::optional>(true, "blocked for a different reason", static_cast(DNSAction::Action::Truncate)); } diff --git a/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc b/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc index 9cdaa0b2a6..3d3a712b5d 100644 --- a/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistlbpolicies_cc.cc @@ -35,6 +35,8 @@ bool TLSFrontend::setupTLS() // NOLINTNEXTLINE(readability-convert-member-functions-to-static): this is a stub, the real one is not that simple.. bool DNSDistSNMPAgent::sendDNSTrap(const DNSQuestion& dnsQuestion, const std::string& reason) { + (void)dnsQuestion; + (void)reason; return false; } @@ -51,6 +53,7 @@ bool setupDoTProtocolNegotiation(std::shared_ptr& tlsCtx) // NOLINTNEXTLINE(performance-unnecessary-value-param): this is a stub, the real one is not that simple and the performance does not matter void responderThread(std::shared_ptr dss) { + (void)dss; } string g_outputBuffer; @@ -99,6 +102,8 @@ static void benchPolicy(const ServerPolicy& pol) } } cerr << pol.name << " took " << std::to_string(sw.udiff()) << " us for " << names.size() << endl; +#else + (void)pol; #endif /* BENCH_POLICIES */ } diff --git a/pdns/dnsdistdist/test-dnsdistluanetwork.cc b/pdns/dnsdistdist/test-dnsdistluanetwork.cc index 6ddc4a2005..e84b524dfe 100644 --- a/pdns/dnsdistdist/test-dnsdistluanetwork.cc +++ b/pdns/dnsdistdist/test-dnsdistluanetwork.cc @@ -42,6 +42,7 @@ BOOST_AUTO_TEST_CASE(test_Basic) BOOST_REQUIRE(fd >= 0); listener.addUnixListeningEndpoint(socketPath, 0, [&received, payload](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)from; BOOST_CHECK_EQUAL(endpoint, 0U); BOOST_CHECK(dgram == payload); received = true; @@ -76,7 +77,11 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) /* invalid path */ dnsdist::NetworkListener listener; BOOST_CHECK_THROW(listener.addUnixListeningEndpoint(std::string(), 0, - [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) {}), + [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; + }), std::runtime_error); bool caught = false; @@ -94,6 +99,9 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) dnsdist::NetworkListener listener; bool received = false; listener.addUnixListeningEndpoint(socketPath, 0, [&received](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; received = true; }); @@ -109,7 +117,11 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) bool raised = false; try { listener.addUnixListeningEndpoint(otherSocketPath, 0, - [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) {}); + [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; + }); } catch (const std::runtime_error& e) { raised = true; @@ -122,6 +134,9 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) dnsdist::NetworkListener listener; bool received = false; listener.addUnixListeningEndpoint(socketPath, 0, [&received](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; received = true; throw std::runtime_error("Test exception"); }); @@ -142,6 +157,9 @@ BOOST_AUTO_TEST_CASE(test_Exceptions) dnsdist::NetworkListener listener; bool received = false; listener.addUnixListeningEndpoint(socketPath, 0, [&received](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; received = true; throw UnexpectedException(); }); @@ -169,6 +187,7 @@ BOOST_AUTO_TEST_CASE(test_Abstract) socketPath.insert(0, 1, 0); listener.addUnixListeningEndpoint(socketPath, 0, [&received, payload](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)from; BOOST_CHECK_EQUAL(endpoint, 0U); BOOST_CHECK(dgram == payload); received = true; @@ -189,13 +208,20 @@ BOOST_AUTO_TEST_CASE(test_Abstract_Exceptions) socketPath.insert(0, 1, 0); bool received = false; listener.addUnixListeningEndpoint(socketPath, 0, [&received](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; received = true; }); /* try binding twice to the same path */ bool raised = false; try { - listener.addUnixListeningEndpoint(socketPath, 0, [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) {}); + listener.addUnixListeningEndpoint(socketPath, 0, [](dnsdist::NetworkListener::EndpointID endpoint, std::string&& dgram, const std::string& from) { + (void)endpoint; + (void)dgram; + (void)from; + }); } catch (const std::runtime_error& e) { raised = true; diff --git a/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc b/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc index a24341f13a..d67288fe57 100644 --- a/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistnghttp2-in_cc.cc @@ -143,6 +143,9 @@ public: nghttp2_data_provider data_provider; data_provider.source.ptr = this; data_provider.read_callback = [](nghttp2_session* session, int32_t stream_id, uint8_t* buf, size_t length, uint32_t* data_flags, nghttp2_data_source* source, void* user_data) -> ssize_t { + (void)session; + (void)stream_id; + (void)source; auto* conn = static_cast(user_data); auto& pos = conn->d_position; const auto& currentQuery = conn->d_currentQuery; @@ -197,6 +200,8 @@ public: private: static ssize_t send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): nghttp2 API conn->d_clientOutBuffer.insert(conn->d_clientOutBuffer.end(), data, data + length); @@ -205,6 +210,7 @@ private: static int on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; auto* conn = static_cast(user_data); if ((frame->hd.type == NGHTTP2_HEADERS || frame->hd.type == NGHTTP2_DATA) && (frame->hd.flags & NGHTTP2_FLAG_END_STREAM) != 0) { const auto& response = conn->d_responses.at(frame->hd.stream_id); @@ -231,6 +237,8 @@ private: static int on_data_chunk_recv_callback(nghttp2_session* session, uint8_t flags, int32_t stream_id, const uint8_t* data, size_t len, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); auto& response = conn->d_responses[stream_id]; // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic): nghttp2 API @@ -240,6 +248,8 @@ private: static int on_header_callback(nghttp2_session* session, const nghttp2_frame* frame, const uint8_t* name, size_t namelen, const uint8_t* value, size_t valuelen, uint8_t flags, void* user_data) { + (void)session; + (void)flags; auto* conn = static_cast(user_data); const std::string status(":status"); if (frame->hd.type == NGHTTP2_HEADERS && frame->headers.cat == NGHTTP2_HCAT_RESPONSE) { @@ -266,6 +276,10 @@ private: static int on_stream_close_callback(nghttp2_session* session, int32_t stream_id, uint32_t error_code, void* user_data) { + (void)session; + (void)stream_id; + (void)error_code; + (void)user_data; return 0; } }; @@ -361,6 +375,8 @@ public: IOState tryConnect(bool fastOpen, const ComboAddress& remote) override { + (void)fastOpen; + (void)remote; throw std::runtime_error("Should not happen"); } @@ -402,6 +418,7 @@ public: void setSession(std::unique_ptr& session) override { + (void)session; } [[nodiscard]] std::vector getAsyncFDs() override @@ -416,15 +433,26 @@ public: void connect(bool fastOpen, const ComboAddress& remote, const struct timeval& timeout) override { + (void)fastOpen; + (void)remote; + (void)timeout; } size_t read(void* buffer, size_t bufferSize, const struct timeval& readTimeout, const struct timeval& totalTimeout = {0, 0}, bool allowIncomplete = false) override { + (void)buffer; + (void)bufferSize; + (void)readTimeout; + (void)totalTimeout; + (void)allowIncomplete; return 0; } size_t write(const void* buffer, size_t bufferSize, const struct timeval& writeTimeout) override { + (void)buffer; + (void)bufferSize; + (void)writeTimeout; return 0; } @@ -560,6 +588,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { /* dnsdist sends a response right away, client closes the connection after getting the response */ s_processQuery = [response](DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)selectedBackend; /* self answered */ dnsQuestion.getMutableData() = response; return ProcessQueryResult::SendAnswer; @@ -591,6 +620,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { /* dnsdist sends a response right away, but the client closes the connection without even reading the response */ s_processQuery = [response](DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)selectedBackend; /* self answered */ dnsQuestion.getMutableData() = response; return ProcessQueryResult::SendAnswer; @@ -626,6 +656,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { /* dnsdist sends a response right away, client closes the connection while getting the response */ s_processQuery = [response](DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)selectedBackend; /* self answered */ dnsQuestion.getMutableData() = response; return ProcessQueryResult::SendAnswer; @@ -675,9 +706,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendTimeout, TestFixture) auto backend = std::make_shared(getBackendAddress("42", 53)); - struct timeval now - { - }; + timeval now{}; gettimeofday(&now, nullptr); size_t counter = 0; @@ -700,6 +729,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendTimeout, TestFixture) { /* dnsdist forwards the query to the backend, which does not answer -> timeout */ s_processQuery = [backend](DNSQuestion& dnsQuestion, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dnsQuestion; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; diff --git a/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc b/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc index 98c37243e3..60e0fca099 100644 --- a/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc +++ b/pdns/dnsdistdist/test-dnsdistnghttp2_cc.cc @@ -168,6 +168,9 @@ public: nghttp2_data_provider dataProvider; dataProvider.source.ptr = &data; dataProvider.read_callback = [](nghttp2_session* session, int32_t stream_id, uint8_t* buf, size_t length, uint32_t* data_flags, nghttp2_data_source* source, void* user_data) -> ssize_t { + (void)session; + (void)stream_id; + (void)user_data; auto buffer = reinterpret_cast(source->ptr); size_t toCopy = 0; if (buffer->size() > 0) { @@ -193,6 +196,7 @@ public: void submitError(uint32_t streamId, uint16_t status, const std::string& msg) { + (void)msg; const std::string statusStr = std::to_string(status); const nghttp2_nv hdrs[] = {{(uint8_t*)":status", (uint8_t*)statusStr.c_str(), sizeof(":status") - 1, statusStr.size(), NGHTTP2_NV_FLAG_NONE}}; @@ -215,6 +219,8 @@ public: private: static ssize_t send_callback(nghttp2_session* session, const uint8_t* data, size_t length, int flags, void* user_data) { + (void)session; + (void)flags; DOHConnection* conn = reinterpret_cast(user_data); // cerr<<"inserting "<d_serverOutBuffer.size()<d_idMapping.empty() && length > 9) { @@ -240,6 +246,7 @@ private: static int on_frame_recv_callback(nghttp2_session* session, const nghttp2_frame* frame, void* user_data) { + (void)session; DOHConnection* conn = reinterpret_cast(user_data); // cerr<<"Frame type is "<hd.type)<hd.type == NGHTTP2_HEADERS || frame->hd.type == NGHTTP2_DATA) && frame->hd.flags & NGHTTP2_FLAG_END_STREAM) { @@ -295,6 +302,8 @@ private: static int on_data_chunk_recv_callback(nghttp2_session* session, uint8_t flags, int32_t stream_id, const uint8_t* data, size_t len, void* user_data) { + (void)session; + (void)flags; DOHConnection* conn = reinterpret_cast(user_data); auto& query = conn->d_queries[stream_id]; query.insert(query.end(), data, data + len); @@ -303,6 +312,9 @@ private: static int on_stream_close_callback(nghttp2_session* session, int32_t stream_id, uint32_t error_code, void* user_data) { + (void)session; + (void)stream_id; + (void)user_data; if (error_code == 0) { return 0; } @@ -397,6 +409,8 @@ public: IOState tryConnect(bool fastOpen, const ComboAddress& remote) override { + (void)fastOpen; + (void)remote; auto step = getStep(); BOOST_REQUIRE_EQUAL(step.request, ExpectedStep::ExpectedRequest::connectToBackend); @@ -441,6 +455,7 @@ public: void setSession(std::unique_ptr& session) override { + (void)session; } std::vector getAsyncFDs() override @@ -455,15 +470,26 @@ public: void connect(bool fastOpen, const ComboAddress& remote, const struct timeval& timeout) override { + (void)fastOpen; + (void)remote; + (void)timeout; } size_t read(void* buffer, size_t bufferSize, const struct timeval& readTimeout, const struct timeval& totalTimeout = {0, 0}, bool allowIncomplete = false) override { + (void)buffer; + (void)bufferSize; + (void)readTimeout; + (void)totalTimeout; + (void)allowIncomplete; return 0; } size_t write(const void* buffer, size_t bufferSize, const struct timeval& writeTimeout) override { + (void)buffer; + (void)bufferSize; + (void)writeTimeout; return 0; } @@ -780,10 +806,12 @@ BOOST_FIXTURE_TEST_CASE(test_ConnectionReuse, TestFixture) {ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, std::numeric_limits::max()}, /* acknowledge settings */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max(), [&firstQueryDone](int desc) { + (void)desc; firstQueryDone = true; }}, /* headers */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max(), [](int desc) { + (void)desc; }}, /* data */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max(), [](int desc) { @@ -794,6 +822,7 @@ BOOST_FIXTURE_TEST_CASE(test_ConnectionReuse, TestFixture) {ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, std::numeric_limits::max()}, /* later the backend sends a go away frame */ {ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, std::numeric_limits::max(), [](int desc) { + (void)desc; s_connectionBuffers.at(desc)->submitGoAway(); }}, {ExpectedStep::ExpectedRequest::closeBackend, IOState::Done}, @@ -867,6 +896,7 @@ BOOST_FIXTURE_TEST_CASE(test_InvalidDNSAnswer, TestFixture) auto sender = std::make_shared(); sender->d_id = counter; sender->d_customHandler = [](uint16_t id, const struct timeval&, TCPResponse&& resp) { + (void)id; BOOST_CHECK_EQUAL(resp.d_buffer.size(), 11U); /* simulate an exception, since DoH and UDP frontends will process the query right away, while TCP and DoT will first pass it back to the TCP worker thread */ @@ -966,6 +996,7 @@ BOOST_FIXTURE_TEST_CASE(test_TimeoutWhileWriting, TestFixture) {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max()}, /* data */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::NeedWrite, std::numeric_limits::max(), [&timeout](int desc) { + (void)desc; timeout = true; }}, {ExpectedStep::ExpectedRequest::closeBackend, IOState::Done}, @@ -1053,6 +1084,7 @@ BOOST_FIXTURE_TEST_CASE(test_TimeoutWhileReading, TestFixture) {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max()}, /* data */ {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max(), [&timeout](int desc) { + (void)desc; /* set the timeout flag now, since the timeout occurs while waiting for the descriptor to become readable */ timeout = true; }}, @@ -1717,6 +1749,7 @@ BOOST_FIXTURE_TEST_CASE(test_WrongStreamID, TestFixture) {ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, std::numeric_limits::max()}, /* read ends up as a time out since nghttp2 filters the frame with the wrong stream ID */ {ExpectedStep::ExpectedRequest::readFromBackend, IOState::NeedRead, 0, [&timeout](int desc) { + (void)desc; /* set the timeout flag now, since the timeout occurs while waiting for the descriptor to become readable */ timeout = true; }}, diff --git a/pdns/dnsdistdist/test-dnsdistnghttp2_common.hh b/pdns/dnsdistdist/test-dnsdistnghttp2_common.hh index b6f9bdd10b..afcdc38d26 100644 --- a/pdns/dnsdistdist/test-dnsdistnghttp2_common.hh +++ b/pdns/dnsdistdist/test-dnsdistnghttp2_common.hh @@ -30,16 +30,22 @@ public: std::unique_ptr getConnection(int socket, const struct timeval& timeout, time_t now) override { + (void)timeout; + (void)now; return std::make_unique(socket); } std::unique_ptr getClientConnection(const std::string& host, bool hostIsAddr, int socket, const struct timeval& timeout) override { + (void)host; + (void)hostIsAddr; + (void)timeout; return std::make_unique(socket, true, d_needProxyProtocol); } void rotateTicketsKey(time_t now) override { + (void)now; } size_t getTicketsKeysCount() override @@ -68,6 +74,7 @@ public: int run(struct timeval* tv, int timeout = 500) override { + (void)timeout; int ret = 0; gettimeofday(tv, nullptr); // MANDATORY @@ -97,14 +104,19 @@ public: void getAvailableFDs(std::vector& fds, int timeout) override { + (void)fds; + (void)timeout; } void addFD(int fd, FDMultiplexer::EventKind kind) override { + (void)fd; + (void)kind; } void removeFD(int fd, FDMultiplexer::EventKind) override { + (void)fd; } string getName() const override diff --git a/pdns/dnsdistdist/test-dnsdisttcp_cc.cc b/pdns/dnsdistdist/test-dnsdisttcp_cc.cc index 1bf6a66bb8..ca8a3a773a 100644 --- a/pdns/dnsdistdist/test-dnsdisttcp_cc.cc +++ b/pdns/dnsdistdist/test-dnsdisttcp_cc.cc @@ -38,21 +38,37 @@ const bool TCPIOHandler::s_disableConnectForUnitTests = true; bool checkDNSCryptQuery(const ClientState& cs, PacketBuffer& query, std::unique_ptr& dnsCryptQuery, time_t now, bool tcp) { + (void)cs; + (void)query; + (void)dnsCryptQuery; + (void)now; + (void)tcp; return false; } bool checkQueryHeaders(const struct dnsheader& dnsHeader, ClientState& clientState) { + (void)dnsHeader; + (void)clientState; return true; } uint64_t uptimeOfProcess(const std::string& str) { + (void)str; return 0; } void handleResponseSent(const InternalQueryState& ids, double udiff, const ComboAddress& client, const ComboAddress& backend, unsigned int size, const dnsheader& cleartextDH, dnsdist::Protocol protocol, bool fromBackend) { + (void)ids; + (void)udiff; + (void)client; + (void)backend; + (void)size; + (void)cleartextDH; + (void)protocol; + (void)fromBackend; } void handleResponseSent(const DNSName& qname, const QType& qtype, double udiff, const ComboAddress& client, const ComboAddress& backend, unsigned int size, const dnsheader& cleartextDH, dnsdist::Protocol outgoingProtocol, dnsdist::Protocol incomingProtocol, bool fromBackend) @@ -72,6 +88,12 @@ ProcessQueryResult processQuery(DNSQuestion& dnsQuestion, std::shared_ptr& remote, bool allowEmptyResponse) { + (void)response; + (void)qname; + (void)qtype; + (void)qclass; + (void)remote; + (void)allowEmptyResponse; return true; } @@ -164,6 +186,7 @@ public: IOState tryRead(PacketBuffer& buffer, size_t& pos, size_t toRead, bool allowIncomplete=false) override { + (void)allowIncomplete; auto step = getStep(); BOOST_REQUIRE_EQUAL(step.request, !d_client ? ExpectedStep::ExpectedRequest::readFromClient : ExpectedStep::ExpectedRequest::readFromBackend); @@ -193,6 +216,8 @@ public: IOState tryConnect(bool fastOpen, const ComboAddress& remote) override { + (void)fastOpen; + (void)remote; auto step = getStep(); BOOST_REQUIRE_EQUAL(step.request, ExpectedStep::ExpectedRequest::connectToBackend); @@ -242,6 +267,7 @@ public: void setSession(std::unique_ptr& session) override { + (void)session; } /* unused in that context, don't bother */ @@ -251,15 +277,26 @@ public: void connect(bool fastOpen, const ComboAddress& remote, const struct timeval& timeout) override { + (void)fastOpen; + (void)remote; + (void)timeout; } size_t read(void* buffer, size_t bufferSize, const struct timeval&readTimeout, const struct timeval& totalTimeout={0,0}, bool allowIncomplete=false) override { + (void)buffer; + (void)bufferSize; + (void)readTimeout; + (void)totalTimeout; + (void)allowIncomplete; return 0; } size_t write(const void* buffer, size_t bufferSize, const struct timeval& writeTimeout) override { + (void)buffer; + (void)bufferSize; + (void)writeTimeout; return 0; } private: @@ -289,16 +326,22 @@ public: std::unique_ptr getConnection(int socket, const struct timeval& timeout, time_t now) override { + (void)timeout; + (void)now; return std::make_unique(socket); } std::unique_ptr getClientConnection(const std::string& host, bool hostIsAddr, int socket, const struct timeval& timeout) override { + (void)host; + (void)hostIsAddr; + (void)timeout; return std::make_unique(socket, true); } void rotateTicketsKey(time_t now) override { + (void)now; } size_t getTicketsKeysCount() override @@ -325,6 +368,7 @@ public: int run(struct timeval* tv, int timeout=500) override { + (void)timeout; int ret = 0; gettimeofday(tv, nullptr); // MANDATORY @@ -355,14 +399,19 @@ public: void getAvailableFDs(std::vector& fds, int timeout) override { + (void)fds; + (void)timeout; } void addFD(int fd, FDMultiplexer::EventKind kind) override { + (void)fd; + (void)kind; } void removeFD(int fd, FDMultiplexer::EventKind) override { + (void)fd; } string getName() const override @@ -514,6 +563,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::Drop; }; @@ -536,6 +587,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; // Would be nicer to actually turn it into a response return ProcessQueryResult::SendAnswer; }; @@ -568,6 +621,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; // Would be nicer to actually turn it into a response return ProcessQueryResult::SendAnswer; }; @@ -596,6 +651,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; throw std::runtime_error("Something unexpected happened"); }; @@ -623,6 +680,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) s_steps.push_back({ ExpectedStep::ExpectedRequest::closeClient, IOState::Done }); s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; // Would be nicer to actually turn it into a response return ProcessQueryResult::SendAnswer; }; @@ -645,6 +704,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; /* should not be reached */ BOOST_CHECK(false); return ProcessQueryResult::SendAnswer; @@ -683,6 +744,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -719,6 +782,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_SelfAnswered, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -780,6 +845,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionWithProxyProtocol_SelfAnswered, T { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -813,6 +880,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionWithProxyProtocol_SelfAnswered, T { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -843,6 +912,8 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionWithProxyProtocol_SelfAnswered, T { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; @@ -922,10 +993,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -962,10 +1037,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; throw std::runtime_error("Unexpected error while processing the response"); }; @@ -1001,10 +1080,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return false; }; @@ -1044,10 +1127,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1072,9 +1159,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeClient, IOState::Done }, }; s_processQuery = [](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; + (void)selectedBackend; return ProcessQueryResult::SendAnswer; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1109,10 +1201,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1177,10 +1273,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1210,26 +1310,31 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, query.size() - 2 }, /* opening a connection to the backend (5 tries by default) */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, @@ -1239,11 +1344,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { - + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1275,11 +1383,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { - + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1322,10 +1433,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1379,10 +1494,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1435,10 +1554,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1467,24 +1590,28 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* and now reconnection fails (1) */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* 2 */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* 3 */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* 4 */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int descriptor) { + (void)descriptor; throw NetworkError("Connection refused by the backend"); } }, @@ -1494,10 +1621,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1546,10 +1677,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1606,10 +1741,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1647,10 +1786,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1711,10 +1854,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) s_steps.push_back({ ExpectedStep::ExpectedRequest::closeClient, IOState::Done }); s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1753,12 +1900,16 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnection_BackendNoOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; dq.asynchronous = true; /* note that we do nothing with the query, we just tell the frontend it was dealt with */ return ProcessQueryResult::Asynchronous; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -1941,10 +2092,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2079,6 +2234,9 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2204,6 +2362,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) /* reading a query from the client (5) */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, 2 }, { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(4).size() - 2, [&threadData,&backendDesc](int desc) { + (void)desc; /* set the backend descriptor as ready now */ dynamic_cast(threadData.mplexer.get())->setReady(backendDesc); } }, @@ -2234,6 +2393,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) /* reading a response from the backend (5) */ { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, 2 }, { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(4).size() - 2, [&threadData](int desc) { + (void)desc; /* set the client descriptor as ready to resume sending */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -2257,10 +2417,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2321,6 +2485,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(1).size() - 2 }, /* query is dropped, closing the connection to the client */ { ExpectedStep::ExpectedRequest::closeClient, IOState::Done, 0, [&timeout](int desc) { + (void)desc; timeout = true; } }, /* closing a connection to the backend after a timeout */ @@ -2329,6 +2494,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) counter = 0; s_processQuery = [backend,&counter](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; if (counter == 0) { ++counter; selectedBackend = backend; @@ -2337,6 +2503,9 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) return ProcessQueryResult::Drop; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2400,6 +2569,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(1).size() - 2 }, /* query is dropped, closing the connection to the client */ { ExpectedStep::ExpectedRequest::closeClient, IOState::Done, 0, [&threadData,&backendDescriptor](int desc) { + (void)desc; /* the backend descriptor becomes ready */ dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptor); } }, @@ -2412,6 +2582,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) counter = 0; s_processQuery = [backend,&counter](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; if (counter == 0) { ++counter; selectedBackend = backend; @@ -2420,6 +2591,9 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) return ProcessQueryResult::Drop; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2524,6 +2698,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(4).size() - 2 }, /* sending response (3) to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(4).size(), [&timeout](int desc) { + (void)desc; timeout = true; } }, /* closing a connection to the backend */ @@ -2533,10 +2708,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2649,30 +2828,36 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done, 0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done,0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done,0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done,0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done }, /* try opening a new connection to the backend, it fails (5) times */ { ExpectedStep::ExpectedRequest::connectToBackend, IOState::Done,0, [](int desc) { + (void)desc; throw NetworkError("Connection refused by the backend"); } }, /* closing a connection to the backend, client becomes ready */ { ExpectedStep::ExpectedRequest::closeBackend, IOState::Done, 0, [&threadData](int desc) { + (void)desc; /* the client descriptor is ready */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -2685,10 +2870,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -2852,6 +3041,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) } }, /* no more query from the client for now */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::NeedRead, 0 , [&threadData](int desc) { + (void)desc; /* the client descriptor becomes NOT ready */ dynamic_cast(threadData.mplexer.get())->setNotReady(-1); } }, @@ -2870,6 +3060,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, axfrResponses.at(2).size() - 2 }, /* sending response (3) to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, axfrResponses.at(2).size(), [&threadData](int desc) { + (void)desc; /* the client descriptor becomes ready */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -2892,10 +3083,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3040,6 +3235,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) } }, /* no more query from the client for now */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::NeedRead, 0 , [&threadData](int desc) { + (void)desc; /* the client descriptor becomes NOT ready */ dynamic_cast(threadData.mplexer.get())->setNotReady(-1); } }, @@ -3066,10 +3262,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [proxyEnabledBackend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = proxyEnabledBackend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3295,6 +3495,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, firstResponse.size() - 2 }, /* sending response (1) to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, firstResponse.size(), [&threadData](int desc) { + (void)desc; /* client descriptor becomes ready */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -3308,6 +3509,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, ixfrResponses.at(0).size() - 2 }, /* sending response (ixfr 1) to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, ixfrResponses.at(0).size(), [&threadData](int desc) { + (void)desc; /* the client descriptor becomes ready */ dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, @@ -3330,10 +3532,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3456,10 +3662,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [proxyEnabledBackend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = proxyEnabledBackend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3541,10 +3751,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [proxyEnabledBackend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = proxyEnabledBackend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3597,6 +3811,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) /* reading a third query from the client */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, 2 }, { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(2).size() - 2, [&timeout](int desc) { + (void)desc; timeout = true; } }, /* trying to read more from the client but nothing to read */ @@ -3608,10 +3823,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3727,6 +3946,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::NeedRead, 0 }, /* nothing more to read from the client at that moment */ { ExpectedStep::ExpectedRequest::readFromClient, IOState::NeedRead, 0, [&threadData, &backend1Desc](int desc) { + (void)desc; /* but the first backend becomes readable */ dynamic_cast(threadData.mplexer.get())->setReady(backend1Desc); } }, @@ -3768,6 +3988,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(2).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(2).size(), [&threadData,&backend1Desc,&backend2Desc](int desc) { + (void)desc; /* backend 2 is no longer readable, backend 1 becomes readable */ dynamic_cast(threadData.mplexer.get())->setNotReady(backend2Desc); dynamic_cast(threadData.mplexer.get())->setReady(backend1Desc); @@ -3777,6 +3998,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(4).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(4).size(), [&threadData,&backend1Desc,&backend2Desc](int desc) { + (void)desc; /* backend 1 is no longer readable, backend 2 becomes readable */ dynamic_cast(threadData.mplexer.get())->setNotReady(backend1Desc); dynamic_cast(threadData.mplexer.get())->setReady(backend2Desc); @@ -3786,6 +4008,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(3).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(3).size(), [&threadData,&backend2Desc](int desc) { + (void)desc; /* backend 2 is no longer readable */ dynamic_cast(threadData.mplexer.get())->setNotReady(backend2Desc); /* client becomes readable */ @@ -3801,10 +4024,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend1](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend1; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -3877,6 +4104,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) } }, /* sending it to the client. we don't have anything else to send to the client, no new query from it either, until we time out */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(0).size(), [&timeout](int desc) { + (void)desc; timeout = true; } }, /* closing a connection to the backend */ @@ -3886,10 +4114,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -4065,6 +4297,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::writeToBackend, IOState::Done, queries.at(4).size() }, /* no response ready yet, client stops being readable, first backend has a response */ { ExpectedStep::ExpectedRequest::readFromBackend, IOState::NeedRead, 0, [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(0)); } }, /* trying to read from the client but nothing yet */ @@ -4076,6 +4309,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(0).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(0).size(), [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(2)); } }, /* reading response (3) from the third backend (3) */ @@ -4083,6 +4317,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(2).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(2).size(), [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(1)); } }, /* reading response (2) from the second backend (2) */ @@ -4090,6 +4325,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(1).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(1).size(), [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(4)); } }, /* reading response (5) from the fifth backend (5) */ @@ -4097,6 +4333,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(4).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(4).size(), [&threadData,&backendDescriptors](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(backendDescriptors.at(3)); } }, /* reading response (4) from the fourth backend (4) */ @@ -4104,6 +4341,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromBackend, IOState::Done, responses.at(3).size() - 2 }, /* sending it to the client */ { ExpectedStep::ExpectedRequest::writeToClient, IOState::Done, responses.at(3).size(), [&threadData](int desc) { + (void)desc; dynamic_cast(threadData.mplexer.get())->setReady(-1); } }, /* client closes the connection */ @@ -4119,10 +4357,14 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) }; s_processQuery = [backend](DNSQuestion& dq, std::shared_ptr& selectedBackend) -> ProcessQueryResult { + (void)dq; selectedBackend = backend; return ProcessQueryResult::PassToBackend; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; }; @@ -4162,6 +4404,7 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, 2 }, { ExpectedStep::ExpectedRequest::readFromClient, IOState::Done, queries.at(1).size() - 2 }, { ExpectedStep::ExpectedRequest::readFromClient, IOState::NeedRead, 0, [&timeout](int desc) { + (void)desc; timeout = true; }}, /* close the connection with the client */ @@ -4175,6 +4418,9 @@ BOOST_FIXTURE_TEST_CASE(test_IncomingConnectionOOOR_BackendNotOOOR, TestFixture) return ProcessQueryResult::Asynchronous; }; s_processResponse = [](PacketBuffer& response, DNSResponse& dr, bool muted) -> bool { + (void)response; + (void)dr; + (void)muted; return true; };