From nobody Mon Feb 9 07:43:00 2026 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.zoho.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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1496844637034648.1660178968655; Wed, 7 Jun 2017 07:10:37 -0700 (PDT) Received: from localhost ([::1]:44219 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIbfN-0000kE-5O for importer@patchew.org; Wed, 07 Jun 2017 10:10:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44574) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIbdw-000819-Dd for qemu-devel@nongnu.org; Wed, 07 Jun 2017 10:09:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIbdr-0002YW-9w for qemu-devel@nongnu.org; Wed, 07 Jun 2017 10:09:04 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:58677) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dIbdq-0002WL-L1; Wed, 07 Jun 2017 10:08:59 -0400 Received: from [194.100.51.2] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1dIbdm-0001gV-NW; Wed, 07 Jun 2017 16:08:54 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1dIbdW-0005i6-NX; Wed, 07 Jun 2017 17:08:38 +0300 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=References:In-Reply-To:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=58I4+wHSvvWJQmc0egBSJCLEBjoUTLGntd78dzP+aoc=; b=KzimWSBCZqz720g4u4QdoHxJi9QqiTBjuzRjBez0VXYsTeH0ztT95l/i7wcW6jPfk3lDQYOzXZ2OLDLuKnrZp4G+Wa567rHoGFDvwvLkErJmkgp1Ymif4QpzhF1PJIt6pWnt/Zk+wIgfwoxUOS08P73S8ytRv3nY7qDRAO9TJstpTX3nJQKETeSeL8LM1EFxoELByX16X3K8V799Ai6zIMKVfCiDPM/adho8rRQ7Cm9ozBQrFcmVscPYsLNzRekmxUAexpMqAYDLANORhE8SNwUAU9QovaogaF+p+E4hAtDg/sSZ1neXrOs6j5v5+bcQVNG2GQG9pMUVv1WNr/CDTA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Wed, 7 Jun 2017 17:08:23 +0300 Message-Id: <2ddc2703be89a250994478c92ca7695b4b88791b.1496844254.git.berto@igalia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: 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 v2 2/7] qcow2: Use unsigned int for both members of Qcow2COWRegion 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-block@nongnu.org, Max Reitz , Stefan Hajnoczi , "Denis V . Lunev" 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" Qcow2COWRegion has two attributes: - The offset of the COW region from the start of the first cluster touched by the I/O request. Since it's always going to be positive and the maximum request size is at most INT_MAX, we can use a regular unsigned int to store this offset. - The size of the COW region in bytes. This is guaranteed to be >=3D 0, so we should use an unsigned type instead. In x86_64 this reduces the size of Qcow2COWRegion from 16 to 8 bytes. It will also help keep some assertions simpler now that we know that there are no negative numbers. The prototype of do_perform_cow() is also updated to reflect these changes. Signed-off-by: Alberto Garcia Reviewed-by: Eric Blake --- block/qcow2-cluster.c | 4 ++-- block/qcow2.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index d1c419f52b..a86c5a75a9 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -406,8 +406,8 @@ int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t se= ctor_num, static int coroutine_fn do_perform_cow(BlockDriverState *bs, uint64_t src_cluster_offset, uint64_t cluster_offset, - int offset_in_cluster, - int bytes) + unsigned offset_in_cluster, + unsigned bytes) { BDRVQcow2State *s =3D bs->opaque; QEMUIOVector qiov; diff --git a/block/qcow2.h b/block/qcow2.h index 1801dc30dc..c26ee0a33d 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -301,10 +301,10 @@ typedef struct Qcow2COWRegion { * Offset of the COW region in bytes from the start of the first clust= er * touched by the request. */ - uint64_t offset; + unsigned offset; =20 /** Number of bytes to copy */ - int nb_bytes; + unsigned nb_bytes; } Qcow2COWRegion; =20 /** --=20 2.11.0