]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Delint opendir/readdir related functions
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 10 Nov 2023 19:57:03 +0000 (20:57 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 10 Nov 2023 19:57:03 +0000 (20:57 +0100)
pdns/dnsbackend.cc
pdns/dnsdist-lua.cc
pdns/ixfrdist.cc
pdns/ixfrutils.cc
pdns/misc.cc

index cfead8c159bd4f7dc844624fc50b95a09eb51d06..7ef66280ac24ae0b0677fbc73a55014015220e01 100644 (file)
@@ -119,8 +119,9 @@ void BackendMakerClass::load_all()
     return;
   }
   struct dirent* entry = nullptr;
-  //NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
+  // NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
   while ((entry = readdir(dir.get())) != nullptr) {
+    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
     auto name = std::string_view(entry->d_name, strlen(entry->d_name));
     if (boost::starts_with(name, "lib") &&
         name.size() > 13 &&
index 78490d756024e950397cd42d3877036c129e02f5..84f85344a33cc026f328fd103be8211594b833c2 100644 (file)
@@ -1870,7 +1870,9 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
     }
 
     struct dirent* ent = nullptr;
-    while ((ent = readdir(dirp.get())) != NULL) {
+    // NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
+    while ((ent = readdir(dirp.get())) != nullptr) {
+      // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
       if (ent->d_name[0] == '.') {
         continue;
       }
index 7192cd9958b2583136422672d9636aeebe944223..d772cb217b2c30037bb103be26a24d302d39bedd 100644 (file)
@@ -208,10 +208,13 @@ static void cleanUpDomain(const DNSName& domain, const uint16_t& keep, const str
   }
   vector<uint32_t> zoneVersions;
   struct dirent* entry = nullptr;
+  // NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
   while ((entry = readdir(dirHandle.get())) != nullptr) {
+    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
     if (strcmp(entry->d_name, ".") == 0 || strcmp(entry->d_name, "..") == 0) {
       continue;
     }
+    //  NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
     zoneVersions.push_back(std::stoi(entry->d_name));
   }
   dirHandle.reset();
index 12b0a3e11b4e2bf706cefd47d66af3a224b6e96f..2fff8c580d085e1775acaa9d65c69e140791a770 100644 (file)
@@ -84,9 +84,10 @@ uint32_t getSerialFromDir(const std::string& dir)
   }
 
   struct dirent* entry = nullptr;
-  //NOLINTNEXTLINE(concurrency-mt-unsafe): readdir is thread-safe nowadays and readdir_r is deprecated
+  // 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);
+    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
     auto name = std::string_view(entry->d_name, strlen(entry->d_name));
     if (std::to_string(num) == name) {
       ret = max(num, ret);
index 3cb1275d84547769172af0080e47926223ceb729..6e98949bedda7489dc2cb8846e4a53f03e9ba3fa 100644 (file)
@@ -1384,13 +1384,16 @@ uint64_t getOpenFileDescriptors(const std::string&)
 
   int ret = 0;
   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;
     try {
+      // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
       pdns::checked_stoi_into(num, entry->d_name);
     } catch (...) {
       continue; // was not a number.
     }
+    // NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay): this is what dirent is
     if (std::to_string(num) == entry->d_name) {
       ret++;
     }