]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Fix warnings from clang-tidy
authorRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 29 Aug 2023 14:03:40 +0000 (16:03 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 10 Nov 2023 16:05:28 +0000 (17:05 +0100)
pdns/dnsbackend.cc
pdns/ixfrutils.cc

index 71b05ff785971368e184b03c48df604fd3e8299e..cfead8c159bd4f7dc844624fc50b95a09eb51d06 100644 (file)
@@ -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);
+    }
   }
 }
 
index 2c1031d8c7b8e710a88229c9c8ffb470fb113fe9..4c8e37fa6bc6bd9781bc6ebf8159b08331b677d1 100644 (file)
@@ -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);
     }
   }