From 06c6630bbfbf7a0b82ebf22d63bc2fc9aca3bdb9 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 4 Apr 2013 14:12:35 -0400 Subject: [PATCH] fix compiling warning in finsh shell --- components/finsh/finsh.h | 3 --- components/finsh/finsh_token.c | 9 ++++++++- components/finsh/shell.c | 31 ------------------------------- components/libc/newlib/libc.c | 9 ++++++--- 4 files changed, 14 insertions(+), 38 deletions(-) diff --git a/components/finsh/finsh.h b/components/finsh/finsh.h index 85e32b9fb8..adb2f09625 100644 --- a/components/finsh/finsh.h +++ b/components/finsh/finsh.h @@ -86,9 +86,6 @@ typedef unsigned int size_t; int strcmp (const char *s1, const char *s2); char *strdup(const char *s); - -int isalpha( int ch ); -int atoi(const char* s); #else /* use libc of armcc */ #include diff --git a/components/finsh/finsh_token.c b/components/finsh/finsh_token.c index d4b1b70d79..2486988a47 100644 --- a/components/finsh/finsh_token.c +++ b/components/finsh/finsh_token.c @@ -28,10 +28,12 @@ * 2013-04-03 Bernard strip more characters. */ #include +#include #include "finsh_token.h" #include "finsh_error.h" +#define is_alpha(ch) ((ch | 0x20) - 'a') < 26u #define is_digit(ch) ((ch) >= '0' && (ch) <= '9') #define is_separator(ch) !(((ch) >= 'a' && (ch) <= 'z') \ || ((ch) >= 'A' && (ch) <= 'Z') || ((ch) >= '0' && (ch) <= '9') || ((ch) == '_')) @@ -329,10 +331,15 @@ static int token_match_name(struct finsh_token* self, const char* str) static void token_trim_space(struct finsh_token* self) { char ch; +#if 0 while ( (ch = token_next_char(self)) ==' ' || ch == '\t' || ch == '\r' || ch == '\n'); +#else + while ( (ch = token_next_char(self)) ==' ' || + ch == '\t'); +#endif token_prev_char(self); } @@ -489,7 +496,7 @@ static void token_proc_number(struct finsh_token* self) { b = 16; ch = token_next_char(self); - while ( is_digit(ch) || isalpha(ch) ) + while ( is_digit(ch) || is_alpha(ch) ) { *p++ = ch; ch = token_next_char(self); diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 53932aa5a0..de6132c1ab 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -76,37 +76,6 @@ char *strdup(const char *s) } #endif -#if !defined(__CC_ARM) && !defined(__IAR_SYSTEMS_ICC__) && !defined(__ADSPBLACKFIN__) && !defined(_MSC_VER) -int isalpha( int ch ) -{ - return (unsigned int)((ch | 0x20) - 'a') < 26u; -} - -int atoi(const char* s) -{ - long int v=0; - int sign=1; - while ( *s == ' ' || (unsigned int)(*s - 9) < 5u) s++; - - switch (*s) - { - case '-': sign=-1; - case '+': ++s; - } - - while ((unsigned int) (*s - '0') < 10u) - { - v=v*10+*s-'0'; ++s; - } - - return sign==-1?-v:v; -} - -int isprint(unsigned char ch) -{ - return (unsigned int)(ch - ' ') < 127u - ' '; -} -#endif #endif #if defined(RT_USING_DFS) && defined(DFS_USING_WORKDIR) diff --git a/components/libc/newlib/libc.c b/components/libc/newlib/libc.c index 797c393db8..f7bb8e3f9b 100644 --- a/components/libc/newlib/libc.c +++ b/components/libc/newlib/libc.c @@ -5,12 +5,15 @@ #include #include "libc.h" +#ifdef RT_USING_PTHREADS +#include +#endif + void libc_system_init(const char* tty_name) { - int fd; - extern int pthread_system_init(void); - #ifdef RT_USING_DFS + int fd; + #ifndef RT_USING_DFS_DEVFS #error Please enable devfs by defining RT_USING_DFS_DEVFS in rtconfig.h #endif