Skip to content

Commit a40646e

Browse files
committed
Fix error handling in replacement pthread_barrier_init().
Commit 44bf3d5 incorrectly used an errno-style interface when supplying missing pthread functionality (i.e. on macOS), but it should check for and return error numbers directly.
1 parent 7c544ec commit a40646e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/port/pthread_barrier_wait.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,17 @@
1818
int
1919
pthread_barrier_init(pthread_barrier_t *barrier, const void *attr, int count)
2020
{
21+
int error;
22+
2123
barrier->sense = false;
2224
barrier->count = count;
2325
barrier->arrived = 0;
24-
if (pthread_cond_init(&barrier->cond, NULL) < 0)
25-
return -1;
26-
if (pthread_mutex_init(&barrier->mutex, NULL) < 0)
26+
if ((error = pthread_cond_init(&barrier->cond, NULL)) != 0)
27+
return error;
28+
if ((error = pthread_mutex_init(&barrier->mutex, NULL)) != 0)
2729
{
28-
int save_errno = errno;
29-
3030
pthread_cond_destroy(&barrier->cond);
31-
errno = save_errno;
32-
33-
return -1;
31+
return error;
3432
}
3533

3634
return 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy