From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlD94-0003R5-No for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UlD93-0000Ue-Oj for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:02 -0400 Received: from e23smtp07.au.ibm.com ([202.81.31.140]:34491) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UlD93-0000UY-5f for qemu-devel@nongnu.org; Sat, 08 Jun 2013 03:01:01 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sat, 8 Jun 2013 16:49:59 +1000 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [9.190.235.21]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 81B9D2CE804A for ; Sat, 8 Jun 2013 17:00:52 +1000 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r5870i9T32374876 for ; Sat, 8 Jun 2013 17:00:44 +1000 Received: from d23av03.au.ibm.com (loopback [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r5870pAj025765 for ; Sat, 8 Jun 2013 17:00:51 +1000 From: Wenchao Xia Date: Sat, 8 Jun 2013 14:57:57 +0800 Message-Id: <1370674687-13849-2-git-send-email-xiawenc@linux.vnet.ibm.com> In-Reply-To: <1370674687-13849-1-git-send-email-xiawenc@linux.vnet.ibm.com> References: <1370674687-13849-1-git-send-email-xiawenc@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 01/11] blockdev: drop redundant proto_drv check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, phrdina@redhat.com, armbru@redhat.com, lcapitulino@redhat.com, stefanha@redhat.com, pbonzini@redhat.com, dietmar@proxmox.com From: Stefan Hajnoczi It is not necessary to check that we can find a protocol block driver since we create or open the image file. This produces the error that we need anyway. Besides, the QERR_INVALID_BLOCK_FORMAT is inappropriate since the protocol is incorrect rather than the format. Also drop an empty line between bdrv_open() and checking its return value. This may be due to copy-pasting from earlier code that performed other operations before handling errors. Reported-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake Reviewed-by: Wenchao Xia --- blockdev.c | 15 --------------- 1 files changed, 0 insertions(+), 15 deletions(-) diff --git a/blockdev.c b/blockdev.c index 9937311..e70225b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -818,7 +818,6 @@ typedef struct ExternalSnapshotStates { static void external_snapshot_prepare(BlkTransactionStates *common, Error **errp) { - BlockDriver *proto_drv; BlockDriver *drv; int flags, ret; Error *local_err = NULL; @@ -874,12 +873,6 @@ static void external_snapshot_prepare(BlkTransactionStates *common, flags = states->old_bs->open_flags; - proto_drv = bdrv_find_protocol(new_image_file); - if (!proto_drv) { - error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); - return; - } - /* create new image w/backing file */ if (mode != NEW_IMAGE_MODE_EXISTING) { bdrv_img_create(new_image_file, format, @@ -1372,7 +1365,6 @@ void qmp_drive_mirror(const char *device, const char *target, { BlockDriverState *bs; BlockDriverState *source, *target_bs; - BlockDriver *proto_drv; BlockDriver *drv = NULL; Error *local_err = NULL; int flags; @@ -1440,12 +1432,6 @@ void qmp_drive_mirror(const char *device, const char *target, sync = MIRROR_SYNC_MODE_FULL; } - proto_drv = bdrv_find_protocol(target); - if (!proto_drv) { - error_set(errp, QERR_INVALID_BLOCK_FORMAT, format); - return; - } - bdrv_get_geometry(bs, &size); size *= 512; if (sync == MIRROR_SYNC_MODE_FULL && mode != NEW_IMAGE_MODE_EXISTING) { @@ -1480,7 +1466,6 @@ void qmp_drive_mirror(const char *device, const char *target, */ target_bs = bdrv_new(""); ret = bdrv_open(target_bs, target, NULL, flags | BDRV_O_NO_BACKING, drv); - if (ret < 0) { bdrv_delete(target_bs); error_set(errp, QERR_OPEN_FILE_FAILED, target); -- 1.7.1