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

Re: [libvirt] [PATCHv2 3/5] qemu: Implement bulk stats API and one of the stats groups to return



On 08/26/14 21:02, Eric Blake wrote:
> On 08/26/2014 08:14 AM, Peter Krempa wrote:
>> Implement the API function for virDomainListGetStats and
>> virConnectGetAllDomainStats in a modular way and implement the
>> VIR_DOMAIN_STATS_STATE group of statistics.
>> ---
>>  src/qemu/qemu_driver.c | 175 +++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 175 insertions(+)
>>

> 
>> + cleanup:
>> +    if (dom)
>> +        virObjectUnlock(dom);
>> +
> 
> Useless if.  virObjectUnlock(NULL) is safe.  (Hmm, why isn't
> syntax-check catching it?)
> 

Actually not useless. virObjectUnlock should not be called with NULL.
This doesn't crash but spews warnings:

/**
 * virObjectUnlock:
 * @anyobj: any instance of virObjectLockablePtr
 *
 * Release a lock on @anyobj. The lock must have been
 * acquired by virObjectLock.
 */
void virObjectUnlock(void *anyobj)
{
    virObjectLockablePtr obj = anyobj;

    if (!virObjectIsClass(obj, virObjectLockableClass)) {
        VIR_WARN("Object %p (%s) is not a virObjectLockable instance",
                 obj, obj ? obj->parent.klass->name : "(unknown)");
        return;
    }

    virMutexUnlock(&obj->lock);
}


/**
 * virObjectIsClass:
 * @anyobj: any instance of virObjectPtr
 * @klass: the class to check
 *
 * Checks whether @anyobj is an instance of
 * @klass
 *
 * Returns true if @anyobj is an instance of @klass
 */
bool virObjectIsClass(void *anyobj,
                      virClassPtr klass)
{
    virObjectPtr obj = anyobj;
    if (!obj)
        return false;

    return virClassIsDerivedFrom(obj->klass, klass);
}


Peter

Attachment: signature.asc
Description: OpenPGP digital signature


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