diff options
author | danh-arm <dan.handley@arm.com> | 2015-07-17 10:16:51 +0100 |
---|---|---|
committer | danh-arm <dan.handley@arm.com> | 2015-07-17 10:16:51 +0100 |
commit | 6058ee6a21d48eb6d126a36009c9320809abdaf5 (patch) | |
tree | 05c1c7af54d5db6a67190c8a5a43236d495d8175 /lib/semihosting/semihosting.c | |
parent | 1f06ca8a63bfb81ffb099ac0e425cc4dd7a44a66 (diff) | |
parent | 31833aff6802a4b5bdc3b7007ce8b1871991e796 (diff) |
Merge pull request #335 from jcastillo-arm/jc/sh_write
Fix bug in semihosting write function
Diffstat (limited to 'lib/semihosting/semihosting.c')
-rw-r--r-- | lib/semihosting/semihosting.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/semihosting/semihosting.c b/lib/semihosting/semihosting.c index 849ec120..b4f53d25 100644 --- a/lib/semihosting/semihosting.c +++ b/lib/semihosting/semihosting.c @@ -125,6 +125,7 @@ long semihosting_file_write(long file_handle, const uintptr_t buffer) { smh_file_read_write_block_t write_block; + long result = -EINVAL; if ((length == NULL) || (buffer == (uintptr_t)NULL)) return -EINVAL; @@ -133,10 +134,12 @@ long semihosting_file_write(long file_handle, write_block.buffer = (uintptr_t)buffer; /* cast away const */ write_block.length = *length; - *length = semihosting_call(SEMIHOSTING_SYS_WRITE, + result = semihosting_call(SEMIHOSTING_SYS_WRITE, (void *) &write_block); - return *length; + *length = result; + + return (result == 0) ? 0 : -EINVAL; } long semihosting_file_close(long file_handle) |