Browse Source

[libc][syscalls]将在libc初始化之前调用printf的行为下调为警告级别

Meco Man 3 years ago
parent
commit
0a799653df

+ 4 - 4
components/libc/compilers/armlibc/syscalls.c

@@ -152,8 +152,8 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
 #ifdef RT_USING_POSIX
         if (libc_stdio_get_console() < 0)
         {
-            LOG_E("invoke standard output before initializing libc");
-            return -1;
+            LOG_W("Do not invoke standard output before initializing libc");
+            return 0;
         }
         size = read(STDIN_FILENO, buf, len);
         return len - size;
@@ -197,8 +197,8 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
 #ifdef RT_USING_POSIX
         if (libc_stdio_get_console() < 0)
         {
-            LOG_E("invoke standard input before initializing libc");
-            return -1;
+            LOG_W("Do not invoke standard input before initializing libc");
+            return 0;
         }
         size = write(STDOUT_FILENO, buf, len);
         return len - size;

+ 2 - 2
components/libc/compilers/dlib/syscall_read.c

@@ -31,8 +31,8 @@ size_t __read(int handle, unsigned char *buf, size_t len)
 #ifdef RT_USING_POSIX
         if (libc_stdio_get_console() < 0)
         {
-            LOG_E("invoke standard input before initializing libc");
-            return _LLIO_ERROR;
+            LOG_W("Do not invoke standard input before initializing libc");
+            return 0;
         }
         return read(STDIN_FILENO, buf, len);
 #else

+ 2 - 2
components/libc/compilers/dlib/syscall_write.c

@@ -36,8 +36,8 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
 #ifdef RT_USING_POSIX
         if (libc_stdio_get_console() < 0)
         {
-            LOG_E("invoke standard output before initializing libc");
-            return _LLIO_ERROR;
+            LOG_W("Do not invoke standard output before initializing libc");
+            return 0;
         }
         return write(STDOUT_FILENO, (void*)buf, len);
 #else

+ 4 - 4
components/libc/compilers/newlib/syscalls.c

@@ -227,8 +227,8 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
     _ssize_t rc;
     if (libc_stdio_get_console() < 0 && fd == STDIN_FILENO)
     {
-        LOG_E("invoke standard input before initializing libc");
-        return -1;
+        LOG_W("Do not invoke standard input before initializing libc");
+        return 0;
     }
     rc = read(fd, buf, nbytes);
     return rc;
@@ -303,8 +303,8 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
     _ssize_t rc;
     if (libc_stdio_get_console() < 0 && fd == STDOUT_FILENO)
     {
-        LOG_E("invoke standard output before initializing libc");
-        return -1;
+        LOG_W("Do not invoke standard output before initializing libc");
+        return 0;
     }
     rc = write(fd, buf, nbytes);
     return rc;