static int timesort(const struct dirent **a, const struct dirent **b)
{
- long long time1, time2;
+ long long time1 = 0;
+ long long time2 = 0;
+ char *ptr;
- time1 = atoll(strtok(strrstr((*a)->d_name, "_"), "_"));
- time2 = atoll(strtok(strrstr((*b)->d_name, "_"), "_"));
+ ptr = strrstr((*a)->d_name, "_");
+ if (ptr && *++ptr)
+ time1 = atoll(ptr);
+
+ ptr = strrstr((*b)->d_name, "_");
+ if (ptr && *++ptr)
+ time2 = atoll(ptr);
return (time1 - time2);
}
return ret;
}
-static unsigned int lowmem_press_eventfd_read(int fd)
+static int lowmem_press_eventfd_read(int fd)
{
- unsigned int ret;
uint64_t dummy_state;
- ret = read(fd, &dummy_state, sizeof(dummy_state));
- return ret;
+ return read(fd, &dummy_state, sizeof(dummy_state));
}
static void lowmem_press_root_cgroup_handler(void)
enum lmk_type lmk_type = LMK_MEMORY;
// FIXME: probably shouldn't get ignored
- (void)lowmem_press_eventfd_read(fd);
+ if (lowmem_press_eventfd_read(fd) < 0)
+ _E("Failed to read lowmem press event, %m\n");
for (i = 0; i < MEMCG_MAX; i++) {
if (!memcg_tree[i] || !memcg_tree[i]->info)