From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50430) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIKzQ-0007MY-PQ for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:08:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIKzL-0000RE-R5 for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:08:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:4698) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIKzL-0000Qn-He for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:08:27 -0400 From: Stefan Hajnoczi Date: Fri, 15 Aug 2014 18:06:44 +0100 Message-Id: <1408122422-13935-38-git-send-email-stefanha@redhat.com> In-Reply-To: <1408122422-13935-1-git-send-email-stefanha@redhat.com> References: <1408122422-13935-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 37/55] parallels: split check for parallels format in parallels_open List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Jeff Cody , Stefan Hajnoczi , "Denis V. Lunev" From: "Denis V. Lunev" and rework error path a bit. There is no difference at the moment, but the code will be definitely shorter when additional processing will be required for WithouFreSpacExt Signed-off-by: Denis V. Lunev CC: Jeff Cody CC: Kevin Wolf CC: Stefan Hajnoczi Reviewed-by: Jeff Cody Signed-off-by: Stefan Hajnoczi --- block/parallels.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index e0cf1d9..f9e18b4 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -85,11 +85,11 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } - if (memcmp(ph.magic, HEADER_MAGIC, 16) || - (le32_to_cpu(ph.version) != HEADER_VERSION)) { - error_setg(errp, "Image not in Parallels format"); - ret = -EINVAL; - goto fail; + if (le32_to_cpu(ph.version) != HEADER_VERSION) { + goto fail_format; + } + if (memcmp(ph.magic, HEADER_MAGIC, 16)) { + goto fail_format; } bs->total_sectors = 0xffffffff & le64_to_cpu(ph.nb_sectors); @@ -124,6 +124,9 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, qemu_co_mutex_init(&s->lock); return 0; +fail_format: + error_setg(errp, "Image not in Parallels format"); + ret = -EINVAL; fail: g_free(s->catalog_bitmap); return ret; -- 1.9.3