Re: [PATCH v2 1/4] Add a read/write lock implementation

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

 



On 01/27/2014 10:18 AM, Daniel P. Berrange wrote:
> Add virRWLock backed up by a POSIX rwlock primitive
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---

> +int virRWLockInit(virRWLockPtr m)
> +{
> +    if (pthread_rwlock_init(&m->lock, NULL) != 0) {
> +        errno = EINVAL;
> +        return -1;

My concern from v1 still stands - this blindly overwrites non-EINVAL
errors, and better would be:

int rc = pthread_rwlock_init(&m->lock, NULL);
if (rc) {
    errno = rc;
    return -1;
}


> +void virRWLockDestroy(virRWLockPtr m)
> +{
> +    pthread_rwlock_destroy(&m->lock);

Likewise, it might be nice to add VIR_DEBUG messages when discarding a
non-zero result, as a way to diagnose the programmer errors that caused
that situation.

-- 
Eric Blake   eblake redhat com    +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]