Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference local variables in teshsuite/.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 23 Dec 2019 20:56:43 +0000 (21:56 +0100)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Mon, 23 Dec 2019 23:33:29 +0000 (00:33 +0100)
teshsuite/mc/dwarf/dwarf.cpp
teshsuite/mc/mutex-handling/mutex-handling.c
teshsuite/msg/app-chainsend/iterator.c
teshsuite/msg/cloud-migration/cloud-migration.c
teshsuite/s4u/cloud-interrupt-migration/cloud-interrupt-migration.cpp
teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
teshsuite/s4u/listen_async/listen_async.cpp
teshsuite/s4u/pid/pid.cpp
teshsuite/s4u/storage_client_server/storage_client_server.cpp
teshsuite/simdag/flatifier/flatifier.cpp
teshsuite/surf/surf_usage/surf_usage.cpp

index c3f876e..f43a8f8 100644 (file)
@@ -60,7 +60,7 @@ static void test_local_variable(simgrid::mc::ObjectInformation* info, const char
   assert(subprogram);
   // TODO, Lookup frame by IP and test against name instead
 
-  simgrid::mc::Variable* var = find_local_variable(subprogram, variable);
+  const simgrid::mc::Variable* var = find_local_variable(subprogram, variable);
   assert(var);
 
   void* frame_base = subprogram->frame_base(*cursor);
@@ -83,7 +83,7 @@ static const simgrid::mc::Variable* test_global_variable(simgrid::mc::RemoteClie
 
   auto i = process.binary_info->types.find(variable->type_id);
   xbt_assert(i != process.binary_info->types.end(), "Missing type for %s", name);
-  simgrid::mc::Type* type = &i->second;
+  const simgrid::mc::Type* type = &i->second;
   xbt_assert(type->byte_size == byte_size, "Byte size mismatch for %s", name);
   return variable;
 }
index c367cdf..8eff02a 100644 (file)
@@ -48,7 +48,7 @@ static int receiver(XBT_ATTRIB_UNUSED int argc, XBT_ATTRIB_UNUSED char* argv[])
 static int sender(int argc, char *argv[])
 {
   xbt_assert(argc == 2);
-  char* message_name = argv[1];
+  const char* message_name = argv[1];
 #ifndef DISABLE_THE_MUTEX
   sg_mutex_lock(mutex);
 #endif
index bfffe74..a96a090 100644 (file)
@@ -29,7 +29,7 @@ void* xbt_dynar_iterator_next(xbt_dynar_iterator_t it)
   if (it->current >= it->length) {
     return NULL;
   } else {
-    int* next = xbt_dynar_get_ptr(it->indices_list, it->current);
+    const int* next = xbt_dynar_get_ptr(it->indices_list, it->current);
     it->current++;
     return xbt_dynar_get_ptr(it->list, *next);
   }
index d3603d7..0391b56 100644 (file)
@@ -23,8 +23,8 @@ static void vm_migrate(msg_vm_t vm, msg_host_t dst_pm)
 static int migration_worker_main(int argc, char* argv[])
 {
   xbt_assert(argc == 3);
-  char* vm_name     = argv[1];
-  char* dst_pm_name = argv[2];
+  const char* vm_name     = argv[1];
+  const char* dst_pm_name = argv[2];
 
   msg_vm_t vm       = (msg_vm_t)MSG_host_by_name(vm_name);
   msg_host_t dst_pm = MSG_host_by_name(dst_pm_name);
index 0701ffa..d2decb8 100644 (file)
@@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_cloud_interrupt_migration, "Messages specific f
 
 static void vm_migrate(simgrid::s4u::VirtualMachine* vm, simgrid::s4u::Host* dst_pm)
 {
-  simgrid::s4u::Host* src_pm = vm->get_pm();
+  const simgrid::s4u::Host* src_pm = vm->get_pm();
   double mig_sta             = simgrid::s4u::Engine::get_clock();
   sg_vm_migrate(vm, dst_pm);
   double mig_end = simgrid::s4u::Engine::get_clock();
index 07838b5..e201a0e 100644 (file)
@@ -143,7 +143,7 @@ static void receiver(std::vector<std::string> args)
       default:
         xbt_die("Unknown receiver spec for test %u: '%c'", test, args[0][test - 1]);
     }
-    std::string* receivedStr = static_cast<std::string*>(received);
+    const std::string* receivedStr = static_cast<std::string*>(received);
     xbt_assert(*receivedStr == mboxName);
     delete receivedStr;
     XBT_INFO("Test %u OK", test);
index 1e64d69..49a2185 100644 (file)
@@ -21,7 +21,7 @@ static void server()
 
   xbt_assert(mailbox->listen()); // True (1)
   XBT_INFO("Task listen works on regular mailboxes");
-  std::string* res = static_cast<std::string*>(mailbox->get());
+  const std::string* res = static_cast<std::string*>(mailbox->get());
 
   xbt_assert(*res == "Some data", "Data received: %s", res->c_str());
   XBT_INFO("Data successfully received from regular mailbox");
index 9f1099d..af9aef7 100644 (file)
@@ -25,7 +25,7 @@ static void killall()
 {
   simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name("mailbox");
   for (int i = 0; i < 3; i++) {
-    int* pid = static_cast<int*>(mailbox->get());
+    const int* pid = static_cast<int*>(mailbox->get());
     XBT_INFO("Killing process \"%d\".", *pid);
     simgrid::s4u::Actor::by_pid(*pid)->kill();
   }
index 79efb8a..0e780ac 100644 (file)
@@ -61,7 +61,7 @@ static void display_disk_content(simgrid::s4u::Disk* disk)
 {
   XBT_INFO("*** Dump a disk ***");
   XBT_INFO("Print the content of the disk: %s", disk->get_cname());
-  std::map<std::string, sg_size_t>* content = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_content();
+  const std::map<std::string, sg_size_t>* content = disk->extension<simgrid::s4u::FileSystemDiskExt>()->get_content();
   if (not content->empty()) {
     for (auto const& entry : *content)
       XBT_INFO("  %s size: %llu bytes", entry.first.c_str(), entry.second);
@@ -74,7 +74,7 @@ static void get_set_disk_data(simgrid::s4u::Disk* disk)
 {
   XBT_INFO("*** GET/SET DATA for disk: %s ***", disk->get_cname());
 
-  std::string* data = static_cast<std::string*>(disk->get_data());
+  const std::string* data = static_cast<std::string*>(disk->get_data());
   XBT_INFO("Get data: '%s'", data ? data->c_str() : "No User Data");
   disk->set_data(new std::string("Some data"));
   data = static_cast<std::string*>(disk->get_data());
@@ -127,7 +127,7 @@ static void server()
 
   XBT_INFO("Server waiting for transfers ...");
   while (1) {
-    std::string* msg = static_cast<std::string*>(mailbox->get());
+    const std::string* msg = static_cast<std::string*>(mailbox->get());
     if (*msg == "finalize") { // Shutdown ...
       delete msg;
       break;
index da1a39a..338f43b 100644 (file)
@@ -121,10 +121,10 @@ static void dump_routes()
             });
 
   for (unsigned int it_src = 0; it_src < totalHosts; it_src++) { // Routes from host
-    simgrid::s4u::Host* host1               = hosts[it_src];
+    const simgrid::s4u::Host* host1         = hosts[it_src];
     simgrid::kernel::routing::NetPoint* src = host1->get_netpoint();
     for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
-      simgrid::s4u::Host* host2 = hosts[it_dst];
+      const simgrid::s4u::Host* host2 = hosts[it_dst];
       std::vector<simgrid::kernel::resource::LinkImpl*> route;
       simgrid::kernel::routing::NetPoint* dst = host2->get_netpoint();
       simgrid::kernel::routing::NetZoneImpl::get_global_route(src, dst, route, nullptr);
@@ -161,7 +161,7 @@ static void dump_routes()
         }
       }
       for (unsigned int it_dst = 0; it_dst < totalHosts; it_dst++) { // Routes to host
-        simgrid::s4u::Host* host2 = hosts[it_dst];
+        const simgrid::s4u::Host* host2 = hosts[it_dst];
         std::printf("  <route src=\"%s\" dst=\"%s\">\n  ", value1->get_cname(), host2->get_cname());
         std::vector<simgrid::kernel::resource::LinkImpl*> route;
         simgrid::kernel::routing::NetPoint* netcardDst = host2->get_netpoint();
index 0d1238d..953efb3 100644 (file)
@@ -46,9 +46,9 @@ int main(int argc, char **argv)
   simgrid::s4u::Host* hostB = sg_host_by_name("Cpu B");
 
   /* Let's do something on it */
-  simgrid::kernel::resource::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0);
-  simgrid::kernel::resource::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0);
-  simgrid::kernel::resource::Action* actionC = hostB->pimpl_cpu->sleep(7.32);
+  const simgrid::kernel::resource::Action* actionA = hostA->pimpl_cpu->execution_start(1000.0);
+  const simgrid::kernel::resource::Action* actionB = hostB->pimpl_cpu->execution_start(1000.0);
+  const simgrid::kernel::resource::Action* actionC = hostB->pimpl_cpu->sleep(7.32);
 
   simgrid::kernel::resource::Action::State stateActionA = actionA->get_state();
   simgrid::kernel::resource::Action::State stateActionB = actionB->get_state();