From 2855afa7f8aa9315fbffc3629cb1fa4624843672 Mon Sep 17 00:00:00 2001 From: Inkyun Kil Date: Thu, 15 Dec 2016 09:24:06 +0900 Subject: [PATCH] Replace 'readdir_r' with 'readdir' 'readdir_r' is deprecated since version 2.24 glibc. By upgrading TOOLCHAIN for platform, it should be replaced by 'readdir' Change-Id: I54ad1b8291f5148e2e294cb8219ce11b32f1db6c Signed-off-by: Inkyun Kil --- src/debugger_info.c | 11 +++++------ src/launcher_info.c | 11 +++++------ src/launchpad_common.c | 18 ++++++++---------- src/launchpad_signal.c | 2 +- src/loader_info.c | 11 +++++------ 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/src/debugger_info.c b/src/debugger_info.c index 4af4a2d..1ba596b 100644 --- a/src/debugger_info.c +++ b/src/debugger_info.c @@ -190,8 +190,7 @@ static GList *__parse_file(GList *list, const char *path) GList *_debugger_info_load(const char *path) { DIR *dp; - struct dirent dentry; - struct dirent *result = NULL; + struct dirent *dentry = NULL; GList *list = NULL; char buf[PATH_MAX]; char *ext; @@ -203,14 +202,14 @@ GList *_debugger_info_load(const char *path) if (dp == NULL) return NULL; - while (readdir_r(dp, &dentry, &result) == 0 && result != NULL) { - if (dentry.d_name[0] == '.') + while ((dentry = readdir(dp)) != NULL) { + if (dentry->d_name[0] == '.') continue; - ext = strrchr(dentry.d_name, '.'); + ext = strrchr(dentry->d_name, '.'); if (ext && strcmp(ext, ".debugger") == 0) { snprintf(buf, sizeof(buf), "%s/%s", - path, dentry.d_name); + path, dentry->d_name); list = __parse_file(list, buf); } } diff --git a/src/launcher_info.c b/src/launcher_info.c index 06b46ab..bff7a12 100644 --- a/src/launcher_info.c +++ b/src/launcher_info.c @@ -169,8 +169,7 @@ static GList *__parse_file(GList *list, const char *path) GList *_launcher_info_load(const char *path) { DIR *dp; - struct dirent dentry; - struct dirent *result = NULL; + struct dirent *dentry = NULL; GList *list = NULL; char buf[PATH_MAX]; char *ext; @@ -182,14 +181,14 @@ GList *_launcher_info_load(const char *path) if (dp == NULL) return NULL; - while (readdir_r(dp, &dentry, &result) == 0 && result != NULL) { - if (dentry.d_name[0] == '.') + while ((dentry = readdir(dp)) != NULL) { + if (dentry->d_name[0] == '.') continue; - ext = strrchr(dentry.d_name, '.'); + ext = strrchr(dentry->d_name, '.'); if (ext && strcmp(ext, ".launcher") == 0) { snprintf(buf, sizeof(buf), "%s/%s", - path, dentry.d_name); + path, dentry->d_name); list = __parse_file(list, buf); } } diff --git a/src/launchpad_common.c b/src/launchpad_common.c index aa4b909..dbfbee4 100644 --- a/src/launchpad_common.c +++ b/src/launchpad_common.c @@ -659,8 +659,7 @@ int _proc_get_attr_by_pid(int pid, char *buf, int size) static int __delete_dir(const char *path) { DIR *dp; - struct dirent dentry; - struct dirent *result = NULL; + struct dirent *dentry = NULL; char buf[PATH_MAX]; struct stat statbuf; int ret; @@ -672,11 +671,11 @@ static int __delete_dir(const char *path) if (dp == NULL) return -1; - while (readdir_r(dp, &dentry, &result) == 0 && result) { - if (!strcmp(dentry.d_name, ".") || !strcmp(dentry.d_name, "..")) + while ((dentry = readdir(dp)) != NULL) { + if (!strcmp(dentry->d_name, ".") || !strcmp(dentry->d_name, "..")) continue; - snprintf(buf, sizeof(buf), "%s/%s", path, dentry.d_name); + snprintf(buf, sizeof(buf), "%s/%s", path, dentry->d_name); ret = stat(buf, &statbuf); if (ret == 0) { if (S_ISDIR(statbuf.st_mode)) @@ -709,8 +708,7 @@ int _delete_sock_path(int pid, uid_t uid) int _close_all_fds(void) { DIR *dp; - struct dirent dentry; - struct dirent *result = NULL; + struct dirent *dentry = NULL; int fd; int max_fd; @@ -724,11 +722,11 @@ int _close_all_fds(void) return 0; } - while (readdir_r(dp, &dentry, &result) == 0 && result) { - if (!isdigit(dentry.d_name[0])) + while ((dentry = readdir(dp)) != NULL) { + if (!isdigit(dentry->d_name[0])) continue; - fd = atoi(dentry.d_name); + fd = atoi(dentry->d_name); if (fd < 3) continue; diff --git a/src/launchpad_signal.c b/src/launchpad_signal.c index e802ca4..1742dcf 100644 --- a/src/launchpad_signal.c +++ b/src/launchpad_signal.c @@ -127,7 +127,7 @@ static gboolean __flush_pending_signal(gpointer data) static void __socket_garbage_collector(void) { DIR *dp; - struct dirent *dentry; + struct dirent *dentry = NULL; char tmp[MAX_LOCAL_BUFSZ]; snprintf(tmp, sizeof(tmp), "/run/aul/apps/%d", getuid()); diff --git a/src/loader_info.c b/src/loader_info.c index c0ded9f..c4ac48c 100644 --- a/src/loader_info.c +++ b/src/loader_info.c @@ -225,8 +225,7 @@ static GList *__parse_file(GList *list, const char *path) GList *_loader_info_load(const char *path) { DIR *dir_info; - struct dirent entry; - struct dirent *result = NULL; + struct dirent *entry = NULL; GList *list = NULL; char buf[PATH_MAX]; char *ext; @@ -235,12 +234,12 @@ GList *_loader_info_load(const char *path) if (dir_info == NULL) return NULL; - while (readdir_r(dir_info, &entry, &result) == 0 && result != NULL) { - if (entry.d_name[0] == '.') + while ((entry = readdir(dir_info)) != NULL) { + if (entry->d_name[0] == '.') continue; - ext = strrchr(entry.d_name, '.'); + ext = strrchr(entry->d_name, '.'); if (ext && !strcmp(ext, ".loader")) { - snprintf(buf, sizeof(buf), "%s/%s", path, entry.d_name); + snprintf(buf, sizeof(buf), "%s/%s", path, entry->d_name); list = __parse_file(list, buf); } } -- 2.7.4