瀏覽代碼

[components/shell] shell will not work if ch is none zero as random value in stack

The serial getchar will only modify the LSB of ch, the MSB 3 bytes
will be unchanged as the random value on stack, so if MSB 3 bytes
not zero, the value got is wrong.
misonyo 6 年之前
父節點
當前提交
14e048aa8e
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      components/finsh/shell.c

+ 1 - 1
components/finsh/shell.c

@@ -139,7 +139,7 @@ static int finsh_getchar(void)
 #ifdef RT_USING_POSIX
 #ifdef RT_USING_POSIX
     return getchar();
     return getchar();
 #else
 #else
-    int ch;
+    int ch = 0;
 
 
     RT_ASSERT(shell != RT_NULL);
     RT_ASSERT(shell != RT_NULL);
     while (rt_device_read(shell->device, -1, &ch, 1) != 1)
     while (rt_device_read(shell->device, -1, &ch, 1) != 1)