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

Unified Diff: base/files/file_enumerator_posix.cc

Issue 2411833004: Replace some deprecated usages of readdir_r with readdir (Closed)
Patch Set: Address review comments by Jorge Lucangeli Obes. Created 4 years, 1 month 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 | net/disk_cache/simple/simple_index_file_posix.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/files/file_enumerator_posix.cc
diff --git a/base/files/file_enumerator_posix.cc b/base/files/file_enumerator_posix.cc
index fb4010aadcad566f304a899344f1cb892b666081..16a04801c3ae450f5ad6c88a02571f12f5cdabde 100644
--- a/base/files/file_enumerator_posix.cc
+++ b/base/files/file_enumerator_posix.cc
@@ -131,9 +131,11 @@ bool FileEnumerator::ReadDirectory(std::vector<FileInfo>* entries,
additional space for pathname may be needed
#endif
- struct dirent dent_buf;
- struct dirent* dent;
- while (readdir_r(dir, &dent_buf, &dent) == 0 && dent) {
+ // In all implementations of the C library that Chromium can run with,
+ // concurrent calls to readdir that specify different directory streams are
+ // thread-safe. This is the case here, since the directory stream is scoped to
+ // the current function. See https://codereview.chromium.org/2411833004/#msg3
+ for (struct dirent* dent = readdir(dir); dent; dent = readdir(dir)) {
FileInfo info;
info.filename_ = FilePath(dent->d_name);
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698