diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c index 2d67c85fe35..dc5eaad34e2 100644 --- a/components/finsh/cmd.c +++ b/components/finsh/cmd.c @@ -940,64 +940,64 @@ static int cmd_list(int argc, char **argv) { if(argc == 2) { - if(strcmp(argv[1], "thread") == 0) + if(rt_strcmp(argv[1], "thread") == 0) { list_thread(); } - else if(strcmp(argv[1], "timer") == 0) + else if(rt_strcmp(argv[1], "timer") == 0) { list_timer(); } #ifdef RT_USING_SEMAPHORE - else if(strcmp(argv[1], "sem") == 0) + else if(rt_strcmp(argv[1], "sem") == 0) { list_sem(); } #endif /* RT_USING_SEMAPHORE */ #ifdef RT_USING_EVENT - else if(strcmp(argv[1], "event") == 0) + else if(rt_strcmp(argv[1], "event") == 0) { list_event(); } #endif /* RT_USING_EVENT */ #ifdef RT_USING_MUTEX - else if(strcmp(argv[1], "mutex") == 0) + else if(rt_strcmp(argv[1], "mutex") == 0) { list_mutex(); } #endif /* RT_USING_MUTEX */ #ifdef RT_USING_MAILBOX - else if(strcmp(argv[1], "mailbox") == 0) + else if(rt_strcmp(argv[1], "mailbox") == 0) { list_mailbox(); } #endif /* RT_USING_MAILBOX */ #ifdef RT_USING_MESSAGEQUEUE - else if(strcmp(argv[1], "msgqueue") == 0) + else if(rt_strcmp(argv[1], "msgqueue") == 0) { list_msgqueue(); } #endif /* RT_USING_MESSAGEQUEUE */ #ifdef RT_USING_MEMHEAP - else if(strcmp(argv[1], "memheap") == 0) + else if(rt_strcmp(argv[1], "memheap") == 0) { list_memheap(); } #endif /* RT_USING_MEMHEAP */ #ifdef RT_USING_MEMPOOL - else if(strcmp(argv[1], "mempool") == 0) + else if(rt_strcmp(argv[1], "mempool") == 0) { list_mempool(); } #endif /* RT_USING_MEMPOOL */ #ifdef RT_USING_DEVICE - else if(strcmp(argv[1], "device") == 0) + else if(rt_strcmp(argv[1], "device") == 0) { list_device(); } #endif /* RT_USING_DEVICE */ #ifdef RT_USING_DFS - else if(strcmp(argv[1], "fd") == 0) + else if(rt_strcmp(argv[1], "fd") == 0) { extern int list_fd(void); list_fd(); diff --git a/components/finsh/msh.c b/components/finsh/msh.c index 505f97f4ad8..7cf93855aff 100644 --- a/components/finsh/msh.c +++ b/components/finsh/msh.c @@ -63,7 +63,7 @@ static int cmd_ps(int argc, char **argv) extern int list_module(void); #ifdef RT_USING_MODULE - if ((argc == 2) && (strcmp(argv[1], "-m") == 0)) + if ((argc == 2) && (rt_strcmp(argv[1], "-m") == 0)) list_module(); else #endif @@ -237,7 +237,7 @@ static cmd_function_t msh_get_cmd(char *cmd, int size) index < _syscall_table_end; FINSH_NEXT_SYSCALL(index)) { - if (strncmp(index->name, cmd, size) == 0 && + if (rt_strncmp(index->name, cmd, size) == 0 && index->name[size] == '\0') { cmd_func = (cmd_function_t)index->func; @@ -276,7 +276,7 @@ int msh_exec_module(const char *cmd_line, int size) rt_memcpy(pg_name, cmd_line, cmd_length); pg_name[cmd_length] = '\0'; - if (strstr(pg_name, ".mo") != RT_NULL || strstr(pg_name, ".MO") != RT_NULL) + if (rt_strstr(pg_name, ".mo") != RT_NULL || rt_strstr(pg_name, ".MO") != RT_NULL) { /* try to open program */ fd = open(pg_name, O_RDONLY, 0); @@ -374,12 +374,12 @@ static rt_bool_t _msh_lwp_cmd_exists(const char *path) static char *_msh_exec_search_path(const char *path, const char *pg_name) { char *path_buffer = RT_NULL; - ssize_t pg_len = strlen(pg_name); + ssize_t pg_len = rt_strlen(pg_name); ssize_t base_len = 0; if (path) { - base_len = strlen(path); + base_len = rt_strlen(path); } path_buffer = rt_malloc(base_len + pg_len + 6); @@ -390,7 +390,7 @@ static char *_msh_exec_search_path(const char *path, const char *pg_name) if (base_len > 0) { - memcpy(path_buffer, path, base_len); + rt_memcpy(path_buffer, path, base_len); path_buffer[base_len] = '/'; path_buffer[base_len + 1] = '\0'; } @@ -405,7 +405,7 @@ static char *_msh_exec_search_path(const char *path, const char *pg_name) return path_buffer; } - if (strstr(path_buffer, ".elf") != NULL) + if (rt_strstr(path_buffer, ".elf") != NULL) { goto not_found; } @@ -506,7 +506,7 @@ int _msh_exec_lwp(int debug, char *cmd, rt_size_t length) /* only check these paths when the first argument doesn't contain path seperator */ - if (strstr(argv[0], "/")) + if (rt_strstr(argv[0], "/")) { return -1; } @@ -704,14 +704,14 @@ void msh_auto_complete_path(char *path) if (dirent == RT_NULL) break; /* matched the prefix string */ - if (strncmp(index, dirent->d_name, rt_strlen(index)) == 0) + if (rt_strncmp(index, dirent->d_name, rt_strlen(index)) == 0) { multi ++; if (min_length == 0) { min_length = rt_strlen(dirent->d_name); /* save dirent name */ - strcpy(full_path, dirent->d_name); + rt_strcpy(full_path, dirent->d_name); } length = str_common(dirent->d_name, full_path); @@ -735,7 +735,7 @@ void msh_auto_complete_path(char *path) dirent = readdir(dir); if (dirent == RT_NULL) break; - if (strncmp(index, dirent->d_name, rt_strlen(index)) == 0) + if (rt_strncmp(index, dirent->d_name, rt_strlen(index)) == 0) rt_kprintf("%s\n", dirent->d_name); } } @@ -822,14 +822,14 @@ void msh_auto_complete(char *prefix) { /* skip finsh shell function */ cmd_name = (const char *) index->name; - if (strncmp(prefix, cmd_name, strlen(prefix)) == 0) + if (rt_strncmp(prefix, cmd_name, rt_strlen(prefix)) == 0) { if (min_length == 0) { /* set name_ptr */ name_ptr = cmd_name; /* set initial length */ - min_length = strlen(name_ptr); + min_length = rt_strlen(name_ptr); } length = str_common(name_ptr, cmd_name); @@ -865,14 +865,14 @@ static msh_cmd_opt_t *msh_get_cmd_opt(char *opt_str) } else { - len = strlen(opt_str); + len = rt_strlen(opt_str); } #if defined(FINSH_USING_SYMTAB) for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index)) { - if (strncmp(index->name, opt_str, len) == 0 && index->name[len] == '\0') + if (rt_strncmp(index->name, opt_str, len) == 0 && index->name[len] == '\0') { opt = index->opt; break; @@ -906,18 +906,18 @@ static void msh_opt_complete(char *opts_str, struct msh_cmd_opt *cmd_opt) const char *name_ptr = RT_NULL; int min_length = 0, length, opts_str_len; - opts_str_len = strlen(opts_str); + opts_str_len = rt_strlen(opts_str); for (opt = cmd_opt; opt->id; opt++) { - if (!strncmp(opt->name, opts_str, opts_str_len)) + if (!rt_strncmp(opt->name, opts_str, opts_str_len)) { if (min_length == 0) { /* set name_ptr */ name_ptr = opt->name; /* set initial length */ - min_length = strlen(name_ptr); + min_length = rt_strlen(name_ptr); } length = str_common(name_ptr, opt->name); @@ -933,7 +933,7 @@ static void msh_opt_complete(char *opts_str, struct msh_cmd_opt *cmd_opt) if (name_ptr != NULL) { - strncpy(opts_str, name_ptr, min_length); + rt_strncpy(opts_str, name_ptr, min_length); } } @@ -959,7 +959,7 @@ void msh_opt_auto_complete(char *prefix) { opt = msh_get_cmd_opt(prefix); } - else if (!msh_get_cmd(prefix, strlen(prefix)) && (' ' == prefix[strlen(prefix) - 1])) + else if (!msh_get_cmd(prefix, rt_strlen(prefix)) && (' ' == prefix[rt_strlen(prefix) - 1])) { opt = msh_get_cmd_opt(prefix); } @@ -989,7 +989,7 @@ int msh_cmd_opt_id_get(int argc, char *argv[], void *options) for (opt_id = 0; (argc >= 2) && opt && opt->id; opt++) { - if (!strcmp(opt->name, argv[1])) + if (!rt_strcmp(opt->name, argv[1])) { opt_id = opt->id; break; diff --git a/components/finsh/msh_file.c b/components/finsh/msh_file.c index 07e22a82066..feebdd6377d 100644 --- a/components/finsh/msh_file.c +++ b/components/finsh/msh_file.c @@ -90,7 +90,7 @@ int msh_exec_script(const char *cmd_line, int size) rt_memcpy(pg_name, cmd_line, cmd_length); pg_name[cmd_length] = '\0'; - if (strstr(pg_name, ".sh") != RT_NULL || strstr(pg_name, ".SH") != RT_NULL) + if (rt_strstr(pg_name, ".sh") != RT_NULL || rt_strstr(pg_name, ".SH") != RT_NULL) { /* try to open program */ fd = open(pg_name, O_RDONLY, 0); @@ -351,7 +351,7 @@ static void directory_delete_for_msh(const char *pathname, char f, char v) if (rt_strcmp(".", dirent->d_name) != 0 && rt_strcmp("..", dirent->d_name) != 0) { - if (strlen(pathname) + 1 + strlen(dirent->d_name) > DFS_PATH_MAX) + if (rt_strlen(pathname) + 1 + rt_strlen(dirent->d_name) > DFS_PATH_MAX) { rt_kprintf("cannot remove '%s/%s', path too long.\n", pathname, dirent->d_name); continue; @@ -518,7 +518,7 @@ static int cmd_mkfs(int argc, char **argv) } else if (argc == 4) { - if (strcmp(argv[1], "-t") == 0) + if (rt_strcmp(argv[1], "-t") == 0) { type = argv[2]; result = dfs_mkfs(type, argv[3]); @@ -585,7 +585,7 @@ static int cmd_mount(int argc, char **argv) /* mount a filesystem to the specified directory */ rt_kprintf("mount device %s(%s) onto %s ... ", device, fstype, path); - if (strcmp(fstype, "nfs") == 0) + if (rt_strcmp(fstype, "nfs") == 0) { data = argv[1]; device = 0; @@ -663,7 +663,7 @@ static int cmd_umount(int argc, char **argv) if (argc > 2) { - flags = strcmp(argv[1], "-f") == 0 ? MNT_FORCE : 0; + flags = rt_strcmp(argv[1], "-f") == 0 ? MNT_FORCE : 0; path = argv[2]; } @@ -693,7 +693,7 @@ static int cmd_df(int argc, char **argv) } else { - if ((strcmp(argv[1], "--help") == 0) || (strcmp(argv[1], "-h") == 0)) + if ((rt_strcmp(argv[1], "--help") == 0) || (rt_strcmp(argv[1], "-h") == 0)) { rt_kprintf("df [path]\n"); } @@ -721,7 +721,7 @@ static int cmd_echo(int argc, char **argv) fd = open(argv[2], O_RDWR | O_APPEND | O_CREAT, 0); if (fd >= 0) { - write(fd, argv[1], strlen(argv[1])); + write(fd, argv[1], rt_strlen(argv[1])); close(fd); } else @@ -875,7 +875,7 @@ static void directory_setattr(const char *pathname, struct dfs_attr *attr, char if (rt_strcmp(".", dirent->d_name) != 0 && rt_strcmp("..", dirent->d_name) != 0) { - if (strlen(pathname) + 1 + strlen(dirent->d_name) > DFS_PATH_MAX) + if (rt_strlen(pathname) + 1 + rt_strlen(dirent->d_name) > DFS_PATH_MAX) { rt_kprintf("'%s/%s' setattr failed, path too long.\n", pathname, dirent->d_name); continue; diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 05a1018194e..c85696ba8ac 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -79,10 +79,10 @@ int finsh_set_prompt(const char *prompt) /* strdup */ if (prompt) { - finsh_prompt_custom = (char *)rt_malloc(strlen(prompt) + 1); + finsh_prompt_custom = (char *)rt_malloc(rt_strlen(prompt) + 1); if (finsh_prompt_custom) { - strcpy(finsh_prompt_custom, prompt); + rt_strcpy(finsh_prompt_custom, prompt); } } @@ -105,11 +105,11 @@ const char *finsh_get_prompt(void) if (finsh_prompt_custom) { - strncpy(finsh_prompt, finsh_prompt_custom, sizeof(finsh_prompt) - 1); + rt_strncpy(finsh_prompt, finsh_prompt_custom, sizeof(finsh_prompt) - 1); } else { - strcpy(finsh_prompt, _MSH_PROMPT); + rt_strcpy(finsh_prompt, _MSH_PROMPT); } #if defined(DFS_USING_POSIX) && defined(DFS_USING_WORKDIR) @@ -423,7 +423,7 @@ static void shell_push_history(struct finsh_shell *shell) if (shell->history_count >= FINSH_HISTORY_LINES) { /* if current cmd is same as last cmd, don't push */ - if (memcmp(&shell->cmd_history[FINSH_HISTORY_LINES - 1], shell->line, FINSH_CMD_SIZE)) + if (rt_memcmp(&shell->cmd_history[FINSH_HISTORY_LINES - 1], shell->line, FINSH_CMD_SIZE)) { /* move history */ int index; @@ -442,7 +442,7 @@ static void shell_push_history(struct finsh_shell *shell) else { /* if current cmd is same as last cmd, don't push */ - if (shell->history_count == 0 || memcmp(&shell->cmd_history[shell->history_count - 1], shell->line, FINSH_CMD_SIZE)) + if (shell->history_count == 0 || rt_memcmp(&shell->cmd_history[shell->history_count - 1], shell->line, FINSH_CMD_SIZE)) { shell->current_history = shell->history_count; rt_memset(&shell->cmd_history[shell->history_count][0], 0, FINSH_CMD_SIZE); @@ -597,7 +597,7 @@ static void finsh_thread_entry(void *parameter) /* copy the history command */ rt_memcpy(shell->line, &shell->cmd_history[shell->current_history][0], FINSH_CMD_SIZE); - shell->line_curpos = shell->line_position = (rt_uint16_t)strlen(shell->line); + shell->line_curpos = shell->line_position = (rt_uint16_t)rt_strlen(shell->line); shell_handle_history(shell); #endif continue; @@ -619,7 +619,7 @@ static void finsh_thread_entry(void *parameter) rt_memcpy(shell->line, &shell->cmd_history[shell->current_history][0], FINSH_CMD_SIZE); - shell->line_curpos = shell->line_position = (rt_uint16_t)strlen(shell->line); + shell->line_curpos = shell->line_position = (rt_uint16_t)rt_strlen(shell->line); shell_handle_history(shell); #endif continue; @@ -758,7 +758,7 @@ static void finsh_thread_entry(void *parameter) /* auto complete */ shell_auto_complete(&shell->line[0]); /* re-calculate position */ - shell->line_curpos = shell->line_position = (rt_uint16_t)strlen(shell->line); + shell->line_curpos = shell->line_position = (rt_uint16_t)rt_strlen(shell->line); continue; }