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

+6-8
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)