summaryrefslogtreecommitdiff
path: root/cmds-filesystem.c
diff options
context:
space:
mode:
authorEric Sandeen <sandeen@redhat.com>2013-11-06 17:15:41 -0600
committerChris Mason <chris.mason@fusionio.com>2013-11-07 16:10:40 -0500
commit667c121184f374bfd8d18275f6cd53472f991677 (patch)
tree98774e1ed500a7db6d4c3eeda205a2b5ad948fe5 /cmds-filesystem.c
parent83e941a746e71aa54da2b4bb2c22077c51d31082 (diff)
btrfs-progs: fix error returns in get_df()
get_df returns -ERRNO, or maybe (+)errno, or even 0 in the case where we inexplicably got 0 total_spaces from the BTRFS_IOC_SPACE_INFO. Consistently return a negative error number, and return -ENOENT rather than 0 for total_spaces == 0, so that the caller will know that **sargs_ret hasn't been set up. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'cmds-filesystem.c')
-rw-r--r--cmds-filesystem.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index eb9b5e4f..e920b8a3 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -106,11 +106,12 @@ static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
fprintf(stderr, "ERROR: couldn't get space info - %s\n",
strerror(e));
free(sargs);
- return ret;
+ return -e;
}
+ /* This really should never happen */
if (!sargs->total_spaces) {
free(sargs);
- return 0;
+ return -ENOENT;
}
count = sargs->total_spaces;
free(sargs);
@@ -128,7 +129,7 @@ static int get_df(int fd, struct btrfs_ioctl_space_args **sargs_ret)
fprintf(stderr, "ERROR: get space info count %llu - %s\n",
count, strerror(e));
free(sargs);
- return ret;
+ return -e;
}
*sargs_ret = sargs;
return 0;