diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2022-05-16 19:34:06 -0700 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2022-06-28 04:35:07 +0530 |
commit | 84ca0dfd1e8c0a23fe8aeb22f4141e0b14da2812 (patch) | |
tree | 96915bc5107b1e01cd1c9bc5798338e3802f196f /semihosting | |
parent | 709fe27b189aa86c801b9bd655f9267fec17d0d0 (diff) |
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.c | 20 |
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; |