From: Chanwoo Choi Date: Fri, 1 Jun 2018 01:25:46 +0000 (+0900) Subject: core: Remove unused helper functions X-Git-Tag: submit/tizen/20180724.000537~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7623f121b200e02949e1a73dacc87e2f20f61d14;p=platform%2Fcore%2Fsystem%2Fpass.git core: Remove unused helper functions Change-Id: I70c130c7715dab70f11294547889022a44ff93ce Signed-off-by: Chanwoo Choi --- diff --git a/include/pass/common.h b/include/pass/common.h index 9de28a3..b11571d 100644 --- a/include/pass/common.h +++ b/include/pass/common.h @@ -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__ */ diff --git a/src/core/common.c b/src/core/common.c index a0ee779..6e2150a 100644 --- a/src/core/common.c +++ b/src/core/common.c @@ -39,64 +39,6 @@ #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; -}