diff options
| author | [email protected] <[email protected]> | 2012-12-29 08:11:38 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-12-29 08:11:38 +0000 |
| commit | d573786d522a4c5316210bcef22a417ba40f92c8 (patch) | |
| tree | d81a377d91f8bfe207cbf702f70bc13dbd940b6f /components | |
| parent | 50d95287cc6e54ac9307a9c24728215607c8fc2f (diff) | |
fix memory access error in list_tc() under bsp/simulator
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2550 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components')
| -rw-r--r-- | components/finsh/cmd.c | 19 | ||||
| -rw-r--r-- | components/finsh/finsh.h | 7 | ||||
| -rw-r--r-- | components/finsh/finsh_vm.c | 9 |
3 files changed, 12 insertions, 23 deletions
diff --git a/components/finsh/cmd.c b/components/finsh/cmd.c index 632577404e..4ebbfc62d6 100644 --- a/components/finsh/cmd.c +++ b/components/finsh/cmd.c @@ -32,21 +32,6 @@ #include <rtthread.h> #include "finsh.h" -#if defined(_MSC_VER) -static struct finsh_syscall* _next_syscall(struct finsh_syscall* call) -{ - unsigned int *ptr; - ptr = (unsigned int*) (call + 1); - while ((*ptr == 0) && ((unsigned int*)ptr < (unsigned int*) _syscall_table_end)) - ptr ++; - - return (struct finsh_syscall*)ptr; -} -#define _NEXT_SYSCALl(index) index=_next_syscall(index) -#else -#define _NEXT_SYSCALl(index) index++ -#endif - rt_inline unsigned int rt_list_len(const rt_list_t *l) { @@ -564,7 +549,7 @@ long list(void) rt_kprintf("--Function List:\n"); { struct finsh_syscall *index; - for (index = _syscall_table_begin; index < _syscall_table_end; _NEXT_SYSCALl(index)) + for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index)) { #ifdef FINSH_USING_DESCRIPTION rt_kprintf("%-16s -- %s\n", index->name, index->desc); @@ -649,7 +634,7 @@ void list_prefix(char *prefix) /* checks in system function call */ { struct finsh_syscall* index; - for (index = _syscall_table_begin; index < _syscall_table_end; _NEXT_SYSCALl(index)) + for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index)) { if (str_is_prefix(prefix, index->name) == 0) { diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index 0ada00ea03..994509bd64 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -148,6 +148,13 @@ struct finsh_sysvar void* var ; /* the address of variable */ }; +#if defined(_MSC_VER) +struct finsh_syscall* finsh_syscall_next(struct finsh_syscall* call); +#define FINSH_NEXT_SYSCALL(index) index=finsh_syscall_next(index) +#else +#define FINSH_NEXT_SYSCALL(index) index++ +#endif + /* system variable item */ struct finsh_sysvar_item { diff --git a/components/finsh/finsh_vm.c b/components/finsh/finsh_vm.c index c5b6dcf632..845eb48919 100644 --- a/components/finsh/finsh_vm.c +++ b/components/finsh/finsh_vm.c @@ -83,8 +83,8 @@ void finsh_syscall_append(const char* name, syscall_func func) } #endif -#if defined(_MSC_VER) -static struct finsh_syscall* _next_syscall(struct finsh_syscall* call) +#ifdef _MSC_VER +struct finsh_syscall* finsh_syscall_next(struct finsh_syscall* call) { unsigned int *ptr; ptr = (unsigned int*) (call + 1); @@ -93,9 +93,6 @@ static struct finsh_syscall* _next_syscall(struct finsh_syscall* call) return (struct finsh_syscall*)ptr; } -#define _NEXT_SYSCALL(index) index=_next_syscall(index) -#else -#define _NEXT_SYSCALL(index) index++ #endif struct finsh_syscall* finsh_syscall_lookup(const char* name) @@ -103,7 +100,7 @@ struct finsh_syscall* finsh_syscall_lookup(const char* name) struct finsh_syscall* index; struct finsh_syscall_item* item; - for (index = _syscall_table_begin; index < _syscall_table_end; _NEXT_SYSCALL(index)) + for (index = _syscall_table_begin; index < _syscall_table_end; FINSH_NEXT_SYSCALL(index)) { if (strcmp(index->name, name) == 0) return index; |
