Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
use strncpy instead of strcpy to please sonar
[simgrid.git] / src / smpi / internals / smpi_global.cpp
index dcc7d0f..be68fe1 100644 (file)
@@ -563,7 +563,7 @@ static void smpi_init_privatization_dlopen(const std::string& executable)
       void* libhandle = dlopen(libname.c_str(), RTLD_LAZY);
       // get library name from path
       char fullpath[512] = {'\0'};
       void* libhandle = dlopen(libname.c_str(), RTLD_LAZY);
       // get library name from path
       char fullpath[512] = {'\0'};
-      strcpy(fullpath, libname.c_str());
+      strncpy(fullpath, libname.c_str(), 511);
 #if not defined(__APPLE__)
       int ret = dl_iterate_phdr(visit_libs, fullpath);
       if (ret == 0)
 #if not defined(__APPLE__)
       int ret = dl_iterate_phdr(visit_libs, fullpath);
       if (ret == 0)
@@ -673,12 +673,6 @@ int smpi_main(const char* executable, int argc, char* argv[])
 
   SMPI_switch_data_segment = &smpi_switch_data_segment;
 
 
   SMPI_switch_data_segment = &smpi_switch_data_segment;
 
-  // TODO This will not be executed in the case where smpi_main is not called,
-  // e.g., not for smpi_msg_masterslave. This should be moved to another location
-  // that is always called -- maybe close to Actor::on_creation?
-  simgrid::s4u::Host::on_creation.connect(
-      [](simgrid::s4u::Host& host) { host.extension_set(new simgrid::smpi::Host(&host)); });
-
   // parse the platform file: get the host list
   simgrid::s4u::Engine::get_instance()->load_platform(argv[1]);
   SIMIX_comm_set_copy_data_callback(smpi_comm_copy_buffer_callback);
   // parse the platform file: get the host list
   simgrid::s4u::Engine::get_instance()->load_platform(argv[1]);
   SIMIX_comm_set_copy_data_callback(smpi_comm_copy_buffer_callback);
@@ -739,6 +733,8 @@ void SMPI_init(){
       process_data.erase(it);
     }
   });
       process_data.erase(it);
     }
   });
+  simgrid::s4u::Host::on_creation.connect(
+      [](simgrid::s4u::Host& host) { host.extension_set(new simgrid::smpi::Host(&host)); });
 
   smpi_init_options();
   smpi_global_init();
 
   smpi_init_options();
   smpi_global_init();