Fix for gnu11 compiler 51/110751/4 accepted/tizen/common/20170118.173908 accepted/tizen/ivi/20170118.041629 accepted/tizen/mobile/20170118.041527 accepted/tizen/tv/20170118.041541 accepted/tizen/wearable/20170118.041549 submit/tizen/20170118.022504
authorKichan Kwon <k_c.kwon@samsung.com>
Wed, 18 Jan 2017 01:00:54 +0000 (10:00 +0900)
committerKichan Kwon <k_c.kwon@samsung.com>
Wed, 18 Jan 2017 02:16:33 +0000 (11:16 +0900)
- Set to static function using static variable
- Replace deprecated readdir_r to readdir

Change-Id: I13473f8e984376d56a71b97dc06c04a95311e930
Signed-off-by: Kichan Kwon <k_c.kwon@samsung.com>
src/common/procfs.c
src/common/util.h
src/heart/heart-battery.c
src/memory/vmpressure-lowmem-handler.c
src/proc-stat/proc-main.c

index 88870d6..f3a1209 100644 (file)
@@ -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);
index 6c06978..af6a0ac 100644 (file)
@@ -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)++)
 
index 6848eca..c3bd76c 100644 (file)
@@ -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;
 }
index 8e05379..61986b4 100644 (file)
@@ -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;
 
index 5341dcc..2fe03ef 100644 (file)
@@ -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;