From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55209) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx1CL-00086p-6n for qemu-devel@nongnu.org; Tue, 17 Jun 2014 17:45:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wx1CG-0006zB-IR for qemu-devel@nongnu.org; Tue, 17 Jun 2014 17:45:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41899) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wx1CG-0006yx-6z for qemu-devel@nongnu.org; Tue, 17 Jun 2014 17:45:40 -0400 Message-ID: <53A0B6F9.60306@redhat.com> Date: Tue, 17 Jun 2014 15:45:29 -0600 From: Eric Blake MIME-Version: 1.0 References: <1403021756-15960-1-git-send-email-mst@redhat.com> <1403021756-15960-93-git-send-email-mst@redhat.com> In-Reply-To: <1403021756-15960-93-git-send-email-mst@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="eCU86ewQnkw4tRUOPGgQLOWpVUoJWim43" Subject: Re: [Qemu-devel] [PULL 092/103] qapi: make string output visitor parse int list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Cc: Peter Maydell , Hu Tao , Michael Roth , Luiz Capitulino , Anthony Liguori , =?UTF-8?B?QW5kcmVhcyBGw6RyYmVy?= , Markus Armbruster This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --eCU86ewQnkw4tRUOPGgQLOWpVUoJWim43 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/17/2014 11:41 AM, Michael S. Tsirkin wrote: > From: Hu Tao >=20 > Signed-off-by: Hu Tao > Acked-by: Michael S. Tsirkin > Tested-by: Michael S. Tsirkin > Signed-off-by: Michael S. Tsirkin >=20 > MST: split up patch > --- > qapi/string-output-visitor.c | 229 +++++++++++++++++++++++++++++= ++++++-- > tests/test-string-output-visitor.c | 38 +++++- > 2 files changed, 255 insertions(+), 12 deletions(-) >=20 > + > + l =3D sov->ranges; > + while (l) { > + Range *r =3D l->data; > + format_string(sov, r, l->next !=3D NULL, false); > + l =3D l->next; > + } > =20 > if (sov->human) { > - out =3D g_strdup_printf("%lld (%#llx)", (long long) *obj, (lon= g long) *obj); > - } else { > - out =3D g_strdup_printf("%lld", (long long) *obj); > + l =3D sov->ranges; > + g_string_append(sov->string, " ("); > + while (l) { > + Range *r =3D l->data; > + format_string(sov, r, l->next !=3D NULL, false); Am I reading this correctly that in human mode, you are creating the stri= ng: 16-31 (16-31) instead of 16-17 (10-1f) because you forgot to pass 'true' as the human parameter on one of the two calls to format_string? Also, this is a worsening of quality; the old code would produce 16 (0x10) to make it obvious which number was hex. > +static void test_visitor_out_intList(TestOutputVisitorData *data, > + const void *unused) > +{ > + int64_t value[] =3D {0, 1, 9, 10, 16, 15, 14, > + 3, 4, 5, 6, 11, 12, 13, 21, 22, INT64_MAX - 1, INT64_MAX}; No test of negative numbers? > + str =3D string_output_get_string(data->sov); > + g_assert(str !=3D NULL); > + g_assert_cmpstr(str, =3D=3D, > + "0-1,3-6,9-16,21-22,9223372036854775806-9223372036854775807");= Shouldn't you also test the human output? Probably worth a followup patch. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --eCU86ewQnkw4tRUOPGgQLOWpVUoJWim43 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 Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJToLb5AAoJEKeha0olJ0NqhJ0H/Rt2ny1t09ftw4Q24+3s+Xow qBOekvXoODs1IRuvRAdpKp85xKIZy5sos2itEdfrQ8bGI10S+zR1dK84uIdlNbvj uYw+jQ88yMCQfFx6nY9q2KzvVXWz81ZaolfPHih7g7s+t8syVeaHB4DGPNoonwG0 02Jp7JqzewMp1R+/GCNY/Qy9Sb9U6Fsm/jriPkqwzz1K0LQTQesPgCymbDdTdpF1 qTdQ8TkEIRt8dmAtp6So/PhkXbm+/RUOxFmcZH8V/wZDjr9pE4AOVnfzDnS07C3u tAhu4byNoC8yK8hapIxRJ5Bx10e9O6OThFXo14oarMdKRuwOCwE6RGdCWsd8SLY= =gO4m -----END PGP SIGNATURE----- --eCU86ewQnkw4tRUOPGgQLOWpVUoJWim43--