From: Otto Moerbeek Date: Tue, 20 Jun 2023 07:24:50 +0000 (+0200) Subject: Fix unused warnings coming from our own code. X-Git-Tag: rec-5.0.0-alpha1~167^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=aa87b287c52392ab25a2024f709a6d8378d10a44;p=thirdparty%2Fpdns.git Fix unused warnings coming from our own code. Some third party warning remain, mostly coming from boost. --- diff --git a/ext/lmdb-safe/lmdb-typed.hh b/ext/lmdb-safe/lmdb-typed.hh index ad5bb07c8a..45da5e00b5 100644 --- a/ext/lmdb-safe/lmdb-typed.hh +++ b/ext/lmdb-safe/lmdb-typed.hh @@ -95,7 +95,7 @@ inline std::string keyConv(const T& t) namespace { - MDBOutVal getKeyFromCombinedKey(MDBInVal combined) { + inline MDBOutVal getKeyFromCombinedKey(MDBInVal combined) { if (combined.d_mdbval.mv_size < sizeof(uint32_t)) { throw std::runtime_error("combined key too short to get ID from"); } @@ -107,7 +107,7 @@ namespace { return ret; } - MDBOutVal getIDFromCombinedKey(MDBInVal combined) { + inline MDBOutVal getIDFromCombinedKey(MDBInVal combined) { if (combined.d_mdbval.mv_size < sizeof(uint32_t)) { throw std::runtime_error("combined key too short to get ID from"); } @@ -119,7 +119,7 @@ namespace { return ret; } - std::string makeCombinedKey(MDBInVal key, MDBInVal val) + inline std::string makeCombinedKey(MDBInVal key, MDBInVal val) { std::string lenprefix(sizeof(uint16_t), '\0'); std::string skey((char*) key.d_mdbval.mv_data, key.d_mdbval.mv_size); diff --git a/modules/geoipbackend/geoipinterface-dat.cc b/modules/geoipbackend/geoipinterface-dat.cc index 2a3f7596a8..198e60f08a 100644 --- a/modules/geoipbackend/geoipinterface-dat.cc +++ b/modules/geoipbackend/geoipinterface-dat.cc @@ -481,7 +481,7 @@ unique_ptr GeoIPInterface::makeDATInterface(const string& fname, #else -unique_ptr GeoIPInterface::makeDATInterface(const string& fname, const map& opts) +unique_ptr GeoIPInterface::makeDATInterface([[maybe_unused]] const string& fname, [[maybe_unused]] const map& opts) { throw PDNSException("libGeoIP support not compiled in"); } diff --git a/modules/geoipbackend/geoipinterface-mmdb.cc b/modules/geoipbackend/geoipinterface-mmdb.cc index fae7c44d28..5866ae1a64 100644 --- a/modules/geoipbackend/geoipinterface-mmdb.cc +++ b/modules/geoipbackend/geoipinterface-mmdb.cc @@ -288,7 +288,7 @@ unique_ptr GeoIPInterface::makeMMDBInterface(const string& fname #else -unique_ptr GeoIPInterface::makeMMDBInterface(const string& fname, const map& opts) +unique_ptr GeoIPInterface::makeMMDBInterface([[maybe_unused]] const string& fname, [[maybe_unused]] const map& opts) { throw PDNSException("libmaxminddb support not compiled in"); } diff --git a/modules/lmdbbackend/lmdbbackend.cc b/modules/lmdbbackend/lmdbbackend.cc index d6eb3ba0e8..ada437db98 100644 --- a/modules/lmdbbackend/lmdbbackend.cc +++ b/modules/lmdbbackend/lmdbbackend.cc @@ -1189,7 +1189,7 @@ bool LMDBBackend::replaceRRSet(uint32_t domain_id, const DNSName& qname, const Q return true; } -bool LMDBBackend::replaceComments(const uint32_t domain_id, const DNSName& qname, const QType& qt, const vector& comments) +bool LMDBBackend::replaceComments([[maybe_unused]] const uint32_t domain_id, [[maybe_unused]] const DNSName& qname, [[maybe_unused]] const QType& qt, const vector& comments) { // if the vector is empty, good, that's what we do here (LMDB does not store comments) // if it's not, report failure diff --git a/pdns/credentials.cc b/pdns/credentials.cc index 137f1b7f67..343c1205ec 100644 --- a/pdns/credentials.cc +++ b/pdns/credentials.cc @@ -96,7 +96,7 @@ void SensitiveData::clear() d_data.clear(); } -static std::string hashPasswordInternal(const std::string& password, const std::string& salt, uint64_t workFactor, uint64_t parallelFactor, uint64_t blockSize) +static std::string hashPasswordInternal([[maybe_unused]] const std::string& password, [[maybe_unused]] const std::string& salt, [[maybe_unused]] uint64_t workFactor, [[maybe_unused]] uint64_t parallelFactor, [[maybe_unused]] uint64_t blockSize) { #if !defined(DISABLE_HASHED_CREDENTIALS) && defined(HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT) auto pctx = std::unique_ptr(EVP_PKEY_CTX_new_id(EVP_PKEY_SCRYPT, nullptr), EVP_PKEY_CTX_free); @@ -165,7 +165,7 @@ static std::string generateRandomSalt() #endif } -std::string hashPassword(const std::string& password, uint64_t workFactor, uint64_t parallelFactor, uint64_t blockSize) +std::string hashPassword([[maybe_unused]] const std::string& password, [[maybe_unused]] uint64_t workFactor, [[maybe_unused]] uint64_t parallelFactor, [[maybe_unused]] uint64_t blockSize) { #if !defined(DISABLE_HASHED_CREDENTIALS) && defined(HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT) if (workFactor == 0) { @@ -197,7 +197,7 @@ std::string hashPassword(const std::string& password, uint64_t workFactor, uint6 #endif } -std::string hashPassword(const std::string& password) +std::string hashPassword([[maybe_unused]] const std::string& password) { #if !defined(DISABLE_HASHED_CREDENTIALS) && defined(HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT) return hashPassword(password, CredentialsHolder::s_defaultWorkFactor, CredentialsHolder::s_defaultParallelFactor, CredentialsHolder::s_defaultBlockSize); @@ -206,7 +206,7 @@ std::string hashPassword(const std::string& password) #endif } -bool verifyPassword(const std::string& binaryHash, const std::string& salt, uint64_t workFactor, uint64_t parallelFactor, uint64_t blockSize, const std::string& binaryPassword) +bool verifyPassword([[maybe_unused]] const std::string& binaryHash, [[maybe_unused]] const std::string& salt, [[maybe_unused]] uint64_t workFactor, [[maybe_unused]] uint64_t parallelFactor, [[maybe_unused]] uint64_t blockSize, [[maybe_unused]] const std::string& binaryPassword) { #if !defined(DISABLE_HASHED_CREDENTIALS) && defined(HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT) auto expected = hashPasswordInternal(binaryPassword, salt, workFactor, parallelFactor, blockSize); @@ -217,7 +217,7 @@ bool verifyPassword(const std::string& binaryHash, const std::string& salt, uint } /* parse a hashed password in PHC string format */ -static void parseHashed(const std::string& hash, std::string& salt, std::string& hashedPassword, uint64_t& workFactor, uint64_t& parallelFactor, uint64_t& blockSize) +static void parseHashed([[maybe_unused]] const std::string& hash, [[maybe_unused]] std::string& salt, [[maybe_unused]] std::string& hashedPassword, [[maybe_unused]] uint64_t& workFactor, [[maybe_unused]] uint64_t& parallelFactor, [[maybe_unused]] uint64_t& blockSize) { #if !defined(DISABLE_HASHED_CREDENTIALS) && defined(HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT) auto parametersEnd = hash.find('$', pwhash_prefix.size()); @@ -282,7 +282,7 @@ static void parseHashed(const std::string& hash, std::string& salt, std::string& #endif } -bool verifyPassword(const std::string& hash, const std::string& password) +bool verifyPassword(const std::string& hash, [[maybe_unused]] const std::string& password) { if (!isPasswordHashed(hash)) { return false; @@ -304,7 +304,7 @@ bool verifyPassword(const std::string& hash, const std::string& password) #endif } -bool isPasswordHashed(const std::string& password) +bool isPasswordHashed([[maybe_unused]] const std::string& password) { #if !defined(DISABLE_HASHED_CREDENTIALS) && defined(HAVE_EVP_PKEY_CTX_SET1_SCRYPT_SALT) if (password.size() < pwhash_prefix_size || password.size() > pwhash_max_size) { diff --git a/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc b/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc index d4367ea50e..e6f0e1e21c 100644 --- a/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc +++ b/pdns/dnsdistdist/test-dnsdist-lua-ffi.cc @@ -427,8 +427,8 @@ BOOST_AUTO_TEST_CASE(test_Server) BOOST_CHECK_EQUAL(dnsdist_ffi_server_is_up(&server), false); BOOST_CHECK_EQUAL(dnsdist_ffi_server_get_name(&server), ""); BOOST_CHECK_EQUAL(dnsdist_ffi_server_get_name_with_addr(&server), dsAddr.toStringWithPort()); - BOOST_CHECK_EQUAL(dnsdist_ffi_server_get_weight(&server), 1U); - BOOST_CHECK_EQUAL(dnsdist_ffi_server_get_order(&server), 1U); + BOOST_CHECK_EQUAL(dnsdist_ffi_server_get_weight(&server), 1); + BOOST_CHECK_EQUAL(dnsdist_ffi_server_get_order(&server), 1); BOOST_CHECK_EQUAL(dnsdist_ffi_server_get_latency(&server), 0.0); } diff --git a/pdns/dnsreplay.cc b/pdns/dnsreplay.cc index 588ca66026..b270f45a43 100644 --- a/pdns/dnsreplay.cc +++ b/pdns/dnsreplay.cc @@ -595,7 +595,7 @@ static bool checkIPTransparentUsability() static bool g_rdSelector; static uint16_t g_pcapDnsPort; -static bool sendPacketFromPR(PcapPacketReader& pr, const ComboAddress& remote, int stamp, bool usePCAPSourceIP) +static bool sendPacketFromPR(PcapPacketReader& pr, const ComboAddress& remote, int stamp, [[maybe_unused]] bool usePCAPSourceIP) { bool sent=false; if (pr.d_len <= sizeof(dnsheader)) { diff --git a/pdns/dynhandler.cc b/pdns/dynhandler.cc index 730d324cdb..b2b35a8338 100644 --- a/pdns/dynhandler.cc +++ b/pdns/dynhandler.cc @@ -410,7 +410,7 @@ string DLListZones(const vector& parts, Utility::pid_t /* ppid */) extern bool PKCS11ModuleSlotLogin(const std::string& module, const string& tokenId, const std::string& pin); #endif -string DLTokenLogin(const vector& parts, Utility::pid_t /* ppid */) +string DLTokenLogin([[maybe_unused]] const vector& parts, [[maybe_unused]] Utility::pid_t /* ppid */) { #ifndef HAVE_P11KIT1 return "PKCS#11 support not compiled in"; diff --git a/pdns/dynlistener.cc b/pdns/dynlistener.cc index a659de4fdd..456d62ba59 100644 --- a/pdns/dynlistener.cc +++ b/pdns/dynlistener.cc @@ -337,7 +337,7 @@ void DynListener::theListener() try { signal(SIGPIPE,SIG_IGN); - for(int n=0;;++n) { + for(;;) { string line=getLine(); boost::trim_right(line); diff --git a/pdns/ednscookies.cc b/pdns/ednscookies.cc index 5e57f04a86..eefa0f43f7 100644 --- a/pdns/ednscookies.cc +++ b/pdns/ednscookies.cc @@ -74,7 +74,7 @@ void EDNSCookiesOpt::getEDNSCookiesOptFromString(const char* option, unsigned in } } -bool EDNSCookiesOpt::isValid(const string& secret, const ComboAddress& source) const +bool EDNSCookiesOpt::isValid([[maybe_unused]] const string& secret, [[maybe_unused]] const ComboAddress& source) const { #ifdef HAVE_CRYPTO_SHORTHASH if (server.length() != 16 || client.length() != 8) { @@ -139,7 +139,7 @@ bool EDNSCookiesOpt::shouldRefresh() const return rfc1982LessThan(ts + 1800, now); } -bool EDNSCookiesOpt::makeServerCookie(const string& secret, const ComboAddress& source) +bool EDNSCookiesOpt::makeServerCookie([[maybe_unused]] const string& secret, [[maybe_unused]] const ComboAddress& source) { #ifdef HAVE_CRYPTO_SHORTHASH static_assert(EDNSCookieSecretSize == crypto_shorthash_KEYBYTES * 2, "The EDNSCookieSecretSize is not twice crypto_shorthash_KEYBYTES"); diff --git a/pdns/recursordist/rec-snmp.cc b/pdns/recursordist/rec-snmp.cc index 8773a158f1..d9c7007127 100644 --- a/pdns/recursordist/rec-snmp.cc +++ b/pdns/recursordist/rec-snmp.cc @@ -249,7 +249,7 @@ static void registerCounter64Stat(const std::string& name, const oid statOID[], std::shared_ptr g_snmpAgent{nullptr}; -bool RecursorSNMPAgent::sendCustomTrap(const std::string& reason) +bool RecursorSNMPAgent::sendCustomTrap([[maybe_unused]] const std::string& reason) { #ifdef HAVE_NET_SNMP netsnmp_variable_list* varList = nullptr; diff --git a/pdns/snmp-agent.cc b/pdns/snmp-agent.cc index 18a088ea43..da56e4a423 100644 --- a/pdns/snmp-agent.cc +++ b/pdns/snmp-agent.cc @@ -161,7 +161,7 @@ void SNMPAgent::worker() #endif /* HAVE_NET_SNMP */ } -SNMPAgent::SNMPAgent(const std::string& name, const std::string& daemonSocket) +SNMPAgent::SNMPAgent([[maybe_unused]] const std::string& name, [[maybe_unused]] const std::string& daemonSocket) { #ifdef HAVE_NET_SNMP netsnmp_enable_subagent(); diff --git a/pdns/speedtest.cc b/pdns/speedtest.cc index 1447080f2c..77bb60fb07 100644 --- a/pdns/speedtest.cc +++ b/pdns/speedtest.cc @@ -1182,7 +1182,7 @@ private: }; #endif -int main(int argc, char** argv) +int main() try { reportAllTypes(); diff --git a/pdns/tcpiohandler.cc b/pdns/tcpiohandler.cc index 8f4d321239..b75c3a9701 100644 --- a/pdns/tcpiohandler.cc +++ b/pdns/tcpiohandler.cc @@ -1854,7 +1854,7 @@ bool TLSFrontend::setupTLS() return true; } -std::shared_ptr getTLSContext(const TLSContextParameters& params) +std::shared_ptr getTLSContext([[maybe_unused]] const TLSContextParameters& params) { #ifdef HAVE_DNS_OVER_TLS /* get the "best" available provider */ diff --git a/pdns/webserver.cc b/pdns/webserver.cc index 43cd180e82..34577e70e5 100644 --- a/pdns/webserver.cc +++ b/pdns/webserver.cc @@ -378,7 +378,7 @@ std::string Logging::IterLoggable::to_stri } #endif -void WebServer::logRequest(const HttpRequest& req, const ComboAddress& remote) const { +void WebServer::logRequest(const HttpRequest& req, [[maybe_unused]] const ComboAddress& remote) const { if (d_loglevel >= WebServer::LogLevel::Detailed) { #ifdef RECURSOR if (!g_slogStructured) {