Re: [PATCH 06/13] Turn virDomainObjPtr into a virObjectPtr

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

 



On 07/11/2012 07:35 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>
> 
> 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@xxxxxxxxxx    +1-919-301-3266
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]