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>
This commit is contained in:
Manish V Badarkhe 2022-09-26 15:06:56 +01:00
parent 58aebb6a53
commit 7c49438874
2 changed files with 7 additions and 2 deletions

View file

@ -649,6 +649,9 @@ subsections:
- title: Context Management
scope: context mgmt
- title: Semihosting
scope: semihosting
- title: Drivers
subsections:

View file

@ -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;