qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] xen_disk: convert discard input to byte ranges


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH] xen_disk: convert discard input to byte ranges
Date: Tue, 22 Nov 2016 11:11:10 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0

On 11/22/2016 11:00 AM, Olaf Hering wrote:
> On Tue, Nov 22, Eric Blake wrote:
> 
>> if (sec_start + sec_count < sec_count ||
>>     sec_start > (INT64_MAX >> BDRV_SECTOR_BITS) - sec_count) {
>>     return false;
>> }
> 
> My point was: how does this handle sec_start=0,sec_count=UINT64_MAX or
> sec_start=INT64_MAX,sec_count=INT64_MAX? For me this gets past the if().

Fair enough.  Your test that things didn't overflow means that you can
then safely compare the sum to the limit, so go with:

if (sec_start + sec_count < sec_count ||
    sec_start + sec_count > INT64_MAX >> BDRV_SECTOR_BITS) {
    return false;
}

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]