[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
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCH v3 13/19] nbd/client: Split handshake into two functions, (continued)
- [Qemu-devel] [PATCH v3 09/19] nbd/client: Change signature of nbd_negotiate_simple_meta_context(), Eric Blake, 2019/01/12
- [Qemu-devel] [PATCH v3 15/19] nbd/client: Add nbd_receive_export_list(), Eric Blake, 2019/01/12
- [Qemu-devel] [PATCH v3 02/19] qemu-nbd: Enhance man page, Eric Blake, 2019/01/12
- [Qemu-devel] [PATCH v3 06/19] qemu-nbd: Avoid strtol open-coding, Eric Blake, 2019/01/12
- [Qemu-devel] [PATCH v3 18/19] nbd/client: Work around 3.0 bug for listing meta contexts, Eric Blake, 2019/01/12
[Qemu-devel] [PATCH v3 04/19] nbd/server: Hoist length check to qemp_nbd_server_add, Eric Blake, 2019/01/12