[Spice-devel] [PATCH spice-gtk v2 4/8] display: return NULL in spice_display_get_gl_scanout()

Marc-André Lureau mlureau at redhat.com
Wed Mar 23 23:39:33 UTC 2016


Hi

----- Original Message -----
> Hi Marc-André,
> 
> On Tue, 2016-03-22 at 13:57 +0100, Marc-André Lureau wrote:
> > If there is no valid scanout, return NULL.
> 
> When / how it can happen ? Looking at gl_scanout() there is g_return if
> scanout == NULL, if NULL is a valid/expected return value then that
> g_return should be changed.

Good point. AI think I wrote this initially thinking that no one should ever call get_gl_scanout() without having first received the scanout notification, but that assumption is wrong. It should be fine to call get_gl_scanout() and it's easier to deal with a NULL return value rather than checking the returned scanout.fd == -1.  I'll change the assert. (btw, the set_static_boxed for the property should be fine)

> 
> Pavel
> > 
> > Signed-off-by: Marc-André Lureau <marcandre.lureau at gmail.com>
> > ---
> >  src/channel-display.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/channel-display.c b/src/channel-display.c
> > index 2c54df7..90d155e 100644
> > --- a/src/channel-display.c
> > +++ b/src/channel-display.c
> > @@ -532,7 +532,7 @@ void
> > spice_display_change_preferred_compression(SpiceChannel *channel,
> > gint comp
> >   * spice_display_get_gl_scanout:
> >   * @channel: a #SpiceDisplayChannel
> >   *
> > - * Returns: the current GL scanout
> > + * Returns: the current GL scanout, or %NULL if none or not valid
> >   *
> >   * Since: 0.31
> >   **/
> > @@ -541,7 +541,7 @@ spice_display_get_gl_scanout(SpiceDisplayChannel
> > *channel)
> >  {
> >      g_return_val_if_fail(SPICE_IS_DISPLAY_CHANNEL(channel), NULL);
> >  
> > -    return &channel->priv->scanout;
> > +    return channel->priv->scanout.fd != -1 ? &channel->priv->scanout
> > : NULL;
> >  }
> >  
> >  /* ---------------------------------------------------------------
> > --- */
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
> 


More information about the Spice-devel mailing list