[libvirt] [PATCH] build: Don't use code with dbus_message_unref when built without dbus

Daniel P. Berrange berrange at redhat.com
Mon Apr 14 15:07:40 UTC 2014


On Mon, Apr 14, 2014 at 04:43:09PM +0200, Martin Kletzander wrote:
> diff --git a/src/util/virnodesuspend.c b/src/util/virnodesuspend.c
> index 59b84ef..60b86ee 100644
> --- a/src/util/virnodesuspend.c
> +++ b/src/util/virnodesuspend.c
> @@ -267,7 +268,14 @@ virNodeSuspendSupportsTargetPMUtils(unsigned int target, bool *supported)
>      virCommandFree(cmd);
>      return ret;
>  }
> -#endif
> +#else /* ! WITH_PM_UTILS */
> +static int
> +virNodeSuspendSupportsTargetPMUtils(unsigned int target ATTRIBUTE_UNUSED,
> +                                    bool *supported ATTRIBUTE_UNUSED)
> +{
> +    return -2;
> +}
> +#endif /* ! WITH_PM_UTILS */
> 
>  static int
>  virNodeSuspendSupportsTargetSystemd(unsigned int target, bool *supported)
> @@ -313,10 +321,16 @@ virNodeSuspendSupportsTarget(unsigned int target, bool *supported)
>      int ret;
> 
>      ret = virNodeSuspendSupportsTargetSystemd(target, supported);
> -#ifdef WITH_PM_UTILS
> -    if (ret < 0)
> +
> +    /* If just unavailable, try other options */
> +    if (ret == -2)
>          ret = virNodeSuspendSupportsTargetPMUtils(target, supported);
> -#endif
> +
> +    /* If still unavailable, then report error */
> +    if (ret == -2) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                       _("Cannot probe for supported suspend types"));

I think we shuld set 'ret = -1' at this point, since the caller
of this API doesn't need to know/care about this -1 vs -2
distinction.

> +    }
> 
>      return ret;
>  }
> diff --git a/src/util/virsystemd.c b/src/util/virsystemd.c
> index e9ca564..e67956f 100644
> --- a/src/util/virsystemd.c
> +++ b/src/util/virsystemd.c
> @@ -326,6 +326,7 @@ virSystemdNotifyStartup(void)
>  #endif
>  }
> 
> +#ifdef WITH_SYSTEMD_DAEMON
>  static int
>  virSystemdPMSupportTarget(const char *methodName, bool *result)
>  {
> @@ -369,6 +370,14 @@ virSystemdPMSupportTarget(const char *methodName, bool *result)
> 
>      return ret;
>  }
> +#else /* ! WITH_SYSTEMD_DAEMON */
> +static int
> +virSystemdPMSupportTarget(const char *methodName ATTRIBUTE_UNUSED,
> +                          bool *result ATTRIBUTE_UNUSED)
> +{
> +    return -2;
> +}
> +#endif /* ! WITH_SYSTEMD_DAEMON */
> 
>  int virSystemdCanSuspend(bool *result)
>  {

ACK with the small change above

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list