Re: [libvirt] [PATCH 02/15] Fix errno handling for pthreads wrappers

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

 



On Tue, Nov 03, 2009 at 02:49:56PM -0500, Daniel P. Berrange wrote:
> * src/util/threads-pthread.c: pthreads APIs do not set errno, instead
>   the return value is the positive errno. Set errno based on the return
>   value in the wrappers
> ---
>  src/util/threads-pthread.c |   26 +++++++++++++++-----------
>  1 files changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
> index 4e00bc5..b3ec06e 100644
> --- a/src/util/threads-pthread.c
> +++ b/src/util/threads-pthread.c
> @@ -35,8 +35,9 @@ void virThreadOnExit(void)
>  
>  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;
> @@ -57,11 +58,11 @@ void virMutexUnlock(virMutexPtr m)
>  }
>  
>  
> -
>  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;
> @@ -69,8 +70,9 @@ int virCondInit(virCondPtr c)
>  
>  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;
> @@ -78,8 +80,9 @@ int virCondDestroy(virCondPtr c)
>  
>  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;
> @@ -99,8 +102,9 @@ void virCondBroadcast(virCondPtr c)
>  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;

  ACK,

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
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]