From 2af2faeb437cdfc558964bc422d3920fdb40f98f Mon Sep 17 00:00:00 2001 From: Yucai Liu Date: Fri, 30 May 2025 09:30:22 +0800 Subject: [PATCH] [Fix] :finsh/shell.c When using char rt_hw_console_getchar(void), some compilers may default to returning 255 instead of the expected -1, causing the condition if(ch < 0) at F: shell.c L:519 to fail and enter an erroneous loop. Solution: Use the signed char type return value as rt_hw_console_getchar Signed-off-by: Yucai Liu <1486344514@qq.com> --- components/finsh/shell.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/finsh/shell.c b/components/finsh/shell.c index 2b9349364c5..bd641db9b66 100644 --- a/components/finsh/shell.c +++ b/components/finsh/shell.c @@ -193,7 +193,7 @@ int finsh_getchar(void) return ch; #endif /* RT_USING_POSIX_STDIO */ #else - extern char rt_hw_console_getchar(void); + extern signed char rt_hw_console_getchar(void); return rt_hw_console_getchar(); #endif /* RT_USING_DEVICE */ }