From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8UCk-0007om-1v for qemu-devel@nongnu.org; Thu, 02 Jun 2016 11:06:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8UCe-0003uD-Kd for qemu-devel@nongnu.org; Thu, 02 Jun 2016 11:06:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49021) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8UCe-0003u9-Bg for qemu-devel@nongnu.org; Thu, 02 Jun 2016 11:06:32 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 952888F01E for ; Thu, 2 Jun 2016 15:06:31 +0000 (UTC) References: <1463632874-28559-1-git-send-email-eblake@redhat.com> <1463632874-28559-18-git-send-email-eblake@redhat.com> <8737oveirs.fsf@dusky.pond.sub.org> From: Eric Blake Message-ID: <57504B76.7040309@redhat.com> Date: Thu, 2 Jun 2016 09:06:30 -0600 MIME-Version: 1.0 In-Reply-To: <8737oveirs.fsf@dusky.pond.sub.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="FqKnpKXLjVGVDQNcDdTmsdLUb6rUXE3f7" Subject: Re: [Qemu-devel] [PATCH v4 17/28] qapi: Factor out JSON number formatting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org, Luiz Capitulino This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --FqKnpKXLjVGVDQNcDdTmsdLUb6rUXE3f7 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/02/2016 09:02 AM, Markus Armbruster wrote: > Eric Blake writes: >=20 >> Pull out a new qstring_append_json_number() helper, so that all >> JSON output producers can use a consistent style for printing >> floating point without duplicating code (since we are doing more >> data massaging than a simple printf format can handle). (For >> now, there is only one client, but later patches will use it.) >> >> Adding a return value will let callers that care diagnose the >> situation where an attempt was made to output invalid JSON (which >> does not specify Infinity or NaN). None of the current callers >> care, but a future patch wants to make it possible to turn this >> situation into an error. >=20 > Suggest: >=20 > * Return 0 if the number is finite, as required by RFC 7159, else -1. >=20 > The return value makes some sense only for symmetry with > qstring_append_json_string(). Without that, I'd ask you to keep this > function simple. Callers could just as easily test isfinite() > themselves. I'm actually thinking of modifying this, given the recent thread pointing out that libvirt chokes hard on JSON extensions: https://lists.gnu.org/archive/html/qemu-devel/2016-05/msg04398.html That is, for symmetry with qstring_append_json_string(), I'm thinking of changing NaN to 0 and Inf to DBL_MAX, and always outputting a finite value, in addition to returning -1 to inform the caller that a substitution was made, so that the output is always strict JSON. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --FqKnpKXLjVGVDQNcDdTmsdLUb6rUXE3f7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXUEt2AAoJEKeha0olJ0Nqc4kH/0J03ccecriTYHCapz/og+N8 zYI/Rl9sDxu5U+wvOFJIjSaqgezTLLxq4Ya4whKHbBFWszXz3d+uZB+x+wu2GJaP yKI/ansckM7xwnY49aWDbWhfBzJjzd83lIDFtz1g2rykKOMYZ1NYExb2Vxg3scc/ F8VVB6uLxCkT0Z41SVw1QY9KUwgP5isPVWB9GcgBT6FeZEppl8Ng3ES/0o/N7BuX 8zOgqnWOI3nB3+icOeP4QmPIc6+X64IDNiAkAu6+DT0tqCpRAD+Up2+xf9hgujnN G8XA0JkgJqMev1yoL6IX06YzQdCM0Kmj4fgK6Q1eiouCt00v6GWUsr0dR8FNpLA= =Uh1S -----END PGP SIGNATURE----- --FqKnpKXLjVGVDQNcDdTmsdLUb6rUXE3f7--