qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 3/3] qapi: Fix memleak in string visitors on


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v2 3/3] qapi: Fix memleak in string visitors on int lists
Date: Tue, 14 Jun 2016 19:53:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Markus Armbruster <address@hidden> writes:

[...]
> I find the comments in range.h terminally confusing.
>
> The clear parts:
>
> * we want to have inclusive lower bound <= inclusive upper bound (no
>   wrap around), and
>
> * we want to encode the bounds using @start as inclusive lower bound,
>   and @end as exclusive upper bound.
>
> This begs the question how end == 0 is to be interpreted.  Options:
>
> (1) It's literally the exclusive upper bound.  An interval with a
> non-negative inclusive lower bound and a zero exclusive upper bound is
> empty.  There is no way to represent the inclusive upper bound 2^63-1.
> This contradicts the comment's claim that you can.
>
> (2) It's 2^64.  Now you cannot represent the inclusive upper bound -1.
> You cannot represent the empty interval [0,-1], although you can
> represent other empty intervals [b,b-1], b>0.  { start = 0, end = 0 }
> encodes the interval [0,2^64-1].  Contradicts the comment's claim that
> you can't, unless...
>
> (2') end=0 is special-cased to mean something else when start=0!  Namely
> 0 instead of 2^64, so that { start=0, end=0 } becomes the empty interval
> [0,-1].
>
> The tradeoff between (2) and (2') is between two anomalies: "can't do
> [0,-1]", and "can't do [0..2^64-1]".
>
> I prefer (2), because I find the former anomaly less bad, and feel
> special-casing @end is bound to lead to bugs.
>
> Whatever option we choose, we should fix the comment to explain it
> clearly.

Unless somebody has better ideas, I'll cook up a patch documenting (2')
and make code conform to it (in case there is code that doesn't).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]