[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 05/14] Sanitize virDiscoverHostPMFeature to return a boolean



On 11/29/2011 09:14 PM, Daniel P. Berrange wrote:

> From: "Daniel P. Berrange" <berrange redhat com>

>  cleanup:
> @@ -2691,23 +2690,30 @@ int
>  virGetPMCapabilities(unsigned int *bitmask)
>  {
>      int ret;


The variable 'ret' is unnecessary in this function. So we can probably
remove it, to do further cleanup.

> +    bool supported;
> 
>      *bitmask = 0;
> 
>      /* Check support for Suspend-to-RAM (S3) */
> -    ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_MEM);
> +    ret = virDiscoverHostPMFeature(VIR_NODE_SUSPEND_TARGET_MEM, &supported);
>      if (ret < 0)
>          return -1;
> +    if (supported)
> +        *bitmask |= (1 << VIR_NODE_SUSPEND_TARGET_MEM);
> 
>      /* Check support for Suspend-to-Disk (S4) */
> -    ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_DISK);
> +    ret = virDiscoverHostPMFeature(VIR_NODE_SUSPEND_TARGET_DISK, &supported);
>      if (ret < 0)
>          return -1;
> +    if (supported)
> +        *bitmask |= (1 << VIR_NODE_SUSPEND_TARGET_DISK);
> 
>      /* Check support for Hybrid-Suspend */
> -    ret = virDiscoverHostPMFeature(bitmask, VIR_NODE_SUSPEND_TARGET_HYBRID);
> +    ret = virDiscoverHostPMFeature(VIR_NODE_SUSPEND_TARGET_HYBRID, &supported);
>      if (ret < 0)
>          return -1;
> +    if (supported)
> +        *bitmask |= (1 << VIR_NODE_SUSPEND_TARGET_HYBRID);
> 
>      return 0;
>  }
> diff --git a/src/util/util.h b/src/util/util.h
> index 204e2b9..6a9de7e 100644
> --- a/src/util/util.h
> +++ b/src/util/util.h
> @@ -263,7 +263,7 @@ void virTypedParameterArrayClear(virTypedParameterPtr params, int nparams);
> 
>  /* Power Management Capabilities of the host system */
> 
> -int virDiscoverHostPMFeature(unsigned int *bitmask, unsigned int feature);
> +int virDiscoverHostPMFeature(unsigned int feature, bool *supported);
>  int virGetPMCapabilities(unsigned int *bitmask);
> 
>  #endif /* __VIR_UTIL_H__ */



-- 
Regards,
Srivatsa S. Bhat
IBM Linux Technology Center


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]