From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42494) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOuZT-0004YY-Oh for qemu-devel@nongnu.org; Tue, 02 Sep 2014 16:21:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XOuZK-0003kj-QJ for qemu-devel@nongnu.org; Tue, 02 Sep 2014 16:20:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57905) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XOuZK-0003ke-Gz for qemu-devel@nongnu.org; Tue, 02 Sep 2014 16:20:46 -0400 Message-ID: <54062690.6070508@redhat.com> Date: Tue, 02 Sep 2014 14:20:32 -0600 From: Eric Blake MIME-Version: 1.0 References: <1409671532-12706-1-git-send-email-david.marchand@6wind.com> <1409671532-12706-2-git-send-email-david.marchand@6wind.com> In-Reply-To: <1409671532-12706-2-git-send-email-david.marchand@6wind.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WK0fpEK0UoCCuP3ENgNQo6cIV7XLVBlcF" Subject: Re: [Qemu-devel] [PATCH v4 01/14] contrib: add ivshmem client and server List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Marchand , qemu-devel@nongnu.org Cc: Olivier Matz , kvm@vger.kernel.org, stefanha@gmail.com, claudio.fontana@huawei.com, armbru@redhat.com, arei.gonglei@huawei.com, pbonzini@redhat.com, jani.kokkonen@huawei.com, cam@cs.ualberta.ca This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WK0fpEK0UoCCuP3ENgNQo6cIV7XLVBlcF Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 documentati= on). > The client is provided as a debug tool. >=20 > Signed-off-by: Olivier Matz > Signed-off-by: David Marchand > --- > +/* parse the size of shm */ > +static int > +parse_size(const char *val_str, size_t *val) > +{ > + char *endptr; > + unsigned long long tmp; > + > + errno =3D 0; > + tmp =3D strtoull(val_str, &endptr, 0); > + if ((errno =3D=3D ERANGE && tmp =3D=3D ULLONG_MAX) || (errno !=3D = 0 && tmp =3D=3D 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 =3D 0; > + tmp =3D strtoul(val_str, &endptr, 0); > + if ((errno =3D=3D ERANGE && tmp =3D=3D ULONG_MAX) || (errno !=3D 0= && tmp =3D=3D 0)) { > + return -1; > + } and again > + if (endptr =3D=3D val_str || endptr[0] !=3D '\0') { > + return -1; > + } > + *val =3D tmp; > + return 0; > +} --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --WK0fpEK0UoCCuP3ENgNQo6cIV7XLVBlcF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg iQEcBAEBCAAGBQJUBiaQAAoJEKeha0olJ0NqhpsIAI/igPRosQrUbd22EXTVbRNB IX6mKoaxOV1Gyr9OiJoC2LxFS1C9MzF6cdD/3WTMeaVhvVP/0DyjReGBse98EucV rdAk1M/JKK3vTowvGPAQb0AbVDgXuCJBLvQkE7hP6lCTYR46jFrTuIx5f5A50/W5 VTB3Nz3Bw6AjXK/486aco9UTHenm7jeuFLCu7uwE/CwLmYYWMRHQsHG+1+YcJQI2 tbT63lx39YFxbAgeQXP/zS5ULUaThM6NNcL7J/g7Kxg/kxQ/s3mmKzedcIBfggaS T/jJVpyRI4b2CQpc8MuePQHLD3aZ0cTt0xrFoGNV3tpWHvxCoas+jVIYE/yJ+XU= =yjek -----END PGP SIGNATURE----- --WK0fpEK0UoCCuP3ENgNQo6cIV7XLVBlcF--