Hi!

Many thanks for paying attention to such issues!

On Fri, 25 Oct 2013 10:30:22 +0200, Justus Winter 
<4win...@informatik.uni-hamburg.de> wrote:
> Previously any err value set before reaching lose: was overwritten and
> thus not properly propagated.
> 
> Found using the Clang Static Analyzer.
> 
> * libports/create-internal.c (_ports_create_port_internal): Fix error
>   handling.

> --- a/libports/create-internal.c
> +++ b/libports/create-internal.c
> @@ -109,10 +109,11 @@ _ports_create_port_internal (struct port_class *class,
>    err = EINTR;
>   lose:
>    pthread_mutex_unlock (&_ports_lock);
> +  error_t e;
>   lose_unlocked:
> -  err = mach_port_mod_refs (mach_task_self (), port,
> -                         MACH_PORT_RIGHT_RECEIVE, -1);
> -  assert_perror (err);
> +  e = mach_port_mod_refs (mach_task_self (), port,
> +                       MACH_PORT_RIGHT_RECEIVE, -1);
> +  assert_perror (e);
>    free (pi);
>  
>    return err;

OK, but I suggest to move the definition of e after the lose_unlocked
label, or even move all that (mach_port_mod_refs call and assert_perror)
into a new scope to make its locality clear.  May also want to replace
the earlier »if (!  pi)« handling with »goto lose_unlocked;« (»free
(NULL)« being a no-op).


Grüße,
 Thomas

Attachment: pgpEa5CZ90Ha1.pgp
Description: PGP signature

Reply via email to