From: Kefu Chai Date: Mon, 7 Nov 2016 05:36:56 +0000 (+0800) Subject: common/fd.cc: use readdir() as readdir_r() is deprecated X-Git-Tag: v11.1.0~314^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8f2acc341ccce44d41675cae1cc7343ea04a2cc1;p=ceph.git common/fd.cc: use readdir() as readdir_r() is deprecated 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 --- diff --git a/src/common/fd.cc b/src/common/fd.cc index 1154e05d580..45d6a129b05 100644 --- a/src/common/fd.cc +++ b/src/common/fd.cc @@ -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;