qemu-devel
[Top][All Lists]
Advanced

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

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


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH v4 01/14] contrib: add ivshmem client and server
Date: Tue, 02 Sep 2014 14:20:32 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.7.0

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 <address@hidden>
> Signed-off-by: David Marchand <address@hidden>
> ---

> +/* 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


reply via email to

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