From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: mst@redhat.com, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH RFC 4/4] range: Replace internal representation of Range
Date: Wed, 15 Jun 2016 17:57:50 -0600 [thread overview]
Message-ID: <5761EB7E.60605@redhat.com> (raw)
In-Reply-To: <1466023310-13221-5-git-send-email-armbru@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1792 bytes --]
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.
>
> 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.
>
> Moreover, the code dealing with the janus-faced @end is too clever by
> half.
>
> 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 = 1, @upb = 0.
And since all users now go through accessors, we've freed ourselves to
change the underlying representation.
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> 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!
>
> /* Compound literal encoding the empty range */
> -#define range_empty ((Range){ .begin = 0, .end = 0 })
> +#define range_empty ((Range){ .lob = 1, .upb = 0 })
well, one particular representation of the empty range, but the comment
is fine as-is.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-06-15 23:57 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 20:41 [Qemu-devel] [PATCH RFC 0/4] range: Make it simpler & safer Markus Armbruster
2016-06-15 20:41 ` [Qemu-devel] [PATCH RFC 1/4] log: Clean up misuse of Range for -dfilter Markus Armbruster
2016-06-15 23:30 ` Eric Blake
2016-06-19 3:24 ` Michael S. Tsirkin
2016-06-15 20:41 ` [Qemu-devel] [PATCH RFC 2/4] range: Eliminate direct Range member access Markus Armbruster
2016-06-15 23:50 ` Eric Blake
2016-06-16 7:50 ` Markus Armbruster
2016-06-19 3:25 ` Michael S. Tsirkin
2016-06-20 7:26 ` Markus Armbruster
2016-06-15 20:41 ` [Qemu-devel] [PATCH RFC 3/4] range: Drop the previous commit's trickery Markus Armbruster
2016-06-15 23:53 ` Eric Blake
2016-06-19 3:28 ` Michael S. Tsirkin
2016-06-20 7:28 ` Markus Armbruster
2016-06-15 20:41 ` [Qemu-devel] [PATCH RFC 4/4] range: Replace internal representation of Range Markus Armbruster
2016-06-15 23:57 ` Eric Blake [this message]
2016-06-16 8:04 ` Markus Armbruster
2016-06-19 3:24 ` Michael S. Tsirkin
2016-06-20 7:33 ` Markus Armbruster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5761EB7E.60605@redhat.com \
--to=eblake@redhat.com \
--cc=armbru@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.