[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 08/11] target/arm: correct return values for WRI
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [RFC PATCH 08/11] target/arm: correct return values for WRITE/READ in arm-semi |
Date: |
Tue, 14 May 2019 16:52:58 +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>
---
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-devel] [RFC PATCH 05/11] target/arm: fixup some of the commentary for arm-semi, (continued)
- [Qemu-devel] [RFC PATCH 05/11] target/arm: fixup some of the commentary for arm-semi, Alex Bennée, 2019/05/14
- [Qemu-devel] [RFC PATCH 10/11] target/mips: convert UHI_plog to use common semihosting code, Alex Bennée, 2019/05/14
- [Qemu-devel] [RFC PATCH 04/11] semihosting: enable chardev backed output for console, Alex Bennée, 2019/05/14
- [Qemu-devel] [RFC PATCH 06/11] target/arm: use the common interface for WRITE0/WRITEC in arm-semi, Alex Bennée, 2019/05/14
- [Qemu-devel] [RFC PATCH 01/11] semihosting: move semihosting configuration into its own directory, Alex Bennée, 2019/05/14
- [Qemu-devel] [RFC PATCH 07/11] target/arm: add LOG_UNIMP messages to arm-semi, Alex Bennée, 2019/05/14
- [Qemu-devel] [RFC PATCH 08/11] target/arm: correct return values for WRITE/READ in arm-semi,
Alex Bennée <=
- [Qemu-devel] [RFC PATCH 09/11] target/mips: only build mips-semi for softmmu, Alex Bennée, 2019/05/14
- [Qemu-devel] [RFC PATCH 11/11] MAINTAINERS: update for semihostings new home, Alex Bennée, 2019/05/14
- Re: [Qemu-devel] [RFC PATCH 00/11] semihosting cleanup and re-factor, Alex Bennée, 2019/05/20