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