From b4608224c49a21a2e8a343cd667265c175221c42 Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Wed, 31 Jan 2024 13:19:08 +0100 Subject: [PATCH] auth: clang-tidy fixes --- pdns/lua-record.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index 106e90df3012..d4a78a23ee76 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -674,7 +674,8 @@ struct EntryHashesHolder { size_t count = 0; while (count < weight) { auto value = boost::str(boost::format("%s-%d") % entry % count); - auto whash = burtle(reinterpret_cast(value.c_str()), value.size(), 0); + // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) + auto whash = burtle(reinterpret_cast(value.data()), value.size(), 0); locked->push_back(whash); ++count; } @@ -725,7 +726,7 @@ static std::string pickConsistentWeightedHashed(const ComboAddress& bestwho, con } { const auto hashes = entry->hashes.read_lock(); - if (hashes->size() > 0) { + if (!hashes->empty()) { if (min > *(hashes->begin())) { min = *(hashes->begin()); first = entry->entry; @@ -747,7 +748,7 @@ static std::string pickConsistentWeightedHashed(const ComboAddress& bestwho, con if (first != boost::none) { return *first; } - return std::string(); + return {}; } static vector genericIfUp(const boost::variant& ips, boost::optional options, const std::function& upcheckf, uint16_t port = 0) @@ -1124,8 +1125,8 @@ static void setupLuaRecords(LuaContext& lua) // NOLINT(readability-function-cogn vector< pair > items; items.reserve(ips.size()); - for (auto& i : ips) { - items.emplace_back(atoi(i.second[1].c_str()), i.second[2]); + for (auto& entry : ips) { + items.emplace_back(atoi(entry.second[1].c_str()), entry.second[2]); } return pickWeightedHashed(s_lua_record_ctx->bestwho, items); @@ -1156,8 +1157,8 @@ static void setupLuaRecords(LuaContext& lua) // NOLINT(readability-function-cogn vector< pair > items; items.reserve(ips.size()); - for (auto& i : ips) { - items.emplace_back(atoi(i.second[1].c_str()), i.second[2]); + for (auto& entry : ips) { + items.emplace_back(atoi(entry.second[1].c_str()), entry.second[2]); } return pickConsistentWeightedHashed(s_lua_record_ctx->bestwho, items);