From d89437893266332cce295c06c9d00b79aa5b4dd6 Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Wed, 18 Dec 2013 12:07:55 +0800 Subject: btrfs-progs: handle error in the btrfs_prepare_device this patch will handle the strerror reporting of the error instead of printing errno, and also replaced the BUG_ON with the error handling Signed-off-by: Anand Jain Signed-off-by: David Sterba Signed-off-by: Chris Mason --- cmds-device.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'cmds-device.c') diff --git a/cmds-device.c b/cmds-device.c index ea20919e..5be83300 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -111,13 +111,11 @@ static int cmd_add_dev(int argc, char **argv) res = btrfs_prepare_device(devfd, argv[i], 1, &dev_block_count, 0, &mixed, discard); + close(devfd); if (res) { - fprintf(stderr, "ERROR: Unable to init '%s'\n", argv[i]); - close(devfd); ret++; - continue; + goto error_out; } - close(devfd); strncpy_null(ioctl_args.name, argv[i]); res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args); @@ -130,6 +128,7 @@ static int cmd_add_dev(int argc, char **argv) } +error_out: close_file_or_dir(fdmnt, dirstream); return !!ret; } -- cgit v1.2.3