Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions components/finsh/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
42 changes: 21 additions & 21 deletions components/finsh/msh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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';
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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);
}
}

Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions components/finsh/msh_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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];
}

Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
18 changes: 9 additions & 9 deletions components/finsh/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down