Received: from eggs.gnu.org ([208.118.235.92]:36051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhMz5-0005bH-FW for qemu-devel@nongnu.org; Tue, 28 May 2013 12:43:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UhMyv-00087y-Hy for qemu-devel@nongnu.org; Tue, 28 May 2013 12:42:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8219) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UhMyv-00087o-AC for qemu-devel@nongnu.org; Tue, 28 May 2013 12:42:41 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4SGge5A021948 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 May 2013 12:42:40 -0400 Message-ID: <51A4DE7F.4070906@redhat.com> Date: Tue, 28 May 2013 10:42:39 -0600 From: Eric Blake MIME-Version: 1.0 References: <1369754856-30036-1-git-send-email-kwolf@redhat.com> <1369754856-30036-4-git-send-email-kwolf@redhat.com> In-Reply-To: <1369754856-30036-4-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="----enig2PLJSQGRUXVPLLTJDBNHJ" Subject: Re: [Qemu-devel] [PATCH 03/16] qemu-io: Make cvtnum() a wrapper around strtosz_suffix() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, lcapitulino@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2PLJSQGRUXVPLLTJDBNHJ Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 05/28/2013 09:27 AM, Kevin Wolf wrote: > No reason to implement the same thing multiple times. A nice side effec= t > is that fractional numbers like 0.5M can be used in qemu-io now. >=20 > Signed-off-by: Kevin Wolf > --- > cmd.c | 37 ------------------------------------- > cmd.h | 1 - > qemu-io.c | 6 ++++++ > 3 files changed, 6 insertions(+), 38 deletions(-) > - > - i =3D strtoll(s, &sp, 0); > - if (i =3D=3D 0 && sp =3D=3D s) > - return -1LL; > - if (*sp =3D=3D '\0') > - return i; Another nice side effect: you are also getting rid of poor handling that fails to check for errors after strtoll() (such as clamping at INT64_MAX on EOVERFLOW). On the other hand, strtosz_suffix uses strtod() which may inadvertently cause rounding of low-order bits of large input numbers (that is, parsing with only 53 significant bits instead of 64 may cause us to round a value that was previously exact); but I'd rather deal with consistent behavior even if it rounds some values, than question which of multiple slightly different implementations will be parsing my values (we can also argue that perhaps strtosz_suffix could be improved to guarantee 64 bits of precision if there is no '.' in the value being parsed, while still providing the flexibility of 0.5G parsing when precision isn't important). Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org ------enig2PLJSQGRUXVPLLTJDBNHJ 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.4.13 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJRpN5/AAoJEKeha0olJ0NqUFsH/jeSXIx3OjZyUS7luZipDGOc SELofPVYQBxQOANgsX1ZyQkD9tdlbdQM5F+ZjCeQmVrdA/I5POKsn2J4J6IeFm8g o3sRaLzgMvITA1EsNqxdEv0x0GdOvFZELCAoGpBL/xnrbM8aP6PBZHnwsXJ332kQ Hq2sf78kj5bWCfx+woCWTGdWUwrQ/CVmEYD5xytqBvi2buIYdKvS1so2tbtulw19 J6rwg3Fx9aLfT5rpJvXuimlqXrPQGnmjs0lWBAI3y3xe0sq3qyC/Wl+aaP7YzdcD GG3g6BFJEbPLLvhuHdN6BnxOIeFzwwGCMgBhKVZJnTPJn7xAL05n1LdbNvwtiKM= =KL4P -----END PGP SIGNATURE----- ------enig2PLJSQGRUXVPLLTJDBNHJ--