Re: [PATCH v4 01/14] contrib: add ivshmem client and server

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

 



On 09/02/2014 09:25 AM, David Marchand wrote:
> When using ivshmem devices, notifications between guests can be sent as
> interrupts using a ivshmem-server (typical use described in documentation).
> The client is provided as a debug tool.
> 
> Signed-off-by: Olivier Matz <olivier.matz@xxxxxxxxx>
> Signed-off-by: David Marchand <david.marchand@xxxxxxxxx>
> ---

> +/* parse the size of shm */
> +static int
> +parse_size(const char *val_str, size_t *val)
> +{
> +    char *endptr;
> +    unsigned long long tmp;
> +
> +    errno = 0;
> +    tmp = strtoull(val_str, &endptr, 0);
> +    if ((errno == ERANGE && tmp == ULLONG_MAX) || (errno != 0 && tmp == 0)) {
> +        return -1;
> +    }

This is overly complex; usually, this is just done as:

if (errno)
    return -1;

> +/* parse an unsigned int */
> +static int
> +parse_uint(const char *val_str, unsigned *val)
> +{
> +    char *endptr;
> +    unsigned long tmp;
> +
> +    errno = 0;
> +    tmp = strtoul(val_str, &endptr, 0);
> +    if ((errno == ERANGE && tmp == ULONG_MAX) || (errno != 0 && tmp == 0)) {
> +        return -1;
> +    }

and again

> +    if (endptr == val_str || endptr[0] != '\0') {
> +        return -1;
> +    }
> +    *val = tmp;
> +    return 0;
> +}

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

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux