Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Useless casts to (void*).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 23 Feb 2023 16:14:51 +0000 (17:14 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 23 Feb 2023 16:18:19 +0000 (17:18 +0100)
examples/sthread/pthread-mutex-simple.c
examples/sthread/pthread-mutex-simpledeadlock.c
examples/sthread/pthread-producer-consumer.c
examples/sthread/sthread-mutex-simple.c

index d97bfe8..1d39141 100644 (file)
@@ -21,8 +21,8 @@ int main(int argc, char* argv[])
   int id[2] = {0, 1};
   pthread_t thread1;
   pthread_t thread2;
-  pthread_create(&thread1, NULL, thread_fun, (void*)&id[0]);
-  pthread_create(&thread2, NULL, thread_fun, (void*)&id[1]);
+  pthread_create(&thread1, NULL, thread_fun, &id[0]);
+  pthread_create(&thread2, NULL, thread_fun, &id[1]);
   fprintf(stderr, "All threads are started.\n");
   pthread_join(thread1, NULL);
   pthread_join(thread2, NULL);
index 433852a..09be6c1 100644 (file)
@@ -39,8 +39,8 @@ int main(int argc, char* argv[])
   int id[2] = {0, 1};
   pthread_t thread1;
   pthread_t thread2;
-  pthread_create(&thread1, NULL, thread_fun1, (void*)&id[0]);
-  pthread_create(&thread2, NULL, thread_fun2, (void*)&id[1]);
+  pthread_create(&thread1, NULL, thread_fun1, &id[0]);
+  pthread_create(&thread2, NULL, thread_fun2, &id[1]);
   fprintf(stderr, "All threads are started.\n");
   pthread_join(thread1, NULL);
   pthread_join(thread2, NULL);
index 78deb2b..8fd1a0b 100644 (file)
@@ -67,9 +67,9 @@ int main(int argc, char** argv)
   int ids[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; // The identity of each thread (for debug messages)
 
   for (int i = 0; i < ProducerCount; i++)
-    pthread_create(&pro[i], NULL, (void*)&producer, (void*)&ids[i]);
+    pthread_create(&pro[i], NULL, producer, &ids[i]);
   for (int i = 0; i < ConsumerCount; i++)
-    pthread_create(&con[i], NULL, (void*)&consumer, (void*)&ids[i]);
+    pthread_create(&con[i], NULL, consumer, &ids[i]);
 
   for (int i = 0; i < ProducerCount; i++)
     pthread_join(pro[i], NULL);
index 76fa009..dccec54 100644 (file)
@@ -21,8 +21,8 @@ int main(int argc, char* argv[])
   int id[2] = {0, 1};
   sthread_t thread1;
   sthread_t thread2;
-  sthread_create(&thread1, NULL, thread_fun, (void*)&id[0]);
-  sthread_create(&thread2, NULL, thread_fun, (void*)&id[1]);
+  sthread_create(&thread1, NULL, thread_fun, &id[0]);
+  sthread_create(&thread2, NULL, thread_fun, &id[1]);
   fprintf(stderr, "All threads are started.\n");
   sthread_join(thread1, NULL);
   sthread_join(thread2, NULL);