[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/5] libports: fix error handling in _ports_create_port_inter
From: |
Thomas Schwinge |
Subject: |
Re: [PATCH 3/5] libports: fix error handling in _ports_create_port_internal |
Date: |
Fri, 25 Oct 2013 15:27:10 +0200 |
User-agent: |
Notmuch/0.9-101-g81dad07 (http://notmuchmail.org) Emacs/23.4.1 (i486-pc-linux-gnu) |
Hi!
Many thanks for paying attention to such issues!
On Fri, 25 Oct 2013 10:30:22 +0200, Justus Winter
<4winter@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
pgph4WZepvJWy.pgp
Description: PGP signature
[PATCH 2/5] exec: Remove the remaining BFD related bits, Justus Winter, 2013/10/25
Re: [PATCH 1/5] Makeconf: add -fno-strict-aliasing to CFLAGS, Thomas Schwinge, 2013/10/25