int virMutexInit(virMutexPtr m)
{
- if (pthread_mutex_init(&m->lock, NULL) != 0) {
- errno = EINVAL;
+ int ret;
+ if ((ret = pthread_mutex_init(&m->lock, NULL)) != 0) {
+ errno = ret;
return -1;
}
return 0;
}
-
int virCondInit(virCondPtr c)
{
- if (pthread_cond_init(&c->cond, NULL) != 0) {
- errno = EINVAL;
+ int ret;
+ if ((ret = pthread_cond_init(&c->cond, NULL)) != 0) {
+ errno = ret;
return -1;
}
return 0;
int virCondDestroy(virCondPtr c)
{
- if (pthread_cond_destroy(&c->cond) != 0) {
- errno = EINVAL;
+ int ret;
+ if ((ret = pthread_cond_destroy(&c->cond)) != 0) {
+ errno = ret;
return -1;
}
return 0;
int virCondWait(virCondPtr c, virMutexPtr m)
{
- if (pthread_cond_wait(&c->cond, &m->lock) != 0) {
- errno = EINVAL;
+ int ret;
+ if ((ret = pthread_cond_wait(&c->cond, &m->lock)) != 0) {
+ errno = ret;
return -1;
}
return 0;
int virThreadLocalInit(virThreadLocalPtr l,
virThreadLocalCleanup c)
{
- if (pthread_key_create(&l->key, c) != 0) {
- errno = EINVAL;
+ int ret;
+ if ((ret = pthread_key_create(&l->key, c)) != 0) {
+ errno = ret;
return -1;
}
return 0;