diff mbox

[v2] btrfs-progs: reserve < 0 return value for errnos

Message ID 20171027144118.23449-1-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anand Jain Oct. 27, 2017, 2:41 p.m. UTC
btrfs_read_dev_super() returns -1 / -EPERM upon not finding a suitable SB,
change that to return -ENOENT instead, which is much closer to the actual
possible errors.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: use -ENOENT instead of 1.

 disk-io.c | 2 +-
 utils.c   | 2 +-
 volumes.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/disk-io.c b/disk-io.c
index f5edc4796619..dcaaea898a3f 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1491,7 +1491,7 @@  int btrfs_read_dev_super(int fd, struct btrfs_super_block *sb, u64 sb_bytenr,
 		}
 	}
 
-	return transid > 0 ? 0 : -1;
+	return transid > 0 ? 0 : -ENOENT;
 }
 
 static int write_dev_supers(struct btrfs_fs_info *fs_info,
diff --git a/utils.c b/utils.c
index 524f463d3140..7574cda8151c 100644
--- a/utils.c
+++ b/utils.c
@@ -1678,7 +1678,7 @@  int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
 		disk_super = (struct btrfs_super_block *)buf;
 		ret = btrfs_read_dev_super(fd, disk_super,
 					   BTRFS_SUPER_INFO_OFFSET, 0);
-		if (ret < 0) {
+		if (ret) {
 			ret = -EIO;
 			goto out;
 		}
diff --git a/volumes.c b/volumes.c
index 2209e5a9100b..87008bfdd586 100644
--- a/volumes.c
+++ b/volumes.c
@@ -268,7 +268,7 @@  int btrfs_scan_one_device(int fd, const char *path,
 
 	disk_super = (struct btrfs_super_block *)buf;
 	ret = btrfs_read_dev_super(fd, disk_super, super_offset, sbflags);
-	if (ret < 0)
+	if (ret)
 		return -EIO;
 	devid = btrfs_stack_device_id(&disk_super->dev_item);
 	if (btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_METADUMP)