From: Remi Gacogne Date: Tue, 29 Aug 2023 14:03:40 +0000 (+0200) Subject: Fix warnings from clang-tidy X-Git-Tag: rec-5.0.0-rc1~46^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d77ce8e047f808d77c7a79264a9991378f12b788;p=thirdparty%2Fpdns.git Fix warnings from clang-tidy --- diff --git a/pdns/dnsbackend.cc b/pdns/dnsbackend.cc index 71b05ff785..cfead8c159 100644 --- a/pdns/dnsbackend.cc +++ b/pdns/dnsbackend.cc @@ -119,11 +119,14 @@ void BackendMakerClass::load_all() return; } struct dirent* entry = nullptr; - while ((entry=readdir(dir.get()))) { - if (strncmp(entry->d_name, "lib", 3) == 0 && - strlen(entry->d_name) > 13 && - strcmp(entry->d_name + strlen(entry->d_name)-10, "backend.so") == 0) + //NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated + while ((entry = readdir(dir.get())) != nullptr) { + auto name = std::string_view(entry->d_name, strlen(entry->d_name)); + if (boost::starts_with(name, "lib") && + name.size() > 13 && + boost::ends_with(name, "backend.so")) { load(entry->d_name); + } } } diff --git a/pdns/ixfrutils.cc b/pdns/ixfrutils.cc index 2c1031d8c7..4c8e37fa6b 100644 --- a/pdns/ixfrutils.cc +++ b/pdns/ixfrutils.cc @@ -82,9 +82,11 @@ uint32_t getSerialFromDir(const std::string& dir) } struct dirent* entry = nullptr; - while ((entry = readdir(dirhdl.get()))) { + //NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated + while ((entry = readdir(dirhdl.get())) != nullptr) { uint32_t num = atoi(entry->d_name); - if (std::to_string(num) == entry->d_name) { + auto name = std::string_view(entry->d_name, strlen(entry->d_name)); + if (std::to_string(num) == name) { ret = max(num, ret); } }