From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=52108 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTeOT-0001ed-7P for qemu-devel@nongnu.org; Fri, 17 Dec 2010 12:47:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PTeMC-00036C-TT for qemu-devel@nongnu.org; Fri, 17 Dec 2010 12:45:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:15294) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PTeMC-000368-Kb for qemu-devel@nongnu.org; Fri, 17 Dec 2010 12:44:40 -0500 From: Kevin Wolf Date: Fri, 17 Dec 2010 18:44:37 +0100 Message-Id: <1292607893-13461-23-git-send-email-kwolf@redhat.com> In-Reply-To: <1292607893-13461-1-git-send-email-kwolf@redhat.com> References: <1292607893-13461-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 22/38] bdrv_img_create() use proper errno return values List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Jes Sorensen Kevin suggested to have bdrv_img_create() return proper -errno values on error. Signed-off-by: Jes Sorensen Signed-off-by: Kevin Wolf --- block.c | 23 ++++++++++------------- 1 files changed, 10 insertions(+), 13 deletions(-) diff --git a/block.c b/block.c index 0c14eee..fe07d0b 100644 --- a/block.c +++ b/block.c @@ -2773,14 +2773,14 @@ int bdrv_img_create(const char *filename, const char *fmt, drv = bdrv_find_format(fmt); if (!drv) { error_report("Unknown file format '%s'", fmt); - ret = -1; + ret = -EINVAL; goto out; } proto_drv = bdrv_find_protocol(filename); if (!proto_drv) { error_report("Unknown protocol '%s'", filename); - ret = -1; + ret = -EINVAL; goto out; } @@ -2799,7 +2799,7 @@ int bdrv_img_create(const char *filename, const char *fmt, param = parse_option_parameters(options, create_options, param); if (param == NULL) { error_report("Invalid options for file format '%s'.", fmt); - ret = -1; + ret = -EINVAL; goto out; } } @@ -2809,7 +2809,7 @@ int bdrv_img_create(const char *filename, const char *fmt, base_filename)) { error_report("Backing file not supported for file format '%s'", fmt); - ret = -1; + ret = -EINVAL; goto out; } } @@ -2818,7 +2818,7 @@ int bdrv_img_create(const char *filename, const char *fmt, if (set_option_parameter(param, BLOCK_OPT_BACKING_FMT, base_fmt)) { error_report("Backing file format not supported for file " "format '%s'", fmt); - ret = -1; + ret = -EINVAL; goto out; } } @@ -2828,7 +2828,7 @@ int bdrv_img_create(const char *filename, const char *fmt, if (!strcmp(filename, backing_file->value.s)) { error_report("Error: Trying to create an image with the " "same filename as the backing file"); - ret = -1; + ret = -EINVAL; goto out; } } @@ -2838,7 +2838,7 @@ int bdrv_img_create(const char *filename, const char *fmt, if (!bdrv_find_format(backing_fmt->value.s)) { error_report("Unknown backing file format '%s'", backing_fmt->value.s); - ret = -1; + ret = -EINVAL; goto out; } } @@ -2860,7 +2860,6 @@ int bdrv_img_create(const char *filename, const char *fmt, ret = bdrv_open(bs, backing_file->value.s, flags, drv); if (ret < 0) { error_report("Could not open '%s'", filename); - ret = -1; goto out; } bdrv_get_geometry(bs, &size); @@ -2870,7 +2869,7 @@ int bdrv_img_create(const char *filename, const char *fmt, set_option_parameter(param, BLOCK_OPT_SIZE, buf); } else { error_report("Image creation needs a size parameter"); - ret = -1; + ret = -EINVAL; goto out; } } @@ -2901,8 +2900,6 @@ out: if (bs) { bdrv_delete(bs); } - if (ret) { - return 1; - } - return 0; + + return ret; } -- 1.7.2.3