Skip to content

Commit 0a79965

Browse files
committed
[libc][syscalls]将在libc初始化之前调用printf的行为下调为警告级别
1 parent 37d4abb commit 0a79965

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

components/libc/compilers/armlibc/syscalls.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
152152
#ifdef RT_USING_POSIX
153153
if (libc_stdio_get_console() < 0)
154154
{
155-
LOG_E("invoke standard output before initializing libc");
156-
return -1;
155+
LOG_W("Do not invoke standard output before initializing libc");
156+
return 0;
157157
}
158158
size = read(STDIN_FILENO, buf, len);
159159
return len - size;
@@ -197,8 +197,8 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
197197
#ifdef RT_USING_POSIX
198198
if (libc_stdio_get_console() < 0)
199199
{
200-
LOG_E("invoke standard input before initializing libc");
201-
return -1;
200+
LOG_W("Do not invoke standard input before initializing libc");
201+
return 0;
202202
}
203203
size = write(STDOUT_FILENO, buf, len);
204204
return len - size;

components/libc/compilers/dlib/syscall_read.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ size_t __read(int handle, unsigned char *buf, size_t len)
3131
#ifdef RT_USING_POSIX
3232
if (libc_stdio_get_console() < 0)
3333
{
34-
LOG_E("invoke standard input before initializing libc");
35-
return _LLIO_ERROR;
34+
LOG_W("Do not invoke standard input before initializing libc");
35+
return 0;
3636
}
3737
return read(STDIN_FILENO, buf, len);
3838
#else

components/libc/compilers/dlib/syscall_write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ size_t __write(int handle, const unsigned char *buf, size_t len)
3636
#ifdef RT_USING_POSIX
3737
if (libc_stdio_get_console() < 0)
3838
{
39-
LOG_E("invoke standard output before initializing libc");
40-
return _LLIO_ERROR;
39+
LOG_W("Do not invoke standard output before initializing libc");
40+
return 0;
4141
}
4242
return write(STDOUT_FILENO, (void*)buf, len);
4343
#else

components/libc/compilers/newlib/syscalls.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ _ssize_t _read_r(struct _reent *ptr, int fd, void *buf, size_t nbytes)
227227
_ssize_t rc;
228228
if (libc_stdio_get_console() < 0 && fd == STDIN_FILENO)
229229
{
230-
LOG_E("invoke standard input before initializing libc");
231-
return -1;
230+
LOG_W("Do not invoke standard input before initializing libc");
231+
return 0;
232232
}
233233
rc = read(fd, buf, nbytes);
234234
return rc;
@@ -303,8 +303,8 @@ _ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
303303
_ssize_t rc;
304304
if (libc_stdio_get_console() < 0 && fd == STDOUT_FILENO)
305305
{
306-
LOG_E("invoke standard output before initializing libc");
307-
return -1;
306+
LOG_W("Do not invoke standard output before initializing libc");
307+
return 0;
308308
}
309309
rc = write(fd, buf, nbytes);
310310
return rc;

0 commit comments

Comments
 (0)