From patchwork Tue Mar 10 08:51:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Denis V. Lunev" X-Patchwork-Id: 448424 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 5DA8B1401AA for ; Tue, 10 Mar 2015 19:59:30 +1100 (AEDT) Received: from localhost ([::1]:47349 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVG0e-0006tX-DX for incoming@patchwork.ozlabs.org; Tue, 10 Mar 2015 04:59:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVFti-0001lc-JY for qemu-devel@nongnu.org; Tue, 10 Mar 2015 04:52:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVFth-00006g-P9 for qemu-devel@nongnu.org; Tue, 10 Mar 2015 04:52:18 -0400 Received: from mailhub.sw.ru ([195.214.232.25]:34723 helo=relay.sw.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVFth-0007iq-DP for qemu-devel@nongnu.org; Tue, 10 Mar 2015 04:52:17 -0400 Received: from hades.sw.ru ([10.30.8.132]) by relay.sw.ru (8.13.4/8.13.4) with ESMTP id t2A8olAq017896; Tue, 10 Mar 2015 11:50:49 +0300 (MSK) From: "Denis V. Lunev" To: Date: Tue, 10 Mar 2015 11:51:01 +0300 Message-Id: <1425977481-13317-8-git-send-email-den@openvz.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1425977481-13317-1-git-send-email-den@openvz.org> References: <1425977481-13317-1-git-send-email-den@openvz.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.0 [fuzzy] X-Received-From: 195.214.232.25 Cc: Kevin Wolf , "Denis V. Lunev" , qemu-devel@nongnu.org, Stefan Hajnoczi Subject: [Qemu-devel] [PATCH 07/27] block/parallels: replace magic constants 4, 64 with proper sizeofs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org simple purification.. Signed-off-by: Denis V. Lunev Reviewed-by: Roman Kagan CC: Kevin Wolf CC: Stefan Hajnoczi --- block/parallels.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 64b169b..306f2e3 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -32,7 +32,6 @@ #define HEADER_MAGIC "WithoutFreeSpace" #define HEADER_MAGIC2 "WithouFreSpacExt" #define HEADER_VERSION 2 -#define HEADER_SIZE 64 // always little-endian typedef struct ParallelsHeader { @@ -63,7 +62,7 @@ static int parallels_probe(const uint8_t *buf, int buf_size, const char *filenam { const ParallelsHeader *ph = (const void *)buf; - if (buf_size < HEADER_SIZE) + if (buf_size < sizeof(ParallelsHeader)) return 0; if ((!memcmp(ph->magic, HEADER_MAGIC, 16) || @@ -116,7 +115,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } s->catalog_size = le32_to_cpu(ph.catalog_entries); - if (s->catalog_size > INT_MAX / 4) { + if (s->catalog_size > INT_MAX / sizeof(uint32_t)) { error_setg(errp, "Catalog too large"); ret = -EFBIG; goto fail; @@ -127,7 +126,8 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } - ret = bdrv_pread(bs->file, 64, s->catalog_bitmap, s->catalog_size * 4); + ret = bdrv_pread(bs->file, sizeof(ParallelsHeader), + s->catalog_bitmap, s->catalog_size * sizeof(uint32_t)); if (ret < 0) { goto fail; }