From nobody Thu May 2 01:47:22 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1507560643745199.4189865477059; Mon, 9 Oct 2017 07:50:43 -0700 (PDT) Received: from localhost ([::1]:58265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1ZO9-0001h9-VH for importer@patchew.org; Mon, 09 Oct 2017 10:50:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33612) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1ZNF-0001GX-UA for qemu-devel@nongnu.org; Mon, 09 Oct 2017 10:49:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1ZNC-0006QM-S7 for qemu-devel@nongnu.org; Mon, 09 Oct 2017 10:49:41 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:36092) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e1ZNC-000675-DZ; Mon, 09 Oct 2017 10:49:38 -0400 Received: from [88.128.80.52] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1e1ZMa-0006hC-G9; Mon, 09 Oct 2017 16:49:00 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1e1ZMN-0000GS-Kx; Mon, 09 Oct 2017 17:48:47 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Message-Id:Date:Subject:Cc:To:From; bh=Yd38sNr4R7+Go91DNsQb3N9cp4wRhMDn2ZJGZVP1hcw=; b=JGpBD/7sN+AcHyU/KrlzCnXgBE8/K/qte2iNqn9wt+Ywp+maVgMAiUYm5sf4tLKCSi3u1YHia535zArTrEhIeAzYU45on6LnPZI2k2qr60ylcX+6BmwPSLH/sf0yFnxxqsPcMEXJ0h5jqiqnoKm0ga6ZOx8DqBTYRA8sDuR04LrznTmd3Y9zsxPjtUf+t2c8gC8sOQYmye+3I/DBHKaXzb6erSXf7dkHbfAafnWRqh1qKADlagWVpPxwqwmlUn4UVfrIEjKjwTKvIjuKzrAG3dfWLNhn/u+FLsudYD8Jiyyca2+djWPC6PULMt0Fnslp9CjZtdJqQ85Nv+EQ+fTziA==; From: Alberto Garcia To: Date: Mon, 9 Oct 2017 16:48:40 +0200 Message-Id: <20171009144840.973-1-berto@igalia.com> X-Mailer: git-send-email 2.11.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 91.117.99.155 Subject: [Qemu-devel] [PATCH] qcow2: Use BDRV_SECTOR_BITS instead of its literal value X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-devel@nongnu.org, qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" BDRV_SECTOR_BITS is defined to be 9 in block.h (and BDRV_SECTOR_SIZE is calculated from that), but there are still a few placed where we are using the literal value instead of the macro. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 6 +++--- block/qcow2.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 0e5aec81cb..0a63604af6 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -748,8 +748,8 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDri= verState *bs, return 0; } =20 - nb_csectors =3D ((cluster_offset + compressed_size - 1) >> 9) - - (cluster_offset >> 9); + nb_csectors =3D ((cluster_offset + compressed_size - 1) >> BDRV_SECTOR= _BITS) - + (cluster_offset >> BDRV_SECTOR_BITS); =20 cluster_offset |=3D QCOW_OFLAG_COMPRESSED | ((uint64_t)nb_csectors << s->csize_shift); @@ -1582,7 +1582,7 @@ int qcow2_decompress_cluster(BlockDriverState *bs, ui= nt64_t cluster_offset) } =20 BLKDBG_EVENT(bs->file, BLKDBG_READ_COMPRESSED); - ret =3D bdrv_read(bs->file, coffset >> 9, s->cluster_data, + ret =3D bdrv_read(bs->file, coffset >> BDRV_SECTOR_BITS, s->cluste= r_data, nb_csectors); if (ret < 0) { return ret; diff --git a/block/qcow2.c b/block/qcow2.c index f63d1831f8..dff903e05c 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1139,7 +1139,7 @@ static int qcow2_do_open(BlockDriverState *bs, QDict = *options, int flags, =20 s->cluster_bits =3D header.cluster_bits; s->cluster_size =3D 1 << s->cluster_bits; - s->cluster_sectors =3D 1 << (s->cluster_bits - 9); + s->cluster_sectors =3D 1 << (s->cluster_bits - BDRV_SECTOR_BITS); =20 /* Initialise version 3 header fields */ if (header.version =3D=3D 2) { @@ -1636,7 +1636,7 @@ static int64_t coroutine_fn qcow2_co_get_block_status= (BlockDriverState *bs, =20 bytes =3D MIN(INT_MAX, nb_sectors * BDRV_SECTOR_SIZE); qemu_co_mutex_lock(&s->lock); - ret =3D qcow2_get_cluster_offset(bs, sector_num << 9, &bytes, + ret =3D qcow2_get_cluster_offset(bs, sector_num << BDRV_SECTOR_BITS, &= bytes, &cluster_offset); qemu_co_mutex_unlock(&s->lock); if (ret < 0) { --=20 2.11.0