From: Ivan Maidanski Date: Mon, 29 Feb 2016 21:07:07 +0000 (+0300) Subject: Fix unchecked pthread_join() result in threadkey_test X-Git-Tag: gc7_6_0~60 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=02596c35b7ea5b68de17a82705e771f2022a3b80;p=gc 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. --- 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;