[libvirt] [PATCH 06/13] Turn virDomainObjPtr into a virObjectPtr

Eric Blake eblake at redhat.com
Tue Jul 17 14:43:52 UTC 2012

On 07/11/2012 07:35 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> Switch virDomainObjPtr to use the virObject APIs for reference
> counting. The main change is that virObjectUnref does not return
> the reference count, merely a bool indicating whether the object
> still has any refs left. Checking the return value is also not
> mandatory.

This didn't apply cleanly for me, but I was able to get past the merge
conflict (I'm sure you'll hit and get past the same issues when you
rebase to latest).

> @@ -726,7 +741,7 @@ virDomainObjListDataFree(void *payload, const void *name ATTRIBUTE_UNUSED)
>  {
>      virDomainObjPtr obj = payload;
>      virDomainObjLock(obj);
> -    if (virDomainObjUnref(obj) > 0)
> +    if (!virObjectUnref(obj))
>          virDomainObjUnlock(obj);

Backwards logic.  You want to unlock if any other reference remains (a
true return), not if you were the last reference.

> @@ -13374,9 +13368,8 @@ static virDomainObjPtr virDomainLoadStatus(virCapsPtr caps,
>      return obj;
>  error:
> -    /* obj was never shared, so unref should return 0 */
>      if (obj)
> -        ignore_value(virDomainObjUnref(obj));
> +        virObjectUnref(obj);

virObjectUnref() gracefully handles a NULL input argument, so you can
get rid of the if.  In fact, it might be worth adding virObjectUnref()
to the list of free-like functions in cfg.mk, so our syntax-check will
automatically detect these cases.

Other than that, this looks okay.

Eric Blake   eblake at 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: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120717/42f21510/attachment-0001.sig>

More information about the libvir-list mailing list