From 418a7adb77abbbc09a17d5626cbaa5e9e54be709 Mon Sep 17 00:00:00 2001 From: "Denis V. Lunev" Date: Mon, 28 Jul 2014 20:23:54 +0400 Subject: parallels: split check for parallels format in parallels_open 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(-) (limited to 'block') diff --git a/block/parallels.c b/block/parallels.c index e0cf1d991f..f9e18b4537 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; -- cgit v1.2.1