* [U-Boot] [PATCH] fs: btrfs: fix btrfs methods return values on failure
@ 2019-05-02 13:28 Marek Behún
2019-05-03 18:21 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Marek Behún @ 2019-05-02 13:28 UTC (permalink / raw)
To: u-boot
The btrfs implementation methods .ls(), .size() and .read() returns 1 on
failure, but the command handlers expect values <0 on failure.
For example if given a nonexistent path, the load command currently
returns success, and hush scripting does not work.
Fix this by setting return values of these methods to -1 instead of 1 on
failure.
Signed-off-by: Marek Behún <marek.behun@nic.cz>
---
fs/btrfs/btrfs.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/fs/btrfs/btrfs.c b/fs/btrfs/btrfs.c
index 6f35854823..cb7e182742 100644
--- a/fs/btrfs/btrfs.c
+++ b/fs/btrfs/btrfs.c
@@ -119,17 +119,17 @@ int btrfs_ls(const char *path)
if (inr == -1ULL) {
printf("Cannot lookup path %s\n", path);
- return 1;
+ return -1;
}
if (type != BTRFS_FT_DIR) {
printf("Not a directory: %s\n", path);
- return 1;
+ return -1;
}
if (btrfs_readdir(&root, inr, readdir_callback)) {
printf("An error occured while listing directory %s\n", path);
- return 1;
+ return -1;
}
return 0;
@@ -158,12 +158,12 @@ int btrfs_size(const char *file, loff_t *size)
if (inr == -1ULL) {
printf("Cannot lookup file %s\n", file);
- return 1;
+ return -1;
}
if (type != BTRFS_FT_REG_FILE) {
printf("Not a regular file: %s\n", file);
- return 1;
+ return -1;
}
*size = inode.size;
@@ -183,12 +183,12 @@ int btrfs_read(const char *file, void *buf, loff_t offset, loff_t len,
if (inr == -1ULL) {
printf("Cannot lookup file %s\n", file);
- return 1;
+ return -1;
}
if (type != BTRFS_FT_REG_FILE) {
printf("Not a regular file: %s\n", file);
- return 1;
+ return -1;
}
if (!len)
@@ -200,7 +200,7 @@ int btrfs_read(const char *file, void *buf, loff_t offset, loff_t len,
rd = btrfs_file_read(&root, inr, offset, len, buf);
if (rd == -1ULL) {
printf("An error occured while reading file %s\n", file);
- return 1;
+ return -1;
}
*actread = rd;
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot] [PATCH] fs: btrfs: fix btrfs methods return values on failure
2019-05-02 13:28 [U-Boot] [PATCH] fs: btrfs: fix btrfs methods return values on failure Marek Behún
@ 2019-05-03 18:21 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2019-05-03 18:21 UTC (permalink / raw)
To: u-boot
On Thu, May 02, 2019 at 03:28:43PM +0200, Marek Behún wrote:
> The btrfs implementation methods .ls(), .size() and .read() returns 1 on
> failure, but the command handlers expect values <0 on failure.
>
> For example if given a nonexistent path, the load command currently
> returns success, and hush scripting does not work.
>
> Fix this by setting return values of these methods to -1 instead of 1 on
> failure.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190503/fbe75e7d/attachment.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-05-03 18:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-02 13:28 [U-Boot] [PATCH] fs: btrfs: fix btrfs methods return values on failure Marek Behún
2019-05-03 18:21 ` Tom Rini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.