[PATCH 03/20] Btrfs-progs: fix magic return value in cmds-chunk.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Wang Shilong <wangsl.fnst@xxxxxxxxxxxxxx>

Signed-off-by: Wang Shilong <wangsl.fnst@xxxxxxxxxxxxxx>
---
 cmds-chunk.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/cmds-chunk.c b/cmds-chunk.c
index 54f0573..115db61 100644
--- a/cmds-chunk.c
+++ b/cmds-chunk.c
@@ -794,13 +794,15 @@ static int scan_devices(struct recover_control *rc)
 	int ret = 0;
 	int fd;
 	struct btrfs_device *dev;
+	int e;
 
 	list_for_each_entry(dev, &rc->fs_devices->devices, dev_list) {
 		fd = open(dev->name, O_RDONLY);
 		if (fd < 0) {
+			e = errno;
 			fprintf(stderr, "Failed to open device %s\n",
 				dev->name);
-			return -1;
+			return -e;
 		}
 		ret = scan_one_device(rc, fd, dev);
 		close(fd);
@@ -1785,7 +1787,7 @@ int cmd_chunk_recover(int argc, char *argv[])
 	ret = check_mounted(file);
 	if (ret) {
 		fprintf(stderr, "the device is busy\n");
-		return ret;
+		goto out;
 	}
 
 	ret = btrfs_recover_chunk_tree(file, verbose, yes);
@@ -1797,5 +1799,6 @@ int cmd_chunk_recover(int argc, char *argv[])
 	} else {
 		fprintf(stdout, "Fail to recover the chunk tree.\n");
 	}
-	return ret;
+out:
+	return !!ret;
 }
-- 
1.7.11.7

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux