X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Ftarget%2Fsemihosting_common.c;h=cae6afba2fb242c4e879411ee42e6091d76f16c5;hp=2c7f4a118c27ba20ba9272163d9baa679957287e;hb=5e96b012af91c4dc6eae680b67a594e9a22b3ead;hpb=b7125c369c4e5bde86d6688cbd1b7a87384d3d24 diff --git a/src/target/semihosting_common.c b/src/target/semihosting_common.c index 2c7f4a118c..cae6afba2f 100644 --- a/src/target/semihosting_common.c +++ b/src/target/semihosting_common.c @@ -1641,17 +1641,11 @@ static int semihosting_common_fileio_end(struct target *target, int result, */ switch (semihosting->op) { case SEMIHOSTING_SYS_WRITE: /* 0x05 */ + case SEMIHOSTING_SYS_READ: /* 0x06 */ if (result < 0) - semihosting->result = fileio_info->param_3; + semihosting->result = fileio_info->param_3; /* Zero bytes read/written. */ else - semihosting->result = 0; - break; - - case SEMIHOSTING_SYS_READ: /* 0x06 */ - if (result == (int)fileio_info->param_3) - semihosting->result = 0; - if (result <= 0) - semihosting->result = fileio_info->param_3; + semihosting->result = (int64_t)fileio_info->param_3 - result; break; case SEMIHOSTING_SYS_SEEK: /* 0x0a */