From: Hyeongsik Min Date: Tue, 27 Dec 2016 07:25:19 +0000 (+0900) Subject: Replace readdir_r with readdir X-Git-Tag: accepted/tizen/4.0/unified/20170816.014018^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Fltrace.git;a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_mobile Replace readdir_r with readdir Change-Id: I1a6c75d8a2f64e58a4c81724e2c3b0568b581a7b Signed-off-by: Hyeongsik Min --- diff --git a/sysdeps/linux-gnu/proc.c b/sysdeps/linux-gnu/proc.c index 953fd86..d17510d 100644 --- a/sysdeps/linux-gnu/proc.c +++ b/sysdeps/linux-gnu/proc.c @@ -242,14 +242,8 @@ process_tasks(pid_t pid, pid_t **ret_tasks, size_t *ret_n) size_t alloc = 0; while (1) { - struct dirent entry; struct dirent *result; - if (readdir_r(d, &entry, &result) != 0) { - fail: - free(tasks); - closedir(d); - return -1; - } + result = readdir(d); if (result == NULL) break; if (result->d_type == DT_DIR && all_digits(result->d_name)) { @@ -258,8 +252,11 @@ process_tasks(pid_t pid, pid_t **ret_tasks, size_t *ret_n) alloc = alloc > 0 ? (2 * alloc) : 8; pid_t *ntasks = realloc(tasks, sizeof(*tasks) * alloc); - if (ntasks == NULL) - goto fail; + if (ntasks == NULL) { + free(tasks); + closedir(d); + return -1; + } tasks = ntasks; } assert(n < alloc);