qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 06/19] qemu-nbd: Avoid strtol open-coding


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v3 06/19] qemu-nbd: Avoid strtol open-coding
Date: Tue, 15 Jan 2019 09:35:14 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0

On 1/15/19 6:31 AM, Vladimir Sementsov-Ogievskiy wrote:
> 12.01.2019 20:57, Eric Blake wrote:
>> Our copy-and-pasted open-coding of strtol handling forgot to
>> handle overflow conditions.  Use qemu_strto*() instead.
>>
>> In the case of --partition, since we insist on a user-supplied
>> partition to be non-zero, we can use 0 rather than -1 for our
>> initial value to distinguish when a partition is not being
>> served, for slightly more optimal code.
>>
>> The error messages for out-of-bounds values are less specific,
>> but should not be a terrible loss in quality.
>>
>> Signed-off-by: Eric Blake <address@hidden>
>> Message-Id: <address@hidden>
>>

>> -            if (partition < 1 || partition > 8) {
>> -                error_report("Invalid partition %d", partition);
>> +            if (qemu_strtoi(optarg, NULL, 0, &partition) < 0 ||
> 
> we can use unsigned conversion like for offset (and unsigned type for 
> partition), but this doesn't really matter.

Yes, but I didn't see the point in changing the variable types in this
patch.

> 
> anyway,
> Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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