Re: [libvirt] [PATCH v2 2/2] Use virCheckFlags for APIs added in 0.8.0

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

 



On 04/13/2010 10:25 AM, Jiri Denemark wrote:
> ---
>  src/esx/esx_driver.c           |   43 ++++++++++++-------------
>  src/nwfilter/nwfilter_driver.c |    4 ++-
>  src/qemu/qemu_driver.c         |   68 +++++++++++++++++++---------------------
>  src/storage/storage_driver.c   |    6 +---
>  src/vbox/vbox_tmpl.c           |   41 ++++++++++++++++-------
>  src/xen/xend_internal.c        |    4 ++
>  6 files changed, 88 insertions(+), 78 deletions(-)
> 
> diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
> index 4ed9890..d9a1cfd 100644
> --- a/src/esx/esx_driver.c
> +++ b/src/esx/esx_driver.c
> @@ -3296,7 +3296,7 @@ esxDomainIsPersistent(virDomainPtr domain ATTRIBUTE_UNUSED)
>  
>  static virDomainSnapshotPtr
>  esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
> -                           unsigned int flags ATTRIBUTE_UNUSED)
> +                           unsigned int flags)
>  {
>      esxPrivate *priv = domain->conn->privateData;
>      virDomainSnapshotDefPtr def = NULL;
> @@ -3308,6 +3308,8 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
>      esxVI_TaskInfoState taskInfoState;
>      virDomainSnapshotPtr snapshot = NULL;
>  
> +    virCheckFlags(0, NULL);

I scanned through the patch, and didn't see any instances where we are
calling virCheckFlags after non-trivial work.  It is something to be
aware of when using the macro in the future, since:

{
    ptr *foo = somethingThatMallocs();
    virCheckFlags(0, NULL);

would be a memory leak, masked because the return is hidden inside the
virCheckFlags macro.

But the alternative, of making virCheckFlags result in a bool, and
making all callers use:

    if (virBadFlags(0))
        return NULL;

is not as aesthetic.  So:

ACK.

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]