On 07/11/2012 07:35 AM, Daniel P. Berrange wrote: > From: "Daniel P. Berrange" <[email protected]> > > 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 [email protected] +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
