[libvirt] [PATCH 2/2] libxl: fix leaking libxl events

Eric Blake eblake at redhat.com
Thu May 16 19:56:52 UTC 2013


On 05/16/2013 10:01 AM, Jim Fehlig wrote:
> libxl expects the event handler to free the event passed to it.  From
> libxl_event.h:
> 
>    event becomes owned by the application and must be freed, either
>    by event_occurs or later
> ---
>  src/libxl/libxl_driver.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 

> @@ -764,6 +765,11 @@ cleanup:
>          libxlDomainEventQueue(driver, dom_event);
>          libxlDriverUnlock(driver);
>      }
> +#ifdef LIBXL_HAVE_NONCONST_EVENT_OCCURS_EVENT_ARG
> +    libxl_event_free(priv->ctx, event);
> +#else
> +    libxl_event_free(priv->ctx, (libxl_event *)event);
> +#endif

At least here your #ifdef isn't inside (), but it is inside a function
body.  Have I mentioned that I like my #ifdefs hoisted to the top level,
when possible? :)

Here, you could avoid the #ifdef, and just write:

/* cast away any const */
libxl_event_free(priv->ctx, (libxl_event *)event);

At any rate, ACK to your series, whether or not you clean up the #ifdefs.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130516/f7b58139/attachment-0001.sig>


More information about the libvir-list mailing list