From 66e03d5f1993d5bdf9c0c0b778afdf99eefff847 Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Tue, 20 Dec 2016 19:49:27 +0900 Subject: [PATCH] Replace deprecated readdir_r with readdir Change-Id: Ic5649cafedfcb3a91c839c33f261c6da7475a9a9 Signed-off-by: Kyungwook Tak --- srcs/key_handler.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/srcs/key_handler.c b/srcs/key_handler.c index cdc96af..c5a2f95 100644 --- a/srcs/key_handler.c +++ b/srcs/key_handler.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -207,15 +208,15 @@ static int traverse_directory(const char *path, entry_callback ecb, void *user_d } int ret = WAE_ERROR_NONE; - struct dirent entry; - struct dirent *result = NULL; while (true) { - if (readdir_r(dir, &entry, &result) != 0) { - WAE_SLOGE("readdir_r error on dir(%s) errno(%d)", path, errno); + errno = 0; + struct dirent *result = readdir(dir); + if (result == NULL) { + if (errno != 0) + WAE_SLOGE("readdir error on dir(%s) errno(%d)", path, errno); break; - } else if (result == NULL) { - break; // end of directory - } else if (strcmp(entry.d_name, ".") == 0 || strcmp(entry.d_name, "..") == 0) { + } else if (strcmp(result->d_name, ".") == 0 || + strcmp(result->d_name, "..") == 0) { continue; } -- 2.7.4