From: Kichan Kwon Date: Wed, 18 Jan 2017 01:00:54 +0000 (+0900) Subject: Fix for gnu11 compiler X-Git-Tag: accepted/tizen/common/20170118.173908 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Ftags%2Faccepted%2Ftizen%2Fcommon%2F20170118.173908;p=platform%2Fcore%2Fsystem%2Fresourced.git Fix for gnu11 compiler - Set to static function using static variable - Replace deprecated readdir_r to readdir Change-Id: I13473f8e984376d56a71b97dc06c04a95311e930 Signed-off-by: Kichan Kwon --- diff --git a/src/common/procfs.c b/src/common/procfs.c index 88870d6..f3a1209 100644 --- a/src/common/procfs.c +++ b/src/common/procfs.c @@ -92,8 +92,7 @@ pid_t find_pid_from_cmdline(char *cmdline) pid_t pid = -1, foundpid = -1; int ret = 0; DIR *dp; - struct dirent dentry; - struct dirent *result; + struct dirent *dentry; char appname[PROC_NAME_MAX]; dp = opendir("/proc"); @@ -101,11 +100,11 @@ pid_t find_pid_from_cmdline(char *cmdline) _E("BACKGRD MANAGE : fail to open /proc"); return RESOURCED_ERROR_FAIL; } - while (!readdir_r(dp, &dentry, &result) && result != NULL) { - if (!isdigit(dentry.d_name[0])) + while ((dentry = readdir(dp))) { + if (!isdigit(dentry->d_name[0])) continue; - pid = atoi(dentry.d_name); + pid = atoi(dentry->d_name); if (!pid) continue; ret = proc_get_cmdline(pid, appname); diff --git a/src/common/util.h b/src/common/util.h index 6c06978..af6a0ac 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -136,17 +136,6 @@ static inline bool strstart_with(const char *str, const char *with) #define FOREACH_WORD(word, length, s, state) \ FOREACH_WORD_SEPARATOR(word, length, s, WHITESPACE, state) -#define FOREACH_DIRENT(de, d, result, on_error) \ - for (errno = readdir_r(d, &de, &result);; errno = readdir_r(d, &de, &result)) \ - if (errno || !result) { \ - if (errno) \ - on_error; \ - break; \ - } else if (streq(de.d_name, ".") || \ - streq(de.d_name, "..")) \ - continue; \ - else - #define FOREACH_STRV(s, l) \ for ((s) = (l); (s) && *(s); (s)++) diff --git a/src/heart/heart-battery.c b/src/heart/heart-battery.c index 6848eca..c3bd76c 100644 --- a/src/heart/heart-battery.c +++ b/src/heart/heart-battery.c @@ -432,12 +432,12 @@ inline long heart_battery_get_prediction_time(int strategy, enum charger_status_ return batt_stat.prediction[status].time_pred_min[strategy]; } -inline time_t heart_battery_get_file_commit_timestamp() +static inline time_t heart_battery_get_file_commit_timestamp() { return last_file_commit_time; } -inline void heart_battery_set_file_commit_timestamp(time_t timestamp) +static inline void heart_battery_set_file_commit_timestamp(time_t timestamp) { last_file_commit_time = timestamp; } diff --git a/src/memory/vmpressure-lowmem-handler.c b/src/memory/vmpressure-lowmem-handler.c index 8e05379..61986b4 100644 --- a/src/memory/vmpressure-lowmem-handler.c +++ b/src/memory/vmpressure-lowmem-handler.c @@ -707,9 +707,7 @@ static unsigned int is_memory_recovered(unsigned int *avail, unsigned int *thres static int lowmem_get_pids_proc(GArray *pids) { DIR *dp; - struct dirent dentry; - struct dirent *result; - int ret; + struct dirent *dentry; char appname[PROC_NAME_MAX] = {0}; dp = opendir("/proc"); @@ -717,16 +715,16 @@ static int lowmem_get_pids_proc(GArray *pids) _E("fail to open /proc"); return RESOURCED_ERROR_FAIL; } - while (!(ret = readdir_r(dp, &dentry, &result)) && result != NULL) { + while ((dentry = readdir(dp))) { struct task_info tsk; pid_t pid = 0, pgid = 0; int oom = 0; unsigned int size = 0; - if (!isdigit(dentry.d_name[0])) + if (!isdigit(dentry->d_name[0])) continue; - pid = (pid_t)atoi(dentry.d_name); + pid = (pid_t)atoi(dentry->d_name); if (pid < 0) continue; @@ -756,8 +754,6 @@ static int lowmem_get_pids_proc(GArray *pids) } closedir(dp); - if (ret) - _E("fail to open subdirectory in /proc"); if (pids->len) return pids->len; @@ -1923,8 +1919,7 @@ static int set_vip_list(void) { pid_t pid = -1; DIR *dp; - struct dirent dentry; - struct dirent *result; + struct dirent *dentry; char proc_name[PROC_NAME_MAX]; int vip_index; char *vip_name; @@ -1935,11 +1930,11 @@ static int set_vip_list(void) return RESOURCED_ERROR_FAIL; } - while (!readdir_r(dp, &dentry, &result) && result != NULL) { - if (!isdigit(dentry.d_name[0])) + while ((dentry = readdir(dp))) { + if (!isdigit(dentry->d_name[0])) continue; - pid = atoi(dentry.d_name); + pid = atoi(dentry->d_name); if (!pid) continue; diff --git a/src/proc-stat/proc-main.c b/src/proc-stat/proc-main.c index 5341dcc..2fe03ef 100644 --- a/src/proc-stat/proc-main.c +++ b/src/proc-stat/proc-main.c @@ -1234,14 +1234,13 @@ static int proc_restore_runtime_app_info(const char *path) static void proc_restore_runtime_app_list(void) { _cleanup_closedir_ DIR *dp = NULL; - struct dirent dentry; struct dirent *dir; dp = opendir(RUNTIME_APP_INFO_DIR); if (!dp) return; - while (!readdir_r(dp, &dentry, &dir) && dir != NULL) { + while ((dir = readdir(dp))) { _cleanup_free_ char *path = NULL; int ret;