Re: [PATCH v2 3/3] btrfs-progs: handle error in the btrfs_prepare_device

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

 



On Tue, 17 Dec 2013 10:33:36 +0800, Anand Jain wrote:
> 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 <anand.jain@xxxxxxxxxx>
> ---
>  v2: commit update
> ---
>  cmds-device.c  |  7 +++----
>  cmds-replace.c | 10 ++++------
>  mkfs.c         |  9 ++++++++-
>  utils.c        | 30 +++++++++++++++++++-----------
>  4 files changed, 34 insertions(+), 22 deletions(-)
> 
[...]
> diff --git a/cmds-replace.c b/cmds-replace.c
> index d9b0940..8160107 100644
> --- a/cmds-replace.c
> +++ b/cmds-replace.c
> @@ -276,13 +276,11 @@ static int cmd_start_replace(int argc, char **argv)
>  	}
>  	strncpy((char *)start_args.start.tgtdev_name, dstdev,
>  		BTRFS_DEVICE_PATH_NAME_MAX);
> -	if (btrfs_prepare_device(fddstdev, dstdev, 1, &dstdev_block_count, 0,
> -				 &mixed, 0)) {
> -		fprintf(stderr, "Error: Failed to prepare device '%s'\n",
> -			dstdev);
> -		goto leave_with_error;
> -	}
> +	ret = btrfs_prepare_device(fddstdev, dstdev, 1, &dstdev_block_count, 0,
> +				 &mixed, 0);
>  	close(fddstdev);
> +	if (ret)
> +		goto leave_with_error;
>  	fddstdev = -1;

You change the code to call close(fddstdev) twice.

[...]
> +zero_dev_error:
> +	if (ret) {
> +		ret < 0 ?
> +		fprintf(stderr, "ERROR: failed to zero device start '%s' - %s\n",
> +			file, strerror(-ret)) :
> +		fprintf(stderr, "ERROR: failed to zero device start '%s' - %d\n",
> +			file, ret);

This is not funny.



--
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