[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-trivial] [Qemu-devel] [PATCH 2/2] Check value for invalid nega
Re: [Qemu-trivial] [Qemu-devel] [PATCH 2/2] Check value for invalid negative values
Thu, 18 Jun 2015 06:45:52 -0400 (EDT)
> On Do, 2015-06-18 at 05:58 -0400, Frediano Ziglio wrote:
> > For the same reason there is the v >= l test.
> > The v >= l test state that the value can be out of range so it not always a
> > constant in the range.
> > Adding the v < 0 check for every invalid value. As these are executed only
> > for logging should not be a performance penalty.
> > I also hope the compiler is able to optimize
> > if (v < 0 || v >= l)
> > with
> > if ((unsigned) v >= l)
> Just make v explicitly unsigned?
Do you mean in the prototype? Well, this could have side effect due to
different conversions so is not a so trivial patch.
Explicitly casting to unsigned would do but is IMHO less easy to read that an
Re: [Qemu-trivial] [PATCH 1/2] Constify some variable, Michael Tokarev, 2015/06/17