Use readdir instead of readdir_r.
http://elliotth.blogspot.com/2012/10/how-not-to-use-readdirr3.html
Test: boots.
Change-Id: If75532e24fe4d17743bf8e8c9590156dee378a63
diff --git a/libutils/ProcessCallStack.cpp b/libutils/ProcessCallStack.cpp
index 4e87a98..73ed4eb 100644
--- a/libutils/ProcessCallStack.cpp
+++ b/libutils/ProcessCallStack.cpp
@@ -131,9 +131,6 @@
}
void ProcessCallStack::update() {
- struct dirent *ep;
- struct dirent entry;
-
std::unique_ptr<DIR, decltype(&closedir)> dp(opendir(PATH_SELF_TASK), closedir);
if (dp == NULL) {
ALOGE("%s: Failed to update the process's call stacks: %s",
@@ -158,8 +155,8 @@
* Each tid is a directory inside of /proc/self/task
* - Read every file in directory => get every tid
*/
- int code;
- while ((code = readdir_r(dp.get(), &entry, &ep)) == 0 && ep != NULL) {
+ dirent* ep;
+ while ((ep = readdir(dp.get())) != NULL) {
pid_t tid = -1;
sscanf(ep->d_name, "%d", &tid);
@@ -194,10 +191,6 @@
ALOGV("%s: Got call stack for tid %d (size %zu)",
__FUNCTION__, tid, threadInfo.callStack.size());
}
- if (code != 0) { // returns positive error value on error
- ALOGE("%s: Failed to readdir from %s: %s",
- __FUNCTION__, PATH_SELF_TASK, strerror(code));
- }
}
void ProcessCallStack::log(const char* logtag, android_LogPriority priority,