From bb7086d063db5c73de9f64f465f86d9440d2da47 Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Fri, 30 Nov 2018 21:15:39 -0800 Subject: [PATCH] drd/test: Fix most gcc 8 compiler warnings --- drd/tests/circular_buffer.c | 18 ++++++++++-------- drd/tests/matinv.c | 6 ++++-- drd/tests/pth_broadcast.c | 8 +++++--- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/drd/tests/circular_buffer.c b/drd/tests/circular_buffer.c index b7ab564164..0b750467b7 100644 --- a/drd/tests/circular_buffer.c +++ b/drd/tests/circular_buffer.c @@ -156,17 +156,21 @@ static void buffer_destroy(buffer_t* b) static buffer_t b; -static void producer(int* id) +static void *producer(void* arg) { + int* id = arg; + buffer_send(&b, id); - pthread_exit(NULL); + return NULL; } #define MAXSLEEP (100 * 1000) -static void consumer(int* id) +static void *consumer(void* arg) { + int* id = arg; int d; + usleep(rand() % MAXSLEEP); buffer_recv(&b, &d); if (! quiet) @@ -174,7 +178,7 @@ static void consumer(int* id) printf("%i: %i\n", *id, d); fflush(stdout); } - pthread_exit(NULL); + return NULL; } #define THREADS (10) @@ -207,13 +211,11 @@ int main(int argc, char** argv) for (i = 0; i < THREADS; ++i) { thread_arg[i] = i; - pthread_create(producers + i, NULL, - (void * (*)(void *)) producer, &thread_arg[i]); + pthread_create(producers + i, NULL, producer, &thread_arg[i]); } for (i = 0; i < THREADS; ++i) - pthread_create(consumers + i, NULL, - (void * (*)(void *)) consumer, &thread_arg[i]); + pthread_create(consumers + i, NULL, consumer, &thread_arg[i]); for (i = 0; i < THREADS; ++i) { diff --git a/drd/tests/matinv.c b/drd/tests/matinv.c index 1e2608850a..1369a699f4 100644 --- a/drd/tests/matinv.c +++ b/drd/tests/matinv.c @@ -167,8 +167,9 @@ static elem_t* multiply_matrices(const elem_t* const a1, * submatrix p->a[0..p->rows-1,0..p->rows-1] is the identity matrix. * @see http://en.wikipedia.org/wiki/Gauss-Jordan_elimination */ -static void gj_threadfunc(struct gj_threadinfo* p) +static void *gj_threadfunc(void *arg) { + struct gj_threadinfo* p = arg; int i, j, k; elem_t* const a = p->a; const int rows = p->rows; @@ -217,6 +218,7 @@ static void gj_threadfunc(struct gj_threadinfo* p) } } } + return NULL; } /** Multithreaded Gauss-Jordan algorithm. */ @@ -246,7 +248,7 @@ static void gj(elem_t* const a, const int rows, const int cols) t[i].cols = cols; t[i].r0 = i * rows / s_nthread; t[i].r1 = (i+1) * rows / s_nthread; - pthread_create(&t[i].tid, &attr, (void*(*)(void*))gj_threadfunc, &t[i]); + pthread_create(&t[i].tid, &attr, gj_threadfunc, &t[i]); } pthread_attr_destroy(&attr); diff --git a/drd/tests/pth_broadcast.c b/drd/tests/pth_broadcast.c index 5276a349d4..21ff4ca1cd 100644 --- a/drd/tests/pth_broadcast.c +++ b/drd/tests/pth_broadcast.c @@ -83,8 +83,9 @@ static pthread_cond_t s_cond; // Function definitions. -static void thread_func(struct cthread* thread_info) +static void *thread_func(void *arg) { + struct cthread* thread_info = arg; int i; pthread_mutex_lock(&s_mutex); @@ -106,6 +107,8 @@ static void thread_func(struct cthread* thread_info) } pthread_mutex_unlock(&s_mutex); + + return NULL; } int main(int argc, char** argv) @@ -151,8 +154,7 @@ int main(int argc, char** argv) cthread_ctr(p); p->m_threadnum = p - thread_vec; p->m_sema = &sema; - pthread_create(&p->m_thread, 0, - (void*(*)(void*))thread_func, &*p); + pthread_create(&p->m_thread, 0, thread_func, &*p); } for (i = 0; i < s_signal_count; i++) { -- 2.47.2