diff options
author | Manish V Badarkhe <Manish.Badarkhe@arm.com> | 2022-09-26 15:06:56 +0100 |
---|---|---|
committer | Manish V Badarkhe <Manish.Badarkhe@arm.com> | 2022-09-28 11:53:42 +0100 |
commit | 7c4943887477754024f0f736461d9543d502efcc (patch) | |
tree | b20fac1b5bf169a1d5b97fe8cab47bf4890cc35a /lib/semihosting | |
parent | 58aebb6a53170cca6211e400e6630d2747bac9de (diff) | |
download | arm-trusted-firmware-7c4943887477754024f0f736461d9543d502efcc.tar.gz |
fix(semihosting): fix seek call failure check
The code checks that the semihosting seek call return value is not
zero instead of a negative value when there is an error condition.
This defect has been fixed.
In [1], possible return values for semihosting seek calls are
mentioned.
[1]: https://github.com/ARM-software/abi-aa/blob/main/semihosting/
semihosting.rst#sys-seek-0x0a
Change-Id: I70f09e98323e9c5bf4eeda322ac065e855e256fc
Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
Diffstat (limited to 'lib/semihosting')
-rw-r--r-- | lib/semihosting/semihosting.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/semihosting/semihosting.c b/lib/semihosting/semihosting.c index e0845c1a5..163a82d84 100644 --- a/lib/semihosting/semihosting.c +++ b/lib/semihosting/semihosting.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -64,8 +64,10 @@ long semihosting_file_seek(long file_handle, ssize_t offset) result = semihosting_call(SEMIHOSTING_SYS_SEEK, (uintptr_t)&seek_block); - if (result != 0) { + if (result < 0) { result = semihosting_call(SEMIHOSTING_SYS_ERRNO, 0); + } else { + result = 0; } return result; |