From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDKh2-0004qQ-CJ for qemu-devel@nongnu.org; Wed, 15 Jun 2016 19:57:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bDKgz-0005Id-0Q for qemu-devel@nongnu.org; Wed, 15 Jun 2016 19:57:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35595) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bDKgy-0005Hj-OD for qemu-devel@nongnu.org; Wed, 15 Jun 2016 19:57:52 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 B68B2C463B for ; Wed, 15 Jun 2016 23:57:51 +0000 (UTC) References: <1466023310-13221-1-git-send-email-armbru@redhat.com> <1466023310-13221-5-git-send-email-armbru@redhat.com> From: Eric Blake Message-ID: <5761EB7E.60605@redhat.com> Date: Wed, 15 Jun 2016 17:57:50 -0600 MIME-Version: 1.0 In-Reply-To: <1466023310-13221-5-git-send-email-armbru@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="96f1h5Otj8jSetXwIjnEUHNPhQkCRs5Rd" Subject: Re: [Qemu-devel] [PATCH RFC 4/4] range: Replace internal representation of Range List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster , qemu-devel@nongnu.org Cc: mst@redhat.com, pbonzini@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --96f1h5Otj8jSetXwIjnEUHNPhQkCRs5Rd Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/15/2016 02:41 PM, Markus Armbruster wrote: > Range represents a range as follows. Member @start is the inclusive > lower bound, member @end is the exclusive upper bound. Zero @end is > special: if @start is also zero, the range is empty, else @end is to > be interpreted as 2^64. No other empty ranges may occur. >=20 > The range [0,2^64-1] cannot be represented. If you try to create it > with range_set_bounds1(), you get the empty range instead. If you try > to create it with range_set_bounds() or range_extend(), assertions > fail. Before range_set_bounds() existed, the open-coded creation > usually got you the empty range instead. Open deathtrap. >=20 > Moreover, the code dealing with the janus-faced @end is too clever by > half. >=20 > Dumb this down to a more pedestrian representation: members @lob and > @upb are inclusive lower and upper bounds. The empty range is encoded > as @lob =3D 1, @upb =3D 0. And since all users now go through accessors, we've freed ourselves to change the underlying representation. >=20 > Signed-off-by: Markus Armbruster > --- > include/qemu/range.h | 55 +++++++++++++++++++++++++-------------------= -------- > util/range.c | 13 +++---------- > 2 files changed, 29 insertions(+), 39 deletions(-) Not only does it have more power, it takes fewer lines of code! > =20 > /* Compound literal encoding the empty range */ > -#define range_empty ((Range){ .begin =3D 0, .end =3D 0 }) > +#define range_empty ((Range){ .lob =3D 1, .upb =3D 0 }) well, one particular representation of the empty range, but the comment is fine as-is. Reviewed-by: Eric Blake --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --96f1h5Otj8jSetXwIjnEUHNPhQkCRs5Rd 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/ iQEcBAEBCAAGBQJXYet+AAoJEKeha0olJ0NqhiUH/1rkaW9CGoROc9WeKRqnPpHy 1HtqML1Tn9TuXPj5txaE0U/Qp/LhKQZ9mh6lMo/nxZ2Jx5oCwMIZTpubQoEtlL8I HcO3zR4T+JquScSSW7ClFJYtMFyHKIN2V0wmrtVoGF9pBsQOsIBTXuC8ffWsmz9F ofIu/JBNlA2OEAI9iUeMbrcAfnuuhBJIUJioX9aD1wyJGAMwxuLerdKDLvD3TBw5 aN9DCaNjE6tW3ibHEo+IqIul8Eyd2koEp+ZX7myKJL0Bu9pX14edHQ3hfCPWjU2I D9XqT5DaFUT0NC4QaIXH2Q4UCzNqpOUgSPk+DyOMOyDyebUMkrhftP5SMukDo80= =NPb9 -----END PGP SIGNATURE----- --96f1h5Otj8jSetXwIjnEUHNPhQkCRs5Rd--