summaryrefslogtreecommitdiffstats
path: root/semihosting
diff options
context:
space:
mode:
authorRichard Henderson2022-05-17 04:34:06 +0200
committerRichard Henderson2022-06-28 01:05:07 +0200
commit84ca0dfd1e8c0a23fe8aeb22f4141e0b14da2812 (patch)
tree96915bc5107b1e01cd1c9bc5798338e3802f196f /semihosting
parentsemihosting: Adjust error checking in common_semi_cb (diff)
downloadqemu-84ca0dfd1e8c0a23fe8aeb22f4141e0b14da2812.tar.gz
qemu-84ca0dfd1e8c0a23fe8aeb22f4141e0b14da2812.tar.xz
qemu-84ca0dfd1e8c0a23fe8aeb22f4141e0b14da2812.zip
semihosting: Clean up common_semi_flen_cb
Do not read from the gdb struct stat buffer if the callback is reporting an error. Use common_semi_cb to finish returning results. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'semihosting')
-rw-r--r--semihosting/arm-compat-semi.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/semihosting/arm-compat-semi.c b/semihosting/arm-compat-semi.c
index 88d6bdeaf2..cc13fcb0ef 100644
--- a/semihosting/arm-compat-semi.c
+++ b/semihosting/arm-compat-semi.c
@@ -346,15 +346,17 @@ static target_ulong common_semi_flen_buf(CPUState *cs)
static void
common_semi_flen_cb(CPUState *cs, target_ulong ret, target_ulong err)
{
- /* The size is always stored in big-endian order, extract
- the value. We assume the size always fit in 32 bits. */
- uint32_t size;
- cpu_memory_rw_debug(cs, common_semi_flen_buf(cs) + 32,
- (uint8_t *)&size, 4, 0);
- size = be32_to_cpu(size);
- common_semi_set_ret(cs, size);
- errno = err;
- set_swi_errno(cs, -1);
+ if (!err) {
+ /*
+ * The size is always stored in big-endian order, extract
+ * the value. We assume the size always fit in 32 bits.
+ */
+ uint32_t size;
+ cpu_memory_rw_debug(cs, common_semi_flen_buf(cs) + 32,
+ (uint8_t *)&size, 4, 0);
+ ret = be32_to_cpu(size);
+ }
+ common_semi_cb(cs, ret, err);
}
static int common_semi_open_guestfd;