Skip to content

Commit

Permalink
semihosting: Adjust error checking in common_semi_cb
Browse files Browse the repository at this point in the history
The err parameter is non-zero if and only if an error occured.
Use this instead of ret == -1 for determining if we need to
update the saved errno.

This fixes the errno setting of SYS_ISTTY, which returns 0 on
error, not -1.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Jun 27, 2022
1 parent 5aadd18 commit 709fe27
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion semihosting/arm-compat-semi.c
Expand Up @@ -290,7 +290,7 @@ static target_ulong common_semi_syscall_len;

static void common_semi_cb(CPUState *cs, target_ulong ret, target_ulong err)
{
if (ret == (target_ulong)-1) {
if (err) {
#ifdef CONFIG_USER_ONLY
TaskState *ts = cs->opaque;
ts->swi_errno = err;
Expand Down

0 comments on commit 709fe27

Please sign in to comment.