From 4482d3953ba30d642c3c48ebed04bb2b94c10aa5 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Thu, 3 Nov 2022 15:25:37 +0800 Subject: [PATCH] update: remove redundant functions --- include/common/sundry.h | 4 +--- include/common/system.h | 1 - src/common/sundry.c | 8 -------- src/common/system.c | 10 ---------- 4 files changed, 1 insertion(+), 22 deletions(-) diff --git a/include/common/sundry.h b/include/common/sundry.h index f12a2a5..97f53ca 100644 --- a/include/common/sundry.h +++ b/include/common/sundry.h @@ -4,13 +4,11 @@ #include char* show_bool(uint8_t value); +uint8_t check_port(uint16_t port); char* string_load(const char *fmt, ...); char* uint32_to_string(uint32_t number); char* string_join(const char *base, const char *add); void string_list_debug(char *describe, char **string_list); void uint32_list_debug(char *describe, uint32_t **uint32_list); -uint8_t check_port(uint16_t port); -uint16_t gen_rand_num(uint16_t limit); - #endif diff --git a/include/common/system.h b/include/common/system.h index 82cd4bf..b8860d9 100644 --- a/include/common/system.h +++ b/include/common/system.h @@ -4,7 +4,6 @@ #include char* read_file(const char *file); -void remove_file(const char *file); int run_command(const char *command); void create_folder(const char *folder); uint8_t is_file_exist(const char *file); diff --git a/src/common/sundry.c b/src/common/sundry.c index 7191199..6efb5d5 100644 --- a/src/common/sundry.c +++ b/src/common/sundry.c @@ -56,11 +56,3 @@ uint8_t check_port(uint16_t port) { // whether port is valid } return FALSE; } - -uint16_t gen_rand_num(uint16_t limit) { // 0 ~ (limit - 1) - struct timeval tv; - gettimeofday(&tv, NULL); - srand(tv.tv_usec); - usleep(1); // sleep 1us (different time seed) - return rand() % limit; // NOLINT -} diff --git a/src/common/system.c b/src/common/system.c index 476d579..0dc3c78 100644 --- a/src/common/system.c +++ b/src/common/system.c @@ -17,16 +17,6 @@ int run_command(const char *command) { // running command under system shell return ret_code; } -void remove_file(const char *file) { // delete file - if (!is_file_exist(file)) { // file not found - log_debug("Delete file `%s` skip -> file not exist", file); - } else if (remove(file)) { // remove failed - log_perror("Delete file `%s` failed -> ", file); - } else { // remove success - log_debug("Delete file `%s` success", file); - } -} - void create_folder(const char *folder) { // create folder if (!access(folder, 0)) { // target is file or folder struct stat buf;