[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
From: |
Frediano Ziglio |
Subject: |
Re: [Qemu-trivial] [Qemu-devel] [PATCH 2/2] Check value for invalid negative values |
Date: |
Thu, 18 Jun 2015 05:58:56 -0400 (EDT) |
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)
Frediano
>
> 11.06.2015 16:17, Frediano Ziglio wrote:
> > In qxl_v2n check that value is not negative.
>
> Why do you think it is necessary?
>
> Thanks,
>
> /mjt
>
> > Signed-off-by: Frediano Ziglio <address@hidden>
> > ---
> > hw/display/qxl-logger.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/display/qxl-logger.c b/hw/display/qxl-logger.c
> > index d944d3f..faed869 100644
> > --- a/hw/display/qxl-logger.c
> > +++ b/hw/display/qxl-logger.c
> > @@ -93,7 +93,7 @@ static const char *const spice_cursor_type[] = {
> >
> > static const char *qxl_v2n(const char *const n[], size_t l, int v)
> > {
> > - if (v >= l || !n[v]) {
> > + if (v < 0 || v >= l || !n[v]) {
> > return "???";
> > }
> > return n[v];
>
>
>
>
Re: [Qemu-trivial] [PATCH 1/2] Constify some variable, Michael Tokarev, 2015/06/17