core: Remove unused helper functions 62/180962/1
authorChanwoo Choi <cw00.choi@samsung.com>
Fri, 1 Jun 2018 01:25:46 +0000 (10:25 +0900)
committerChanwoo Choi <cw00.choi@samsung.com>
Thu, 7 Jun 2018 01:38:21 +0000 (10:38 +0900)
Change-Id: I70c130c7715dab70f11294547889022a44ff93ce
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
include/pass/common.h
src/core/common.c

index 9de28a36f4f674923f2c5942bf45db8dfba84746..b11571d81411a08ba8494f40a796f2a136a0bfc8 100644 (file)
@@ -77,16 +77,6 @@ typedef unsigned long long uint64;
        })
 #endif
 
-#ifndef clamp
-#define clamp(x, low, high)                                            \
-       __extension__ ({                                                \
-               typeof(x) _x = (x);                                     \
-               typeof(low) _low = (low);                               \
-               typeof(high) _high = (high);                            \
-               ((_x > _high) ? _high : ((_x < _low) ? _low : _x));     \
-       })
-#endif
-
 #ifndef SEC_TO_MSEC
 #define SEC_TO_MSEC(x)         ((x)*1000)
 #endif
@@ -100,54 +90,7 @@ typedef unsigned long long uint64;
 #define USEC_TO_MSEC(x)                ((double)x/1000)
 #endif
 
-#define NANO_SECOND_MULTIPLIER  1000000 /* 1ms = 1,000,000 nsec */
-
-#ifndef safe_free
-#define safe_free(x) safe_free_memory((void**)&(x))
-#endif
-
-static inline void safe_free_memory(void** mem)
-{
-       if (mem && *mem) {
-               free(*mem);
-               *mem = NULL;
-       }
-}
-
-#define ret_value_if(expr, val) do { \
-       if (expr) { \
-               _E("(%s)", #expr); \
-               return (val); \
-       } \
-} while (0)
-
-#define ret_value_msg_if(expr, val, fmt, arg...) do {  \
-       if (expr) {                             \
-               _E(fmt, ##arg);                 \
-               return val;                     \
-       }                                       \
-} while (0)
-
-#define ret_msg_if(expr, fmt, arg...) do {     \
-       if (expr) {                             \
-               _E(fmt, ##arg);                 \
-               return;                 \
-       }                                       \
-} while (0)
-
-FILE * open_proc_oom_score_adj_file(int pid, const char *mode);
-int get_exec_pid(const char *execpath);
-int get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size);
-int is_vip(int pid);
-int remove_dir(const char *path, int del_dir);
-int sys_check_node(char *path);
 int sys_get_int(char *fname, int *val);
-int sys_set_int(char *fname, int val);
 int sys_get_str(char *fname, char *str);
-int sys_set_str(char *fname, char *val);
-int terminate_process(const char *partition, bool force);
-int mount_check(const char* path);
-void print_time(const char *prefix);
-int get_privilege(pid_t pid, char *name, size_t len);
 
 #endif /* __CORE_COMMON_H__ */
index a0ee779a3b65675698e7b089c00bd97857457af4..6e2150a37172cdf260e4505ef842119c501a0115 100644 (file)
 
 #define BUFF_MAX       255
 
-int get_cmdline_name(pid_t pid, char *cmdline, size_t cmdline_size)
-{
-       int fd, ret;
-       char buf[PATH_MAX + 1];
-       char *filename;
-
-       if (!cmdline_size)
-               return -1;
-
-       snprintf(buf, sizeof(buf), "/proc/%d/cmdline", pid);
-       fd = open(buf, O_RDONLY);
-       if (fd < 0) {
-               errno = ESRCH;
-               return -1;
-       }
-
-       ret = read(fd, buf, PATH_MAX);
-       close(fd);
-       if ((ret >= 0) && (ret <= PATH_MAX)) {
-               buf[ret] = '\0';
-       } else {
-               errno = EIO;
-               return -1;
-       }
-
-       filename = strrchr(buf, '/');
-       if (filename == NULL)
-               filename = buf;
-       else
-               filename = filename + 1;
-
-       if ((cmdline_size - 1) < strlen(filename)) {
-               errno = EOVERFLOW;
-               return -1;
-       }
-
-       strncpy(cmdline, filename, cmdline_size - 1);
-       cmdline[cmdline_size - 1] = '\0';
-       return 0;
-}
-
-/*
- * Helper function
- * - Read from sysfs entry
- * - Write to sysfs entry
- */
-int sys_check_node(char *path)
-{
-       int fd;
-
-       fd = open(path, O_RDONLY);
-       if (fd == -1)
-               return -1;
-
-       close(fd);
-       return 0;
-}
-
 static int sys_read_buf(char *file, char *buf)
 {
        int fd;
@@ -118,25 +60,6 @@ static int sys_read_buf(char *file, char *buf)
        return ret;
 }
 
-static int sys_write_buf(char *file, char *buf)
-{
-       int fd;
-       int r;
-       int ret = 0;
-
-       fd = open(file, O_WRONLY);
-       if (fd == -1)
-               return -ENOENT;
-
-       r = write(fd, buf, strlen(buf));
-       if (r < 0)
-               ret = -EIO;
-
-       close(fd);
-
-       return ret;
-}
-
 int sys_get_int(char *fname, int *val)
 {
        char buf[BUFF_MAX];
@@ -152,19 +75,6 @@ int sys_get_int(char *fname, int *val)
        return ret;
 }
 
-int sys_set_int(char *fname, int val)
-{
-       char buf[BUFF_MAX];
-       int ret = 0;
-
-       snprintf(buf, sizeof(buf), "%d", val);
-
-       if (sys_write_buf(fname, buf) != 0)
-               ret = -EIO;
-
-       return ret;
-}
-
 int sys_get_str(char *fname, char *str)
 {
        char buf[BUFF_MAX] = {0};
@@ -176,15 +86,3 @@ int sys_get_str(char *fname, char *str)
 
        return -1;
 }
-
-int sys_set_str(char *fname, char *val)
-{
-       int r = -1;
-
-       if (val != NULL) {
-               if (sys_write_buf(fname, val) == 0)
-                       r = 0;
-       }
-
-       return r;
-}