From nobody Mon Feb 9 14:01:04 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 149553887136961.55449118775607; Tue, 23 May 2017 04:27:51 -0700 (PDT) Received: from localhost ([::1]:47805 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD7yf-0003DU-TQ for importer@patchew.org; Tue, 23 May 2017 07:27:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46666) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dD7ux-0000Aa-EH for qemu-devel@nongnu.org; Tue, 23 May 2017 07:24:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dD7us-0000Hi-HJ for qemu-devel@nongnu.org; Tue, 23 May 2017 07:23:59 -0400 Received: from fanzine.igalia.com ([91.117.99.155]:55466) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dD7us-00085H-0m; Tue, 23 May 2017 07:23:54 -0400 Received: from [192.168.13.244] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1dD7uD-0002iV-Qh; Tue, 23 May 2017 13:23:13 +0200 Received: from berto by perseus.local with local (Exim 4.89) (envelope-from ) id 1dD7uD-0005Li-Nv; Tue, 23 May 2017 14:23:13 +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=lXQbx2BlVVoyWSpbJ20Ay9p+5eJnM7NwbujpDRW5xt8=; b=i7ss5F9RRPVtLn/TUdNLwH2jk2zZAiO8+j+3Su6sNp4GvfydQaCdljkji8p+WDiiDLX10biTvEKG0HzFavHtIY22LwQH/y4iyVW5jQ9O2U4moQ8YQpREwiUvHcrzoyNH0Ii5Q8FM60bhyp0c/V/u0mVOh3A+JfBHHZi7rOt4azPVJDoKCcXv+4iiC48D6Rb0tbdxBLgw6tTbyfOk4fyVFp7kJV7zzTiUpkoitoIEcAzXUO3wh+zsyq8jn0F7UNfDVzY/EY2HRhD8WBleEGqKUhNWPtT8+8RxH1DYz/DqXnUmTUeqJqTZbLVDY4dq6C2dr6A7Gk8UamMF+RS5KNFNOA==; From: Alberto Garcia To: qemu-devel@nongnu.org Date: Tue, 23 May 2017 13:22:57 +0200 Message-Id: <95b03a81b53b6cd20c78112545072eb3c669c7d5.1495536228.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 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 --- 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 3dc170e421..6757875ec9 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