Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Useless cast to void*.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Dec 2020 13:35:19 +0000 (14:35 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Thu, 17 Dec 2020 13:35:19 +0000 (14:35 +0100)
examples/deprecated/simdag/daxload/sd_daxload.c
examples/deprecated/simdag/test/sd_test.cpp
examples/s4u/maestro-set/s4u-maestro-set.cpp
include/xbt/functional.hpp
src/bindings/java/jmsg_host.cpp
src/bindings/java/jmsg_task.cpp
src/bindings/java/jmsg_vm.cpp
src/s4u/s4u_Netzone.cpp
teshsuite/mc/mutex-handling/mutex-handling.cpp
teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
teshsuite/simdag/availability/availability.c

index d6a29f8..77741ed 100644 (file)
@@ -66,7 +66,7 @@ int main(int argc, char **argv)
   XBT_INFO("------------------- Schedule tasks ---------------------------");
   sg_host_t *host_list = sg_host_list();
   int hosts_count = sg_host_count();
-  qsort((void *) host_list, hosts_count, sizeof(sg_host_t), name_compare_hosts);
+  qsort(host_list, hosts_count, sizeof(sg_host_t), name_compare_hosts);
 
   xbt_dynar_foreach(dax, cursor, task) {
     if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {
index eea9731..f9955eb 100644 (file)
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
   SD_task_t taskD = SD_task_create("Task D", nullptr, 60.0);
 
   /* try to attach and retrieve user data to a task */
-  SD_task_set_data(taskA, static_cast<void*>(&comp_amount1));
+  SD_task_set_data(taskA, &comp_amount1);
   if (fabs(comp_amount1 - (*(static_cast<double*>(SD_task_get_data(taskA))))) > 1e-12)
       XBT_ERROR("User data was corrupted by a simple set/get");
 
index 51af163..b6758ca 100644 (file)
@@ -41,7 +41,7 @@ static void sender()
 {
   ensure_root_tid();
   auto* payload = new std::string("some message");
-  simgrid::s4u::Mailbox::by_name("some mailbox")->put((void*)payload, 10e8);
+  simgrid::s4u::Mailbox::by_name("some mailbox")->put(payload, 10e8);
 }
 
 static void receiver()
index b869563..d333fb9 100644 (file)
@@ -151,7 +151,7 @@ public:
     if (that.vtable_ && that.vtable_->move)
       that.vtable_->move(buffer_, that.buffer_);
     else
-      std::memcpy(static_cast<void*>(&buffer_), static_cast<void*>(&that.buffer_), sizeof(buffer_));
+      std::memcpy(&buffer_, &that.buffer_, sizeof(buffer_));
     vtable_      = std::move(that.vtable_);
     that.vtable_ = nullptr;
   }
@@ -162,7 +162,7 @@ public:
     if (that.vtable_ && that.vtable_->move)
       that.vtable_->move(buffer_, that.buffer_);
     else
-      std::memcpy(static_cast<void*>(&buffer_), static_cast<void*>(&that.buffer_), sizeof(buffer_));
+      std::memcpy(&buffer_, &that.buffer_, sizeof(buffer_));
     vtable_      = std::move(that.vtable_);
     that.vtable_ = nullptr;
     return *this;
index d6bc9fd..766308c 100644 (file)
@@ -93,7 +93,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_getByName(JNIEnv* env, jclas
     jhost_bind(jhost, host, env);
 
     /* the native host data field is set with the global reference to the java host returned by this function */
-    host->extension_set(JAVA_HOST_LEVEL, (void *)jhost);
+    host->extension_set(JAVA_HOST_LEVEL, jhost);
   }
 
   /* return the global reference to the java host instance */
@@ -128,7 +128,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Host_currentHost(JNIEnv * env, jc
     env->SetObjectField(jhost, jhost_field_Host_name, jname);
     /* Bind & store it */
     jhost_bind(jhost, host, env);
-    host->extension_set(JAVA_HOST_LEVEL, (void *) jhost);
+    host->extension_set(JAVA_HOST_LEVEL, jhost);
   } else {
     jhost = (jobject) host->extension(JAVA_HOST_LEVEL);
   }
index 0bd50d6..8551cac 100644 (file)
@@ -267,7 +267,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_sendBounded(JNIEnv * env,jobjec
   }
 
   /* Add a global ref into the Ctask so that the receiver can use it */
-  MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
+  MSG_task_set_data(task, env->NewGlobalRef(jtask));
 
   const char* alias = env->GetStringUTFChars(jalias, nullptr);
   msg_error_t res   = MSG_task_send_with_timeout_bounded(task, alias, jtimeout, maxrate);
@@ -403,7 +403,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isend(JNIEnv *env, jobject j
         return nullptr;
   }
 
-  MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
+  MSG_task_set_data(task, env->NewGlobalRef(jtask));
   comm = MSG_task_isend(task,mailbox);
 
   env->SetLongField(jcomm, jtask_field_Comm_bind, (jlong) (uintptr_t)(comm));
@@ -439,7 +439,7 @@ JNIEXPORT jobject JNICALL Java_org_simgrid_msg_Task_isendBounded(JNIEnv *env, jo
         return nullptr;
   }
 
-  MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
+  MSG_task_set_data(task, env->NewGlobalRef(jtask));
   comm = MSG_task_isend_bounded(task,mailbox,maxrate);
 
   env->SetLongField(jcomm, jtask_field_Comm_bind, (jlong) (uintptr_t)(comm));
@@ -491,7 +491,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_dsend(JNIEnv * env, jobject jta
   }
 
   /* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
-  MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
+  MSG_task_set_data(task, env->NewGlobalRef(jtask));
   MSG_task_dsend(task, alias, msg_task_cancel_on_failed_dsend);
 
   env->ReleaseStringUTFChars(jalias, alias);
@@ -511,7 +511,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_Task_dsendBounded(JNIEnv * env, jobj
   }
 
   /* Pass a global ref to the Jtask into the Ctask so that the receiver can use it */
-  MSG_task_set_data(task, (void *) env->NewGlobalRef(jtask));
+  MSG_task_set_data(task, env->NewGlobalRef(jtask));
   MSG_task_dsend_bounded(task, alias, msg_task_cancel_on_failed_dsend, maxrate);
 
   env->ReleaseStringUTFChars(jalias, alias);
index 96a9550..5c0e3e6 100644 (file)
@@ -79,7 +79,7 @@ JNIEXPORT void JNICALL Java_org_simgrid_msg_VM_create(JNIEnv* env, jobject jVm,
   jvm_bind(env, jVm, vm);
   jVm = env->NewGlobalRef(jVm);
   // We use the extension level of the host, even if that's somehow disturbing
-  vm->extension_set(JAVA_HOST_LEVEL, (void*)jVm);
+  vm->extension_set(JAVA_HOST_LEVEL, jVm);
 }
 
 JNIEXPORT jobjectArray JNICALL Java_org_simgrid_msg_VM_all(JNIEnv* env, jclass cls_arg)
index 6ee90d7..f1fec05 100644 (file)
@@ -122,7 +122,7 @@ sg_netzone_t sg_zone_get_by_name(const char* name)
 void sg_zone_get_sons(const_sg_netzone_t netzone, xbt_dict_t whereto)
 {
   for (auto const& elem : netzone->get_children()) {
-    xbt_dict_set(whereto, elem->get_cname(), static_cast<void*>(elem));
+    xbt_dict_set(whereto, elem->get_cname(), elem);
   }
 }
 
index 162dab9..4e64813 100644 (file)
@@ -48,7 +48,7 @@ static int sender(const char* box_name, simgrid::s4u::MutexPtr mutex, int value)
   if (mutex)
     mutex->lock();
 
-  mb->put(static_cast<void*>(payload), 8);
+  mb->put(payload, 8);
 
   if (mutex)
     mutex->unlock();
index c9282f0..0583b1c 100644 (file)
@@ -53,32 +53,32 @@ static void sender(std::vector<std::string> args)
     switch (args[0][test - 1]) {
       case 'r':
         XBT_INFO("Test %u: r (regular send)", test);
-        mbox->put((void*)mboxName, 42.0);
+        mbox->put(mboxName, 42.0);
         break;
       case 'R':
         XBT_INFO("Test %u: R (sleep + regular send)", test);
         simgrid::s4u::this_actor::sleep_for(0.5);
-        mbox->put((void*)mboxName, 42.0);
+        mbox->put(mboxName, 42.0);
         break;
 
       case 'i':
         XBT_INFO("Test %u: i (asynchronous isend)", test);
-        mbox->put_async((void*)mboxName, 42.0)->wait();
+        mbox->put_async(mboxName, 42.0)->wait();
         break;
       case 'I':
         XBT_INFO("Test %u: I (sleep + isend)", test);
         simgrid::s4u::this_actor::sleep_for(0.5);
-        mbox->put_async((void*)mboxName, 42.0)->wait();
+        mbox->put_async(mboxName, 42.0)->wait();
         break;
 
       case 'd':
         XBT_INFO("Test %u: d (detached send)", test);
-        mbox->put_init((void*)mboxName, 42.0)->detach();
+        mbox->put_init(mboxName, 42.0)->detach();
         break;
       case 'D':
         XBT_INFO("Test %u: D (sleep + detached send)", test);
         simgrid::s4u::this_actor::sleep_for(0.5);
-        mbox->put_init((void*)mboxName, 42.0)->detach();
+        mbox->put_init(mboxName, 42.0)->detach();
         break;
       default:
         xbt_die("Unknown sender spec for test %u: '%c'", test, args[0][test - 1]);
index 16fe88f..20867ee 100644 (file)
@@ -22,7 +22,7 @@ static void scheduleDAX(const_xbt_dynar_t dax)
 
   sg_host_t *hosts = sg_host_list();
   size_t totalHosts = sg_host_count();
-  qsort((void *) hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
+  qsort(hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
 
   xbt_dynar_foreach(dax, cursor, task) {
     if (SD_task_get_kind(task) == SD_TASK_COMP_SEQ) {