summaryrefslogtreecommitdiff
path: root/components/libc/compilers/armlibc/syscalls.c
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-12-01 02:19:15 -0500
committerMeco Man <[email protected]>2021-12-01 02:19:15 -0500
commit7b1f65a690c8f28d172e640989643df12597fa7a (patch)
tree96465d7a6431653b5e11d4c4a2dae3c264841ffe /components/libc/compilers/armlibc/syscalls.c
parent43ebe094e34449221e9716e3168f08764b6f7fd6 (diff)
[libc][keil] fix the bug of _sys_read and _sys_write
Diffstat (limited to 'components/libc/compilers/armlibc/syscalls.c')
-rw-r--r--components/libc/compilers/armlibc/syscalls.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/components/libc/compilers/armlibc/syscalls.c b/components/libc/compilers/armlibc/syscalls.c
index bfd3777193..0e965d62af 100644
--- a/components/libc/compilers/armlibc/syscalls.c
+++ b/components/libc/compilers/armlibc/syscalls.c
@@ -156,22 +156,26 @@ int _sys_read(FILEHANDLE fh, unsigned char *buf, unsigned len, int mode)
return 0; /* error, but keep going */
}
size = read(STDIN_FILENO, buf, len);
- return 0; /* success */
+ return len - size; /* success */
#else
return 0; /* error */
#endif /* RT_USING_POSIX_DEVIO */
}
else if (fh == STDOUT || fh == STDERR)
{
- return 0; /* error */
+ return -1; /* 100% error */
}
else
{
size = read(fh, buf, len);
if (size >= 0)
+ {
return len - size; /* success */
+ }
else
+ {
return 0; /* error */
+ }
}
#else
return 0; /* error */
@@ -209,16 +213,20 @@ int _sys_write(FILEHANDLE fh, const unsigned char *buf, unsigned len, int mode)
}
else if (fh == STDIN)
{
- return 0; /* error */
+ return -1; /* 100% error */
}
else
{
#ifdef DFS_USING_POSIX
size = write(fh, buf, len);
if (size >= 0)
- return 0; /* success */
+ {
+ return len - size; /* success */
+ }
else
+ {
return 0; /* error */
+ }
#else
return 0; /* error */
#endif /* DFS_USING_POSIX */