]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/fd.cc: use readdir() as readdir_r() is deprecated
authorKefu Chai <kchai@redhat.com>
Mon, 7 Nov 2016 05:36:56 +0000 (13:36 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 7 Nov 2016 06:19:44 +0000 (14:19 +0800)
see https://lwn.net/Articles/696469/, readdir_r() is deprecated by
glibc since 2.24. so let's use readdir() instead.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/fd.cc

index 1154e05d580f7c995ca7657816f14d52b78aa995..45d6a129b0542ee715de44b34cdb577d417f3434 100644 (file)
@@ -30,16 +30,14 @@ void dump_open_fds(CephContext *cct)
     lderr(cct) << "dump_open_fds unable to open " << fn << dendl;
     return;
   }
-  struct dirent de, *pde = 0;
+  struct dirent *de = nullptr;
 
   int n = 0;
-  while (readdir_r(d, &de, &pde) >= 0) {
-    if (pde == NULL)
-      break;
-    if (de.d_name[0] == '.')
+  while ((de = ::readdir(d))) {
+    if (de->d_name[0] == '.')
       continue;
     char path[PATH_MAX];
-    snprintf(path, sizeof(path), "%s/%s", fn, de.d_name);
+    snprintf(path, sizeof(path), "%s/%s", fn, de->d_name);
     char target[PATH_MAX];
     ssize_t r = readlink(path, target, sizeof(target) - 1);
     if (r < 0) {
@@ -48,7 +46,7 @@ void dump_open_fds(CephContext *cct)
       continue;
     }
     target[r] = 0;
-    lderr(cct) << "dump_open_fds " << de.d_name << " -> " << target << dendl;
+    lderr(cct) << "dump_open_fds " << de->d_name << " -> " << target << dendl;
     n++;
   }
   lderr(cct) << "dump_open_fds dumped " << n << " open files" << dendl;