summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorguo <[email protected]>2021-10-14 10:05:03 +0800
committerGitHub <[email protected]>2021-10-14 10:05:03 +0800
commit33263d7e4ec22b118d0407ec7488ccfa60a8a0a1 (patch)
treeb7db670d2cdad0477bb9bcddb33c961776a1d412 /components
parent4351507752f43d7bbec0f62be7619cd52447a0d1 (diff)
parentc99dfc3147ef08ef62e729dc2860e06ad90380d3 (diff)
Merge pull request #5166 from liukangcc/finsh
[update] fix finsh_getchar() 未对 shell->device 为空处理的问题
Diffstat (limited to 'components')
-rw-r--r--components/finsh/shell.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/components/finsh/shell.c b/components/finsh/shell.c
index 48651d2c4f..7b577db6b6 100644
--- a/components/finsh/shell.c
+++ b/components/finsh/shell.c
@@ -151,15 +151,19 @@ char finsh_getchar(void)
char ch = 0;
RT_ASSERT(shell != RT_NULL);
+ if (shell->device == RT_NULL)
+ {
+ return -RT_ERROR;
+ }
while (rt_device_read(shell->device, -1, &ch, 1) != 1)
rt_sem_take(&shell->rx_sem, RT_WAITING_FOREVER);
return ch;
-#endif
+#endif /* RT_USING_POSIX */
#else
extern char rt_hw_console_getchar(void);
return rt_hw_console_getchar();
-#endif
+#endif /* RT_USING_DEVICE */
}
#if !defined(RT_USING_POSIX) && defined(RT_USING_DEVICE)