[Spice-devel] [PATCH spice-gtk] widget: Use parentheses around ternary conditional

Pavel Grunt pgrunt at redhat.com
Tue Mar 29 14:45:35 UTC 2016


On Tue, 2016-03-29 at 15:39 +0200, Victor Toso wrote:
> Hey,
> 
> Works fine! Thanks!
> 
> On Tue, Mar 29, 2016 at 03:03:03PM +0200, Pavel Grunt wrote:
> > 
> > "&&" has higher precedency than "?:"
> Maybe a small summary of the issue that his patch fixes?
> 
> > 
> > 
> > Fixes:
> > https://bugs.freedesktop.org/show_bug.cgi?id=94738
> > ---
> >  src/spice-widget.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/spice-widget.c b/src/spice-widget.c
> > index 21b1c14..67a9cc1 100644
> > --- a/src/spice-widget.c
> > +++ b/src/spice-widget.c
> > @@ -232,12 +232,11 @@ static void update_ready(SpiceDisplay
> > *display)
> >      SpiceDisplayPrivate *d = display->priv;
> >      gboolean ready;
> > 
> > -    ready = d->monitor_ready &&
> >  #ifndef G_OS_WIN32
> > -        d->egl.enabled ? d->egl.image != NULL :
> > +    ready = d->monitor_ready && (d->egl.enabled ? d->egl.image !=
> > NULL : d->mark != 0);
> > +#else
> > +    ready = d->monitor_ready && d->mark != 0;
> >  #endif
> > -        d->mark;
> I would go with something like
> 
>     gboolean ready = FALSE;
>     ...
>     if (d->monitor_ready) {
>     #ifndef G_OS_WIN32
>       ready = d->egl.enabled ? d->egl.image != NULL : d->mark != 0;
>     #else
>       ready = d->mark != 0;
>     #endif
>     }
> 
> But either way is fine (I'm not really picky with this things)
> 
> Acked-by: Victor Toso <victortoso at redhat.com>

I will go for your suggestion

Pavel

> 
> > 
> > -
> >      /* If the 'resize-guest' property is set, the application
> > expects spice-gtk
> >       * to manage the size and state of the displays, so update the
> > 'enabled'
> >       * state here. If 'resize-guest' is false, we can assume that
> > the


More information about the Spice-devel mailing list