From 02596c35b7ea5b68de17a82705e771f2022a3b80 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 1 Mar 2016 00:07:07 +0300 Subject: [PATCH] Fix unchecked pthread_join() result in threadkey_test * tests/threadkey_test.c: Include stdio.h (unconditionally), stdlib.h for fprintf() and exit(). * tests/threadkey_test.c (main): Abort in case of GC_pthread_join failure. --- tests/threadkey_test.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/threadkey_test.c b/tests/threadkey_test.c index f87530e3..859f53fd 100644 --- a/tests/threadkey_test.c +++ b/tests/threadkey_test.c @@ -11,6 +11,9 @@ #include "gc.h" +#include +#include + #if (!defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) \ || defined(__native_client__)) && !defined(SKIP_THREADKEY_TEST) /* FIXME: Skip this test on Solaris for now. The test may fail on */ @@ -21,8 +24,6 @@ #ifdef SKIP_THREADKEY_TEST -#include - int main (void) { printf("threadkey_test skipped\n"); @@ -91,7 +92,11 @@ int main (void) void *res; if (GC_pthread_create (&t, NULL, entry, NULL) == 0 && (i & 1) != 0) { - (void)GC_pthread_join(t, &res); + int code = GC_pthread_join(t, &res); + if (code != 0) { + fprintf(stderr, "Thread join failed %d\n", code); + exit(2); + } } } return 0; -- 2.50.1