Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2389)

Unified Diff: sandbox/linux/services/proc_util.cc

Issue 2959043002: Replace calls to deprecated readdir_r() in ProcUtil with readdir()
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/services/proc_util.cc
diff --git a/sandbox/linux/services/proc_util.cc b/sandbox/linux/services/proc_util.cc
index b6d58de56489f7f0a92984ee079c623c7cdfabc6..06b9002e2eb647b42b64e918bfae6e5de7c8aa77 100644
--- a/sandbox/linux/services/proc_util.cc
+++ b/sandbox/linux/services/proc_util.cc
@@ -51,15 +51,14 @@ int ProcUtil::CountOpenFds(int proc_fd) {
CHECK(dir);
int count = 0;
- struct dirent e;
struct dirent* de;
- while (!readdir_r(dir.get(), &e, &de) && de) {
- if (strcmp(e.d_name, ".") == 0 || strcmp(e.d_name, "..") == 0) {
+ while ((de = readdir(dir.get()))) {
+ if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) {
continue;
}
int fd_num;
- CHECK(base::StringToInt(e.d_name, &fd_num));
+ CHECK(base::StringToInt(de->d_name, &fd_num));
if (fd_num == proc_fd || fd_num == proc_self_fd) {
continue;
}
@@ -81,22 +80,21 @@ bool ProcUtil::HasOpenDirectory(int proc_fd) {
ScopedDIR dir(fdopendir(proc_self_fd));
CHECK(dir);
- struct dirent e;
struct dirent* de;
- while (!readdir_r(dir.get(), &e, &de) && de) {
- if (strcmp(e.d_name, ".") == 0 || strcmp(e.d_name, "..") == 0) {
+ while ((de = readdir(dir.get()))) {
+ if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0) {
continue;
}
int fd_num;
- CHECK(base::StringToInt(e.d_name, &fd_num));
+ CHECK(base::StringToInt(de->d_name, &fd_num));
if (fd_num == proc_fd || fd_num == proc_self_fd) {
continue;
}
struct stat s;
// It's OK to use proc_self_fd here, fstatat won't modify it.
- CHECK(fstatat(proc_self_fd, e.d_name, &s, 0) == 0);
+ CHECK(fstatat(proc_self_fd, de->d_name, &s, 0) == 0);
if (S_ISDIR(s.st_mode)) {
return true;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698