[Spice-devel] [PATCH 1/2] server: factor out bitmap_fmt_is_rgb
Alon Levy
alevy at redhat.com
Mon Jul 16 09:23:16 PDT 2012
On Mon, Jul 16, 2012 at 11:40:51AM -0400, Marc-André Lureau wrote:
>
>
> ----- Mensaje original -----
> > ---
> > server/red_common.h | 11 +++++++++++
> > server/red_worker.c | 15 +++++++--------
> > 2 files changed, 18 insertions(+), 8 deletions(-)
> >
> > diff --git a/server/red_common.h b/server/red_common.h
> > index cb7bf71..b9dcd49 100644
> > --- a/server/red_common.h
> > +++ b/server/red_common.h
> > @@ -35,4 +35,15 @@ enum {
> > STREAM_VIDEO_FILTER
> > };
> >
> > +static inline int bitmap_fmt_is_rgb(uint8_t fmt)
> > +{
> > + static const int BITMAP_FMT_IS_RGB[] = {0, 0, 0, 0, 0, 0, 1, 1,
> > 1, 1};
> > +
> > + if (fmt >= SPICE_BITMAP_FMT_ENUM_END) {
> > + spice_warning("fmt >= SPICE_BITMAP_FMT_ENUM_END");
> > + return 0;
> > + }
> > + return BITMAP_FMT_IS_RGB[fmt];
> > +}
>
> It may still access over the array size. So I would either initialize the array with a fixed size of SPICE_BITMAP_FMT_ENUM_END (good thing imho), or add an additional array size check.
>
> ack otherwise.
ok, good idea, will do.
More information about the Spice-devel
mailing list