From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zw5at-000892-MW for qemu-devel@nongnu.org; Tue, 10 Nov 2015 04:52:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zw5at-0003rh-0M for qemu-devel@nongnu.org; Tue, 10 Nov 2015 04:52:03 -0500 References: <1447059810-11376-1-git-send-email-arei.gonglei@huawei.com> <20151109135722.GB27221@stefanha-x1.localdomain> <56419027.8090509@huawei.com> From: Paolo Bonzini Message-ID: <5641BE3A.4020504@redhat.com> Date: Tue, 10 Nov 2015 10:51:54 +0100 MIME-Version: 1.0 In-Reply-To: <56419027.8090509@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v3] virtio-blk: trivial code optimization List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gonglei , Stefan Hajnoczi Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org On 10/11/2015 07:35, Gonglei wrote: >> > nb_sectors - int >> > max_xfer_len - int >> > req->qiov.size - size_t >> > BDRV_SECTOR_SIZE - unsigned long long >> > >> > Therefore this expression is an int > unsigned long long comparison. >> > > Sorry, I'm confused. > max_xfer_len is int, > "req->qiov.size / BDRV_SECTOR_SIZE" is unsigned long long, > so, "max_xfer_len - req->qiov.size / BDRV_SECTOR_SIZE" will be int, No, the result will be unsigned long long, and the comparison is wrong if max_xfer_len < req->qiov.size / BDRV_SECTOR_SIZE. Paolo > and nb_sectors is int too, so this comparison is right. Am I wrong? >