From: Otto Moerbeek Date: Wed, 1 Nov 2023 12:24:55 +0000 (+0100) Subject: Kill a bunch of warnings emitted by clang X-Git-Tag: rec-5.0.0-beta1~18^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d15375faa37615ef34b038ae9af56dd2d171917e;p=thirdparty%2Fpdns.git Kill a bunch of warnings emitted by clang A few are coming from boost, I disabled those by adding #pragma's --- diff --git a/ext/lmdb-safe/lmdb-safe.cc b/ext/lmdb-safe/lmdb-safe.cc index 6b93b3b7cf..6d4f8c8198 100644 --- a/ext/lmdb-safe/lmdb-safe.cc +++ b/ext/lmdb-safe/lmdb-safe.cc @@ -78,7 +78,7 @@ namespace LMDBLS { #endif /* #ifndef DNSDIST */ -MDBDbi::MDBDbi(MDB_env* env, MDB_txn* txn, const string_view dbname, int flags) +MDBDbi::MDBDbi(MDB_env* /* env */, MDB_txn* txn, const string_view dbname, int flags) { // A transaction that uses this function must finish (either commit or abort) before any other transaction in the process may use this function. diff --git a/modules/geoipbackend/geoipbackend.cc b/modules/geoipbackend/geoipbackend.cc index 2d0523158b..3a08f037db 100644 --- a/modules/geoipbackend/geoipbackend.cc +++ b/modules/geoipbackend/geoipbackend.cc @@ -34,7 +34,10 @@ #include #include #include +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wshadow" #include +#pragma clang diagnostic pop ReadWriteLock GeoIPBackend::s_state_lock; diff --git a/pdns/dnsbulktest.cc b/pdns/dnsbulktest.cc index 085a644d57..2505be3aff 100644 --- a/pdns/dnsbulktest.cc +++ b/pdns/dnsbulktest.cc @@ -22,9 +22,13 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" +#pragma clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-copy" #include #include #include +#pragma clang diagnostic pop #include #include "inflighter.cc" #include diff --git a/pdns/dnsscope.cc b/pdns/dnsscope.cc index 5e52d407a5..a16b0de4ca 100644 --- a/pdns/dnsscope.cc +++ b/pdns/dnsscope.cc @@ -203,7 +203,7 @@ try int dnserrors=0, parsefail=0; typedef map cumul_t; cumul_t cumul; - unsigned int untracked=0, errorresult=0, nonRDQueries=0, queries=0; + unsigned int untracked=0, nonRDQueries=0, queries=0; unsigned int ipv4DNSPackets=0, ipv6DNSPackets=0, fragmented=0, rdNonRAAnswers=0; unsigned int answers=0, nonDNSIP=0, rdFilterMismatch=0; unsigned int dnssecOK=0, edns=0; @@ -373,8 +373,6 @@ try if(!noservfailstats || header.rcode != 2) cumul[usecs]++; - if(header.rcode != 0 && header.rcode!=3) - errorresult++; ComboAddress rem = pr.getDest(); rem.sin4.sin_port=0; diff --git a/pdns/dnstcpbench.cc b/pdns/dnstcpbench.cc index b35ebc7a96..b0d536654c 100644 --- a/pdns/dnstcpbench.cc +++ b/pdns/dnstcpbench.cc @@ -22,11 +22,14 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" +#pragma clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-copy" #include #include #include - #include +#pragma clang diagnostic pop #include diff --git a/pdns/histog.hh b/pdns/histog.hh index fb69528326..613b115e91 100644 --- a/pdns/histog.hh +++ b/pdns/histog.hh @@ -1,6 +1,10 @@ #pragma once +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" +#pragma clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-copy" #include #include +#pragma clang diagnostic pop #include #include diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index 65630ab36a..644f07e8f0 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -48,7 +48,10 @@ #include "logger.hh" #include "ixfrdist-stats.hh" #include "ixfrdist-web.hh" +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wshadow" #include +#pragma clang diagnostic pop /* BEGIN Needed because of deeper dependencies */ #include "arguments.hh" diff --git a/pdns/libssl.cc b/pdns/libssl.cc index 610783fb82..a77d665157 100644 --- a/pdns/libssl.cc +++ b/pdns/libssl.cc @@ -202,7 +202,7 @@ std::pair libssl_load_provider(const std::string& providerNam #endif /* HAVE_LIBSSL && OPENSSL_VERSION_MAJOR >= 3 && HAVE_TLS_PROVIDERS */ #if defined(HAVE_LIBSSL) && !defined(HAVE_TLS_PROVIDERS) -std::pair libssl_load_engine(const std::string& engineName, const std::optional& defaultString) +std::pair libssl_load_engine([[maybe_unused]] const std::string& engineName, [[maybe_unused]] const std::optional& defaultString) { #ifdef OPENSSL_NO_ENGINE return { false, "OpenSSL has been built without engine support" }; diff --git a/pdns/logging.hh b/pdns/logging.hh index 637e97d67e..12c46ed581 100644 --- a/pdns/logging.hh +++ b/pdns/logging.hh @@ -202,19 +202,21 @@ extern bool g_slogStructured; // SLOG(g_log<error("No such file", "Unable to parse configuration file", "config_file", Logging::Loggable(configname)); // +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define SLOG(oldStyle, slogCall) \ - if (true) { \ + do { \ if (g_slogStructured) { \ slogCall; \ } \ else { \ oldStyle; \ } \ - } + } while (0) #else // No structured logging (e.g. auth) +// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define SLOG(oldStyle, slogCall) \ do { \ oldStyle; \ - } while (0); + } while (0) #endif // RECURSOR diff --git a/pdns/recursordist/rec-lua-conf.cc b/pdns/recursordist/rec-lua-conf.cc index 96d1294170..ee5f359b04 100644 --- a/pdns/recursordist/rec-lua-conf.cc +++ b/pdns/recursordist/rec-lua-conf.cc @@ -884,7 +884,8 @@ void loadRecursorLuaConfig(const std::string& fname, luaConfigDelayedThreads& de catch (const PDNSException& exp) { // exp is the exception that was thrown from inside the lambda SLOG(g_log << exp.reason << std::endl, - lci.d_slog->error(Logr::Error, exp.reason, "Exception loading Lua", "exception", Logging::Loggable("PDNSException"))) } + lci.d_slog->error(Logr::Error, exp.reason, "Exception loading Lua", "exception", Logging::Loggable("PDNSException"))); + } throw; } catch (std::exception& err) { diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 66508e17d0..9cc1cde07a 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -2788,7 +2788,7 @@ static void recursorThread() if (threadInfo.isHandler()) { if (::arg().mustDo("webserver")) { SLOG(g_log << Logger::Warning << "Enabling web server" << endl, - log->info(Logr::Info, "Enabling web server")) + log->info(Logr::Info, "Enabling web server")); try { rws = make_unique(t_fdm.get()); } @@ -2837,11 +2837,11 @@ static void recursorThread() } catch (PDNSException& ae) { SLOG(g_log << Logger::Error << "Exception: " << ae.reason << endl, - log->error(Logr::Error, ae.reason, "Exception in RecursorThread", "exception", Logging::Loggable("PDNSException"))) + log->error(Logr::Error, ae.reason, "Exception in RecursorThread", "exception", Logging::Loggable("PDNSException"))); } catch (std::exception& e) { SLOG(g_log << Logger::Error << "STL Exception: " << e.what() << endl, - log->error(Logr::Error, e.what(), "Exception in RecursorThread", "exception", Logging::Loggable("std::exception"))) + log->error(Logr::Error, e.what(), "Exception in RecursorThread", "exception", Logging::Loggable("std::exception"))); } catch (...) { SLOG(g_log << Logger::Error << "any other exception in main: " << endl, diff --git a/pdns/recursordist/rpzloader.cc b/pdns/recursordist/rpzloader.cc index c99480fea3..fb6eb04463 100644 --- a/pdns/recursordist/rpzloader.cc +++ b/pdns/recursordist/rpzloader.cc @@ -508,7 +508,7 @@ void RPZIXFRTracker(const std::vector& primaries, const boost::opt if (luaconfsLocal->generation != configGeneration) { SLOG(g_log << Logger::Info << "A more recent configuration has been found, stopping the existing RPZ update thread for " << zoneName << endl, - logger->info(Logr::Info, "A more recent configuration has been found, stopping the existing RPZ update thread")) + logger->info(Logr::Info, "A more recent configuration has been found, stopping the existing RPZ update thread")); return; } oldZone = luaconfsLocal->dfe.getZone(zoneIdx); diff --git a/pdns/recursordist/ws-recursor.cc b/pdns/recursordist/ws-recursor.cc index 2737f78ec0..64c027da55 100644 --- a/pdns/recursordist/ws-recursor.cc +++ b/pdns/recursordist/ws-recursor.cc @@ -1570,7 +1570,7 @@ void AsyncWebServer::serveConnection(const std::shared_ptr& socket) cons } catch (...) { SLOG(g_log << Logger::Error << logprefix << "Unknown exception" << endl, - req.d_slog->error(Logr::Error, "Exception handing request")) + req.d_slog->error(Logr::Error, "Exception handing request")); } } diff --git a/pdns/tcpiohandler.cc b/pdns/tcpiohandler.cc index a5d00ed73b..03468f8e36 100644 --- a/pdns/tcpiohandler.cc +++ b/pdns/tcpiohandler.cc @@ -1129,9 +1129,9 @@ public: /* The callback prototype changed in 3.4.0. */ #if GNUTLS_VERSION_NUMBER >= 0x030400 - static int newTicketFromServerCb(gnutls_session_t session, unsigned int htype, unsigned post, unsigned int incoming, const gnutls_datum_t* msg) + static int newTicketFromServerCb(gnutls_session_t session, unsigned int htype, unsigned post, unsigned int /* incoming */, const gnutls_datum_t* /* msg */) #else - static int newTicketFromServerCb(gnutls_session_t session, unsigned int htype, unsigned post, unsigned int incoming) + static int newTicketFromServerCb(gnutls_session_t session, unsigned int htype, unsigned post, unsigned int /* incoming */) #endif /* GNUTLS_VERSION_NUMBER >= 0x030400 */ { if (htype != GNUTLS_HANDSHAKE_NEW_SESSION_TICKET || post != GNUTLS_HOOK_POST || session == nullptr) { @@ -1153,7 +1153,7 @@ public: return 0; } - IOState tryConnect(bool fastOpen, const ComboAddress& remote) override + IOState tryConnect(bool fastOpen, [[maybe_unused]] const ComboAddress& remote) override { int ret = 0; diff --git a/pdns/test-dns_random_hh.cc b/pdns/test-dns_random_hh.cc index 7c19d72ec8..7f7324ca29 100644 --- a/pdns/test-dns_random_hh.cc +++ b/pdns/test-dns_random_hh.cc @@ -7,10 +7,14 @@ #include #include +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" +#pragma clang diagnostic ignored "-Wdeprecated-copy-with-user-provided-copy" #include #include #include #include +#pragma clang diagnostic pop #include "arguments.hh" #include "dns_random.hh"