File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -134,12 +134,12 @@ void finsh_set_prompt_mode(rt_uint32_t prompt_mode)
134134 shell -> prompt_mode = prompt_mode ;
135135}
136136
137- static char finsh_getchar (void )
137+ static int finsh_getchar (void )
138138{
139139#ifdef RT_USING_POSIX
140140 return getchar ();
141141#else
142- char ch ;
142+ int ch ;
143143
144144 RT_ASSERT (shell != RT_NULL );
145145 while (rt_device_read (shell -> device , -1 , & ch , 1 ) != 1 )
@@ -279,7 +279,7 @@ const char *finsh_get_password(void)
279279
280280static void finsh_wait_auth (void )
281281{
282- char ch ;
282+ int ch ;
283283 rt_bool_t input_finish = RT_FALSE ;
284284 char password [FINSH_PASSWORD_MAX ] = { 0 };
285285 rt_size_t cur_pos = 0 ;
@@ -295,6 +295,11 @@ static void finsh_wait_auth(void)
295295 {
296296 /* read one character from device */
297297 ch = finsh_getchar ();
298+ if (ch < 0 )
299+ {
300+ rt_kprintf ("finsh getchar error\n" );
301+ continue ;
302+ }
298303
299304 if (ch >= ' ' && ch <= '~' && cur_pos < FINSH_PASSWORD_MAX )
300305 {
@@ -460,7 +465,7 @@ static void shell_push_history(struct finsh_shell *shell)
460465
461466void finsh_thread_entry (void * parameter )
462467{
463- char ch ;
468+ int ch ;
464469
465470 /* normal is echo mode */
466471#ifndef FINSH_ECHO_DISABLE_DEFAULT
@@ -503,6 +508,11 @@ void finsh_thread_entry(void *parameter)
503508 while (1 )
504509 {
505510 ch = finsh_getchar ();
511+ if (ch < 0 )
512+ {
513+ rt_kprintf ("finsh getchar error\n" );
514+ continue ;
515+ }
506516
507517 /*
508518 * handle control key
You can’t perform that action at this time.
0 commit comments