[virt-tools-list] [PATCH virt-viewer] util: fix glib_check_version() condition

Marc-André Lureau mlureau at redhat.com
Wed Jun 11 15:54:31 UTC 2014



----- Original Message -----
> On Wed, Jun 11, 2014 at 05:21:59PM +0200, Marc-André Lureau wrote:
> > glib_check_version() returns NULL if version is higher or equal.
> > ---
> >  src/virt-viewer-util.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c
> > index c81c09a..6fdaa07 100644
> > --- a/src/virt-viewer-util.c
> > +++ b/src/virt-viewer-util.c
> > @@ -283,7 +283,7 @@ static void log_handler(const gchar *log_domain,
> >                          const gchar *message,
> >                          gpointer unused_data)
> >  {
> > -    if (!glib_check_version(2, 32, 0))
> > +    if (glib_check_version(2, 32, 0) != NULL)
> >          if (log_level >= G_LOG_LEVEL_DEBUG && !doDebug)
> >              return;
> 
> 
> Or maybe this?

Well, it's not like we are using a different API, so I prefer the dynamic version.

> 
> diff --git a/src/virt-viewer-util.c b/src/virt-viewer-util.c
> index c81c09a..06cbdfa 100644
> --- a/src/virt-viewer-util.c
> +++ b/src/virt-viewer-util.c
> @@ -278,17 +278,18 @@ gulong virt_viewer_signal_connect_object(gpointer
> instance
>      return ctx->handler_id;
>  }
>  
> +#if !GLIB_CHECK_VERSION(2, 32, 0)
>  static void log_handler(const gchar *log_domain,
>                          GLogLevelFlags log_level,
>                          const gchar *message,
>                          gpointer unused_data)
>  {
> -    if (!glib_check_version(2, 32, 0))
> -        if (log_level >= G_LOG_LEVEL_DEBUG && !doDebug)
> -            return;
> +    if (log_level >= G_LOG_LEVEL_DEBUG && !doDebug)
> +        return;
>  
>      g_log_default_handler(log_domain, log_level, message, unused_data);
>  }
> +#endif
>  
>  void virt_viewer_util_init(const char *appname)
>  {
> @@ -323,7 +324,9 @@ void virt_viewer_util_init(const char *appname)
>  
>      g_set_application_name(appname);
>  
> +#if !GLIB_CHECK_VERSION(2, 32, 0)
>      g_log_set_default_handler(log_handler, NULL);
> +#endif
>  }
>  
>  static gchar *
> 
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list




More information about the virt-tools-list mailing list