]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
drd/test: Fix most gcc 8 compiler warnings
authorBart Van Assche <bvanassche@acm.org>
Sat, 1 Dec 2018 05:15:39 +0000 (21:15 -0800)
committerBart Van Assche <bvanassche@acm.org>
Sat, 1 Dec 2018 18:45:51 +0000 (10:45 -0800)
drd/tests/circular_buffer.c
drd/tests/matinv.c
drd/tests/pth_broadcast.c

index b7ab5641644cd9abcad01211edb1fc5612553433..0b750467b78d1b30c0304a30ad6bf14dac86297b 100644 (file)
@@ -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)
   {
index 1e2608850a29ce69229c31417751bb77ddf80b6c..1369a699f48b1c4d7efa4a813cb049efbbfd7740 100644 (file)
@@ -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);
index 5276a349d45ce92122fadaee476ba23f283f694b..21ff4ca1cd654170b61173460042fb14ccdffd11 100644 (file)
@@ -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++)
     {