From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38338) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTpUE-0007To-Hq for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VTpU8-0001sA-Eo for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:51:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17631) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VTpU8-0001s4-7H for qemu-devel@nongnu.org; Wed, 09 Oct 2013 04:51:12 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r998pBhV022070 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 9 Oct 2013 04:51:11 -0400 From: Max Reitz Date: Wed, 9 Oct 2013 10:51:04 +0200 Message-Id: <1381308666-24268-2-git-send-email-mreitz@redhat.com> In-Reply-To: <1381308666-24268-1-git-send-email-mreitz@redhat.com> References: <1381308666-24268-1-git-send-email-mreitz@redhat.com> Subject: [Qemu-devel] [PATCH 1/3] qcow2: Always use error path on writing snapshots List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Max Reitz qcow2_write_snapshots does contain a fail label and there is no reason not to use it on some errors; therefore, we should always jump there on error. Signed-off-by: Max Reitz --- block/qcow2-snapshot.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index 5e8a779..3337974 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -182,11 +182,12 @@ static int qcow2_write_snapshots(BlockDriverState *bs) snapshots_offset = qcow2_alloc_clusters(bs, snapshots_size); offset = snapshots_offset; if (offset < 0) { - return offset; + ret = offset; + goto fail; } ret = bdrv_flush(bs); if (ret < 0) { - return ret; + goto fail; } /* The snapshot list position has not yet been updated, so these clusters @@ -194,7 +195,7 @@ static int qcow2_write_snapshots(BlockDriverState *bs) ret = qcow2_pre_write_overlap_check(bs, QCOW2_OL_DEFAULT, offset, snapshots_size); if (ret < 0) { - return ret; + goto fail; } -- 1.8.3.1