소스 검색

Merge pull request #1824 from yangfasheng/master

update armlibc/stdio.c
Bernard Xiong 7 년 전
부모
커밋
ef4f904096
1개의 변경된 파일18개의 추가작업 그리고 2개의 파일을 삭제
  1. 18 2
      components/libc/compilers/armlibc/stdio.c

+ 18 - 2
components/libc/compilers/armlibc/stdio.c

@@ -65,11 +65,27 @@ int libc_stdio_get_console(void)
 
 int libc_stdio_read(void *buffer, size_t size)
 {
-    return read(std_fd, buffer, size);
+    if (std_fd >= 0)
+    {
+        return read(std_fd, buffer, size);
+    }
+    else
+    {
+        rt_kprintf("Illegal stdio input!\n");
+        return 0;
+    }
 }
 
 int libc_stdio_write(const void *buffer, size_t size)
 {
-    return write(std_fd, buffer, size);
+    if (std_fd >= 0)
+    {
+        return write(std_fd, buffer, size);
+    }
+    else
+    {
+        rt_kprintf("Illegal stdio output!\n");
+        return size;
+    }
 }
 #endif