summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-03-11 09:44:49 +0800
committerGitHub <[email protected]>2019-03-11 09:44:49 +0800
commit359d57006116be4956ef253239ad5bc6c1c199ab (patch)
tree013c954455f9f740003a2b9377fc78685e054939 /components
parenta4f16ed41f16d8847ccc18dd26c315023dfb340e (diff)
parent860f8d954d7f99971fe8c12fd3195870c52940fb (diff)
Merge pull request #2414 from gbcwbz/finsh
[finsh] change return type of finsh_getchar from ch to int
Diffstat (limited to 'components')
-rw-r--r--components/finsh/shell.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/components/finsh/shell.c b/components/finsh/shell.c
index f96e1f8928..61c8d3dd15 100644
--- a/components/finsh/shell.c
+++ b/components/finsh/shell.c
@@ -134,12 +134,12 @@ void finsh_set_prompt_mode(rt_uint32_t prompt_mode)
shell->prompt_mode = prompt_mode;
}
-static char finsh_getchar(void)
+static int finsh_getchar(void)
{
#ifdef RT_USING_POSIX
return getchar();
#else
- char ch;
+ int ch;
RT_ASSERT(shell != RT_NULL);
while (rt_device_read(shell->device, -1, &ch, 1) != 1)
@@ -279,7 +279,7 @@ const char *finsh_get_password(void)
static void finsh_wait_auth(void)
{
- char ch;
+ int ch;
rt_bool_t input_finish = RT_FALSE;
char password[FINSH_PASSWORD_MAX] = { 0 };
rt_size_t cur_pos = 0;
@@ -295,6 +295,11 @@ static void finsh_wait_auth(void)
{
/* read one character from device */
ch = finsh_getchar();
+ if (ch < 0)
+ {
+ rt_kprintf("finsh getchar error\n");
+ continue;
+ }
if (ch >= ' ' && ch <= '~' && cur_pos < FINSH_PASSWORD_MAX)
{
@@ -460,7 +465,7 @@ static void shell_push_history(struct finsh_shell *shell)
void finsh_thread_entry(void *parameter)
{
- char ch;
+ int ch;
/* normal is echo mode */
#ifndef FINSH_ECHO_DISABLE_DEFAULT
@@ -503,6 +508,11 @@ void finsh_thread_entry(void *parameter)
while (1)
{
ch = finsh_getchar();
+ if (ch < 0)
+ {
+ rt_kprintf("finsh getchar error\n");
+ continue;
+ }
/*
* handle control key