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");
_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);
#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)++)
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;
}
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");
_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;
}
closedir(dp);
- if (ret)
- _E("fail to open subdirectory in /proc");
if (pids->len)
return pids->len;
{
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;
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;
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;