diff --git a/test/zdtm/transition/thread-bomb.c b/test/zdtm/transition/thread-bomb.c index 6621b18ed..c1b825be7 100644 --- a/test/zdtm/transition/thread-bomb.c +++ b/test/zdtm/transition/thread-bomb.c @@ -18,17 +18,31 @@ static const size_t stack_size = 64 * 1024; static void *thread_fn(void *arg) { pthread_t t, p, *self; + int err; if (arg) { p = *(pthread_t *)arg; - pthread_join(p, NULL); + err = pthread_join(p, NULL); free(arg); + if (err) { + pr_err("pthread_join(): %d\n", err); + return NULL; + } } self = malloc(sizeof(*self)); + if (!self) { + pr_perror("malloc()"); + return NULL; + } + *self = pthread_self(); - pthread_create(&t, &attr, thread_fn, self); + err = pthread_create(&t, &attr, thread_fn, self); + if (err) { + pr_err("pthread_create(): %d\n", err); + free(self); + } return NULL; } @@ -38,6 +52,8 @@ int main(int argc, char **argv) char *val; int err; + test_init(argc, argv); + err = pthread_attr_init(&attr); if (err) { pr_err("pthread_attr_init(): %d\n", err); @@ -56,8 +72,6 @@ int main(int argc, char **argv) test_msg("%d\n", max_nr); - test_init(argc, argv); - for (i = 0; i < max_nr; i++) { pthread_t p; err = pthread_create(&p, &attr, thread_fn, NULL);