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

Unified Diff: net/disk_cache/simple/simple_index_file_posix.cc

Issue 2411833004: Replace some deprecated usages of readdir_r with readdir (Closed)
Patch Set: Created 4 years, 2 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
Index: net/disk_cache/simple/simple_index_file_posix.cc
diff --git a/net/disk_cache/simple/simple_index_file_posix.cc b/net/disk_cache/simple/simple_index_file_posix.cc
index e0dd3dd126a98801b5711eb892d8ca79bd9b3bfc..c49a89dce4ea9603446f846af7e82d104860e143 100644
--- a/net/disk_cache/simple/simple_index_file_posix.cc
+++ b/net/disk_cache/simple/simple_index_file_posix.cc
@@ -34,18 +34,18 @@ bool SimpleIndexFile::TraverseCacheDirectory(
PLOG(ERROR) << "opendir " << cache_path.value();
return false;
}
- dirent entry, *result;
- while (readdir_r(dir.get(), &entry, &result) == 0) {
- if (!result)
- return true; // The traversal completed successfully.
- const std::string file_name(result->d_name);
+ errno = 0;
+ for (dirent* entry = readdir(dir.get()); entry; entry = readdir(dir.get())) {
+ const std::string file_name(entry->d_name);
if (file_name == "." || file_name == "..")
continue;
const base::FilePath file_path = cache_path.Append(
base::FilePath(file_name));
entry_file_callback.Run(file_path);
}
- PLOG(ERROR) << "readdir_r " << cache_path.value();
+ if (!errno)
+ return true; // The traversal completed successfully.
+ PLOG(ERROR) << "readdir " << cache_path.value();
return false;
}

Powered by Google App Engine
This is Rietveld 408576698