Received: from eggs.gnu.org ([2001:4830:134:3::10]:46045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBnhq-00070V-5t for qemu-devel@nongnu.org; Mon, 28 Jul 2014 12:23:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XBnhk-0000Me-DD for qemu-devel@nongnu.org; Mon, 28 Jul 2014 12:23:22 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:12956 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XBnhk-0000E9-24 for qemu-devel@nongnu.org; Mon, 28 Jul 2014 12:23:16 -0400 From: "Denis V. Lunev" Date: Mon, 28 Jul 2014 20:23:54 +0400 Message-Id: <1406564635-261591-4-git-send-email-den@openvz.org> In-Reply-To: <1406564635-261591-1-git-send-email-den@openvz.org> References: <1406564635-261591-1-git-send-email-den@openvz.org> Subject: [Qemu-devel] [PATCH v2 3/4] parallels: split check for parallels format in parallels_open List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , den@openvz.org, Jeff Cody , qemu-devel@nongnu.org, Stefan Hajnoczi 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 --- block/parallels.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 16d14ad..466705e 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); @@ -120,6 +120,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.1