From: Remi Gacogne Date: Tue, 26 Nov 2024 09:05:08 +0000 (+0100) Subject: dnsdist: Fix clang-tidy warnings X-Git-Tag: dnsdist-1.9.8~4^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=237c3adfd68ddc0ebb0c64a586ac514c753732eb;p=thirdparty%2Fpdns.git dnsdist: Fix clang-tidy warnings --- diff --git a/pdns/dnsdist-lua.cc b/pdns/dnsdist-lua.cc index 8f5b3bb826..48598b370e 100644 --- a/pdns/dnsdist-lua.cc +++ b/pdns/dnsdist-lua.cc @@ -3036,7 +3036,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) } }); - luaCtx.registerFunction::*)(boost::variant, LuaArray, LuaArray>> certFiles, boost::variant> keyFiles)>("loadNewCertificatesAndKeys", [](std::shared_ptr frontend, boost::variant, LuaArray, LuaArray>> certFiles, boost::variant> keyFiles) { + luaCtx.registerFunction::*)(boost::variant, LuaArray, LuaArray>> certFiles, boost::variant> keyFiles)>("loadNewCertificatesAndKeys", [](const std::shared_ptr& frontend, boost::variant, LuaArray, LuaArray>> certFiles, boost::variant> keyFiles) { #ifdef HAVE_DNS_OVER_HTTPS if (frontend != nullptr) { if (loadTLSCertificateAndKeys("DOHFrontend::loadNewCertificatesAndKeys", frontend->d_tlsContext.d_tlsConfig.d_certKeyPairs, certFiles, keyFiles)) { @@ -3046,26 +3046,26 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck) #endif }); - luaCtx.registerFunction::*)()>("rotateTicketsKey", [](std::shared_ptr frontend) { + luaCtx.registerFunction::*)()>("rotateTicketsKey", [](const std::shared_ptr& frontend) { if (frontend != nullptr) { frontend->rotateTicketsKey(time(nullptr)); } }); - luaCtx.registerFunction::*)(const std::string&)>("loadTicketsKeys", [](std::shared_ptr frontend, const std::string& file) { + luaCtx.registerFunction::*)(const std::string&)>("loadTicketsKeys", [](const std::shared_ptr& frontend, const std::string& file) { if (frontend != nullptr) { frontend->loadTicketsKeys(file); } }); - luaCtx.registerFunction::*)(const std::string&)>("loadTicketsKey", [](std::shared_ptr frontend, const std::string& key) { + luaCtx.registerFunction::*)(const std::string&)>("loadTicketsKey", [](const std::shared_ptr& frontend, const std::string& key) { if (frontend != nullptr) { frontend->loadTicketsKey(key); } }); luaCtx.writeFunction("loadTicketsKey", [](const std::string& key) { - for (auto& frontend : g_frontends) { + for (const auto& frontend : g_frontends) { if (!frontend) { continue; } diff --git a/pdns/libssl.cc b/pdns/libssl.cc index 451e7133ef..0004df3171 100644 --- a/pdns/libssl.cc +++ b/pdns/libssl.cc @@ -745,22 +745,23 @@ OpenSSLTLSTicketKey::OpenSSLTLSTicketKey(std::ifstream& file) #endif /* HAVE_LIBSODIUM */ } +// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init): d_name, d_cipherKey and d_hmacKey are initialized OpenSSLTLSTicketKey::OpenSSLTLSTicketKey(const std::string& key) { if (key.size() != (sizeof(d_name) + sizeof(d_cipherKey) + sizeof(d_hmacKey))) { throw std::runtime_error("Unable to load a ticket key from given data"); } size_t from = 0; - memcpy(d_name, &key.at(from), sizeof(d_name)); + memcpy(&d_name, &key.at(from), sizeof(d_name)); from += sizeof(d_name); - memcpy(d_cipherKey, &key.at(from), sizeof(d_cipherKey)); + memcpy(&d_cipherKey, &key.at(from), sizeof(d_cipherKey)); from += sizeof(d_cipherKey); - memcpy(d_hmacKey, &key.at(from), sizeof(d_hmacKey)); + memcpy(&d_hmacKey, &key.at(from), sizeof(d_hmacKey)); #ifdef HAVE_LIBSODIUM - sodium_mlock(d_name, sizeof(d_name)); - sodium_mlock(d_cipherKey, sizeof(d_cipherKey)); - sodium_mlock(d_hmacKey, sizeof(d_hmacKey)); + sodium_mlock(&d_name, sizeof(d_name)); + sodium_mlock(&d_cipherKey, sizeof(d_cipherKey)); + sodium_mlock(&d_hmacKey, sizeof(d_hmacKey)); #endif /* HAVE_LIBSODIUM */ }