svace fix 99/219199/5
authorsanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 3 Dec 2019 06:26:54 +0000 (15:26 +0900)
committersanghyeok.oh <sanghyeok.oh@samsung.com>
Tue, 3 Dec 2019 12:32:09 +0000 (21:32 +0900)
Change-Id: Ifc22558c277143c9620b38c9b2eb1552d37b652b
Signed-off-by: sanghyeok.oh <sanghyeok.oh@samsung.com>
src/memory/vmpressure-lowmem-handler.c

index 9a7cfec..c7678f0 100644 (file)
@@ -428,10 +428,17 @@ static char *strrstr(const char *str, const char *token)
 
 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);
 }
@@ -1850,13 +1857,11 @@ static int create_memcgs(void)
        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)
@@ -1902,7 +1907,8 @@ static bool lowmem_press_eventfd_handler(int fd, void *data)
        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)