diff options
author | Simon Glass <sjg@chromium.org> | 2024-08-07 16:47:24 -0600 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2024-08-09 16:03:19 -0600 |
commit | b254a8359ecdc8ec85cd93e055c6bbeee259df1d (patch) | |
tree | ef8e14b921dd1a74ac6214844a0547a71b788bc8 /fs/sandbox/sandboxfs.c | |
parent | d8289e7dfe5541dfef59520917d81cd39e10c8f3 (diff) |
sandbox: Return error code from read/write/seek
The existing API for these functions is different from the rest of
U-Boot, in that any error code must be obtained from the errno variable
on failure. This variable is part of the C library, so accessing it
outside of the special 'sandbox' shim-functions is not ideal.
Adjust the API to return an error code, to avoid this. Update existing
uses to check for any negative value, rather than just -1.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'fs/sandbox/sandboxfs.c')
-rw-r--r-- | fs/sandbox/sandboxfs.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/sandbox/sandboxfs.c b/fs/sandbox/sandboxfs.c index 773b583fa43..76f1a71f412 100644 --- a/fs/sandbox/sandboxfs.c +++ b/fs/sandbox/sandboxfs.c @@ -28,7 +28,7 @@ int sandbox_fs_read_at(const char *filename, loff_t pos, void *buffer, if (fd < 0) return fd; ret = os_lseek(fd, pos, OS_SEEK_SET); - if (ret == -1) { + if (ret < 0) { os_close(fd); return ret; } @@ -65,14 +65,14 @@ int sandbox_fs_write_at(const char *filename, loff_t pos, void *buffer, if (fd < 0) return fd; ret = os_lseek(fd, pos, OS_SEEK_SET); - if (ret == -1) { + if (ret < 0) { os_close(fd); return ret; } size = os_write(fd, buffer, towrite); os_close(fd); - if (size == -1) { + if (size < 0) { ret = -1; } else { ret = 0; |