From patchwork Thu Dec 13 15:10:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 206170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C47BC2C0095 for ; Fri, 14 Dec 2012 03:53:55 +1100 (EST) Received: from localhost ([::1]:52662 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjC2k-0005bA-22 for incoming@patchwork.ozlabs.org; Thu, 13 Dec 2012 11:53:54 -0500 Received: from eggs.gnu.org ([208.118.235.92]:37141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjARU-000888-QJ for qemu-devel@nongnu.org; Thu, 13 Dec 2012 10:11:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TjARN-0005xs-C4 for qemu-devel@nongnu.org; Thu, 13 Dec 2012 10:11:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TjARN-0005xc-58 for qemu-devel@nongnu.org; Thu, 13 Dec 2012 10:11:13 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBDFBC65012822 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 13 Dec 2012 10:11:12 -0500 Received: from dhcp-5-188.str.redhat.com (dhcp-200-232.str.redhat.com [10.33.200.232]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBDFApmX026810; Thu, 13 Dec 2012 10:11:11 -0500 From: Kevin Wolf To: anthony@codemonkey.ws Date: Thu, 13 Dec 2012 16:10:25 +0100 Message-Id: <1355411450-12761-19-git-send-email-kwolf@redhat.com> In-Reply-To: <1355411450-12761-1-git-send-email-kwolf@redhat.com> References: <1355411450-12761-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kwolf@redhat.com, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 18/43] block: bdrv_img_create(): drop unused error handling code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Luiz Capitulino Signed-off-by: Luiz Capitulino Signed-off-by: Kevin Wolf --- block.c | 40 +++++----------------------------------- block.h | 6 +++--- 2 files changed, 8 insertions(+), 38 deletions(-) diff --git a/block.c b/block.c index 066bd66..b3faf3a 100644 --- a/block.c +++ b/block.c @@ -4442,9 +4442,9 @@ bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie) bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns; } -int bdrv_img_create(const char *filename, const char *fmt, - const char *base_filename, const char *base_fmt, - char *options, uint64_t img_size, int flags, Error **errp) +void bdrv_img_create(const char *filename, const char *fmt, + const char *base_filename, const char *base_fmt, + char *options, uint64_t img_size, int flags, Error **errp) { QEMUOptionParameter *param = NULL, *create_options = NULL; QEMUOptionParameter *backing_fmt, *backing_file, *size; @@ -4456,18 +4456,14 @@ int bdrv_img_create(const char *filename, const char *fmt, /* Find driver and parse its options */ drv = bdrv_find_format(fmt); if (!drv) { - error_report("Unknown file format '%s'", fmt); error_setg(errp, "Unknown file format '%s'", fmt); - ret = -EINVAL; - goto out; + return; } proto_drv = bdrv_find_protocol(filename); if (!proto_drv) { - error_report("Unknown protocol '%s'", filename); error_setg(errp, "Unknown protocol '%s'", filename); - ret = -EINVAL; - goto out; + return; } create_options = append_option_parameters(create_options, @@ -4484,9 +4480,7 @@ int bdrv_img_create(const char *filename, const char *fmt, if (options) { param = parse_option_parameters(options, create_options, param); if (param == NULL) { - error_report("Invalid options for file format '%s'.", fmt); error_setg(errp, "Invalid options for file format '%s'.", fmt); - ret = -EINVAL; goto out; } } @@ -4494,22 +4488,16 @@ int bdrv_img_create(const char *filename, const char *fmt, if (base_filename) { if (set_option_parameter(param, BLOCK_OPT_BACKING_FILE, base_filename)) { - error_report("Backing file not supported for file format '%s'", - fmt); error_setg(errp, "Backing file not supported for file format '%s'", fmt); - ret = -EINVAL; goto out; } } if (base_fmt) { if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, base_fmt)) { - error_report("Backing file format not supported for file " - "format '%s'", fmt); error_setg(errp, "Backing file format not supported for file " "format '%s'", fmt); - ret = -EINVAL; goto out; } } @@ -4517,11 +4505,8 @@ int bdrv_img_create(const char *filename, const char *fmt, backing_file = get_option_parameter(param, BLOCK_OPT_BACKING_FILE); if (backing_file && backing_file->value.s) { if (!strcmp(filename, backing_file->value.s)) { - error_report("Error: Trying to create an image with the " - "same filename as the backing file"); error_setg(errp, "Error: Trying to create an image with the " "same filename as the backing file"); - ret = -EINVAL; goto out; } } @@ -4530,11 +4515,8 @@ int bdrv_img_create(const char *filename, const char *fmt, if (backing_fmt && backing_fmt->value.s) { backing_drv = bdrv_find_format(backing_fmt->value.s); if (!backing_drv) { - error_report("Unknown backing file format '%s'", - backing_fmt->value.s); error_setg(errp, "Unknown backing file format '%s'", backing_fmt->value.s); - ret = -EINVAL; goto out; } } @@ -4556,7 +4538,6 @@ int bdrv_img_create(const char *filename, const char *fmt, ret = bdrv_open(bs, backing_file->value.s, back_flags, backing_drv); if (ret < 0) { - error_report("Could not open '%s'", backing_file->value.s); error_setg_errno(errp, -ret, "Could not open '%s'", backing_file->value.s); goto out; @@ -4567,9 +4548,7 @@ int bdrv_img_create(const char *filename, const char *fmt, snprintf(buf, sizeof(buf), "%" PRId64, size); set_option_parameter(param, BLOCK_OPT_SIZE, buf); } else { - error_report("Image creation needs a size parameter"); error_setg(errp, "Image creation needs a size parameter"); - ret = -EINVAL; goto out; } } @@ -4579,21 +4558,14 @@ int bdrv_img_create(const char *filename, const char *fmt, puts(""); ret = bdrv_create(drv, filename, param); - if (ret < 0) { if (ret == -ENOTSUP) { - error_report("Formatting or formatting option not supported for " - "file format '%s'", fmt); error_setg(errp,"Formatting or formatting option not supported for " "file format '%s'", fmt); } else if (ret == -EFBIG) { - error_report("The image size is too large for file format '%s'", - fmt); error_setg(errp, "The image size is too large for file format '%s'", fmt); } else { - error_report("%s: error while creating %s: %s", filename, fmt, - strerror(-ret)); error_setg(errp, "%s: error while creating %s: %s", filename, fmt, strerror(-ret)); } @@ -4606,6 +4578,4 @@ out: if (bs) { bdrv_delete(bs); } - - return ret; } diff --git a/block.h b/block.h index ff54d15..24bea09 100644 --- a/block.h +++ b/block.h @@ -343,9 +343,9 @@ int bdrv_save_vmstate(BlockDriverState *bs, const uint8_t *buf, int bdrv_load_vmstate(BlockDriverState *bs, uint8_t *buf, int64_t pos, int size); -int bdrv_img_create(const char *filename, const char *fmt, - const char *base_filename, const char *base_fmt, - char *options, uint64_t img_size, int flags, Error **errp); +void bdrv_img_create(const char *filename, const char *fmt, + const char *base_filename, const char *base_fmt, + char *options, uint64_t img_size, int flags, Error **errp); void bdrv_set_buffer_alignment(BlockDriverState *bs, int align); void *qemu_blockalign(BlockDriverState *bs, size_t size);