[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v2 08/28] target/arm: correct return values for WRITE/
From: |
Alex Bennée |
Subject: |
[Qemu-arm] [PATCH v2 08/28] target/arm: correct return values for WRITE/READ in arm-semi |
Date: |
Thu, 23 May 2019 11:25:12 +0100 |
The documentation says the write should return the number of bytes not
written on an error (0 means everything was written). Read provides a
buffer length and the return value should be the buffer length - bytes
actually read. Remove the incorrect FIXME's and return the correct
values.
Signed-off-by: Alex Bennée <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
---
target/arm/arm-semi.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/target/arm/arm-semi.c b/target/arm/arm-semi.c
index a3bbef18ef7..3ae8f05d51b 100644
--- a/target/arm/arm-semi.c
+++ b/target/arm/arm-semi.c
@@ -334,13 +334,15 @@ target_ulong do_arm_semihosting(CPUARMState *env)
} else {
s = lock_user(VERIFY_READ, arg1, len, 1);
if (!s) {
- /* FIXME - should this error code be -TARGET_EFAULT ? */
- return (uint32_t)-1;
+ /* Return bytes not written on error */
+ return len;
}
ret = set_swi_errno(ts, write(arg0, s, len));
unlock_user(s, arg1, 0);
- if (ret == (uint32_t)-1)
- return -1;
+ if (ret == (uint32_t)-1) {
+ ret = 0;
+ }
+ /* Return bytes not written */
return len - ret;
}
case TARGET_SYS_READ:
@@ -355,15 +357,17 @@ target_ulong do_arm_semihosting(CPUARMState *env)
} else {
s = lock_user(VERIFY_WRITE, arg1, len, 0);
if (!s) {
- /* FIXME - should this error code be -TARGET_EFAULT ? */
- return (uint32_t)-1;
+ /* return bytes not read */
+ return len;
}
do {
ret = set_swi_errno(ts, read(arg0, s, len));
} while (ret == -1 && errno == EINTR);
unlock_user(s, arg1, len);
- if (ret == (uint32_t)-1)
- return -1;
+ if (ret == (uint32_t)-1) {
+ ret = 0;
+ }
+ /* Return bytes not read */
return len - ret;
}
case TARGET_SYS_READC:
--
2.20.1
- [Qemu-arm] [PATCH v2 02/28] semihosting: introduce CONFIG_SEMIHOSTING, (continued)
- [Qemu-arm] [PATCH v2 02/28] semihosting: introduce CONFIG_SEMIHOSTING, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 07/28] target/arm: add LOG_UNIMP messages to arm-semi, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 20/28] tests/tcg/multiarch: expand system memory test to cover more, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 09/28] target/mips: only build mips-semi for softmmu, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 16/28] editorconfig: add settings for .s/.S files, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 05/28] target/arm: fixup some of the commentary for arm-semi, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 10/28] target/mips: convert UHI_plog to use common semihosting code, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 08/28] target/arm: correct return values for WRITE/READ in arm-semi,
Alex Bennée <=
- [Qemu-arm] [PATCH v2 11/28] MAINTAINERS: update for semihostings new home, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 06/28] target/arm: use the common interface for WRITE0/WRITEC in arm-semi, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 14/28] tests/tcg/multiarch: add support for multiarch system tests, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 04/28] semihosting: enable chardev backed output for console, Alex Bennée, 2019/05/23
- [Qemu-arm] [PATCH v2 03/28] semihosting: implement a semihosting console, Alex Bennée, 2019/05/23