Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Const for local variables.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 3 Jul 2020 11:44:50 +0000 (13:44 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Fri, 3 Jul 2020 11:44:50 +0000 (13:44 +0200)
14 files changed:
src/instr/jedule/jedule_platform.cpp
src/mc/ModelChecker.cpp
src/plugins/host_load.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Host.cpp
src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/bindings/smpi_pmpi_topo.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_memory.cpp
src/smpi/mpi/smpi_request.cpp
src/smpi/plugins/load_balancer/LoadBalancer.cpp
src/surf/cpu_cas01.cpp
src/surf/sg_platf.cpp
teshsuite/s4u/actor-suspend/actor-suspend.cpp

index c53f3dd..f9dcd9c 100644 (file)
@@ -158,7 +158,7 @@ static void add_subsets_to(std::vector<simgrid::jedule::Subset>& subset_list, st
 
   for (auto const& host_name : hostgroup) {
     xbt_assert( host_name != nullptr );
-    jed_container_t parent_cont = host2_simgrid_parent_container.at(host_name);
+    const simgrid::jedule::Container* parent_cont = host2_simgrid_parent_container.at(host_name);
     unsigned int id             = parent_cont->get_id_by_name(host_name);
     id_list.push_back(id);
   }
index 894419c..884444c 100644 (file)
@@ -94,7 +94,7 @@ static const std::pair<const char*, const char*> ignored_local_variables[] = {
 
 void ModelChecker::setup_ignore()
 {
-  RemoteSimulation& process = this->get_remote_simulation();
+  const RemoteSimulation& process = this->get_remote_simulation();
   for (std::pair<const char*, const char*> const& var :
       ignored_local_variables)
     process.ignore_local_variable(var.first, var.second);
index 2188d2c..c538bf3 100644 (file)
@@ -218,7 +218,7 @@ void sg_host_load_plugin_init()
 
   // If SimGrid is already initialized, we need to attach an extension to each existing host
   if (simgrid::s4u::Engine::is_initialized()) {
-    simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
+    const simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
     for (auto& host : e->get_all_hosts()) {
       host->extension_set(new HostLoad(host));
     }
index f3a612b..da64c24 100644 (file)
@@ -478,7 +478,7 @@ size_t sg_actor_count()
 
 sg_actor_t* sg_actor_list()
 {
-  simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
+  const simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
   size_t actor_count      = e->get_actor_count();
   xbt_assert(actor_count > 0, "There is no actor!");
   std::vector<simgrid::s4u::ActorPtr> actors = e->get_all_actors();
index 81f6158..3dba929 100644 (file)
@@ -319,7 +319,7 @@ size_t sg_host_count()
 }
 sg_host_t* sg_host_list()
 {
-  simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
+  const simgrid::s4u::Engine* e = simgrid::s4u::Engine::get_instance();
   size_t host_count       = e->get_host_count();
   xbt_assert(host_count > 0, "There is no host!");
   std::vector<simgrid::s4u::Host*> hosts = e->get_all_hosts();
index c64a63a..ddc0a15 100644 (file)
@@ -138,7 +138,7 @@ int PMPI_Startall(int count, MPI_Request * requests)
       TRACE_smpi_comm_in(my_proc_id, __func__, new simgrid::instr::NoOpTIData("Startall"));
       if (not TRACE_smpi_view_internals())
         for (int i = 0; i < count; i++) {
-          MPI_Request req = requests[i];
+          const simgrid::smpi::Request* req = requests[i];
           if (req->flags() & MPI_REQ_SEND)
             TRACE_smpi_send(my_proc_id, my_proc_id, getPid(req->comm(), req->dst()), req->tag(), req->size());
         }
@@ -147,7 +147,7 @@ int PMPI_Startall(int count, MPI_Request * requests)
 
       if (not TRACE_smpi_view_internals())
         for (int i = 0; i < count; i++) {
-          MPI_Request req = requests[i];
+          const simgrid::smpi::Request* req = requests[i];
           if (req->flags() & MPI_REQ_RECV)
             TRACE_smpi_recv(getPid(req->comm(), req->src()), my_proc_id, req->tag());
         }
@@ -588,10 +588,9 @@ int PMPI_Iprobe(int source, int tag, MPI_Comm comm, int* flag, MPI_Status* statu
 }
 
 // TODO: cheinrich: Move declaration to other file? Rename this function - it's used for PMPI_Wait*?
-static void trace_smpi_recv_helper(MPI_Request* request, MPI_Status* status);
 static void trace_smpi_recv_helper(MPI_Request* request, MPI_Status* status)
 {
-  MPI_Request req = *request;
+  const simgrid::smpi::Request* req = *request;
   if (req != MPI_REQUEST_NULL) { // Received requests become null
     int src_traced = req->src();
     // the src may not have been known at the beginning of the recv (MPI_ANY_SOURCE)
index c45f88b..7e774e6 100644 (file)
@@ -91,7 +91,7 @@ int PMPI_Cartdim_get(MPI_Comm comm, int* ndims) {
   CHECK_COMM(1)
   CHECK_NULL(1, MPI_ERR_TOPOLOGY, comm->topo())
   CHECK_NULL(2, MPI_ERR_ARG, ndims)
-  MPIR_Cart_Topology topo = static_cast<MPIR_Cart_Topology>(comm->topo().get());
+  const simgrid::smpi::Topo_Cart* topo = static_cast<MPIR_Cart_Topology>(comm->topo().get());
   if (topo==nullptr) {
     return MPI_ERR_ARG;
   }
index b54cd49..0ef90fa 100644 (file)
@@ -103,7 +103,7 @@ void smpi_bench_begin()
 double smpi_adjust_comp_speed(){
   double speedup=1;
   if (smpi_cfg_comp_adjustment_file()[0] != '\0') {
-    smpi_trace_call_location_t* loc                            = smpi_process()->call_location();
+    const smpi_trace_call_location_t* loc                      = smpi_process()->call_location();
     std::string key                                            = loc->get_composed_key();
     std::unordered_map<std::string, double>::const_iterator it = location2speedup.find(key);
     if (it != location2speedup.end()) {
index a5f00a7..394dbb4 100644 (file)
@@ -192,7 +192,7 @@ void smpi_switch_data_segment(simgrid::s4u::ActorPtr actor)
 #if HAVE_PRIVATIZATION
   // FIXME, cross-process support (mmap across process when necessary)
   XBT_DEBUG("Switching data frame to the one of process %ld", actor->get_pid());
-  simgrid::smpi::ActorExt* process = smpi_process_remote(actor);
+  const simgrid::smpi::ActorExt* process = smpi_process_remote(actor);
   int current                     = process->privatized_region()->file_descriptor;
   const void* tmp = mmap(TOPAGE(smpi_data_exe_start), smpi_data_exe_size, PROT_RW, MAP_FIXED | MAP_SHARED, current, 0);
   if (tmp != TOPAGE(smpi_data_exe_start))
index a447e56..f1060f1 100644 (file)
@@ -429,7 +429,7 @@ void Request::start()
     if (smpi_cfg_async_small_thresh() != 0 || (flags_ & MPI_REQ_RMA) != 0)
       mut->unlock();
   } else { /* the RECV flag was not set, so this is a send */
-    simgrid::smpi::ActorExt* process = smpi_process_remote(simgrid::s4u::Actor::by_pid(dst_));
+    const simgrid::smpi::ActorExt* process = smpi_process_remote(simgrid::s4u::Actor::by_pid(dst_));
     xbt_assert(process, "Actor pid=%d is gone??", dst_);
     int rank = src_;
     if (TRACE_smpi_view_internals()) {
index 11df4aa..1e9866c 100644 (file)
@@ -41,7 +41,7 @@ bool compare_hosts::operator()(s4u::Host* const a, s4u::Host* const b) const
 
 void LoadBalancer::run()
 {
-  s4u::Engine* engine = s4u::Engine::get_instance();
+  const s4u::Engine* engine = s4u::Engine::get_instance();
   std::vector<s4u::Host*> available_hosts =
       engine->get_filtered_hosts([](const s4u::Host* host) { return host->is_on(); });
   xbt_assert(available_hosts.size() > 0, "No hosts available; are they all switched off?");
index 7118711..9aae097 100644 (file)
@@ -108,7 +108,7 @@ void CpuCas01::on_speed_change()
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(),
                                                             get_core_count() * speed_.scale * speed_.peak);
   while ((var = get_constraint()->get_variable(&elem))) {
-    auto* action = static_cast<CpuCas01Action*>(var->get_id());
+    const CpuCas01Action* action = static_cast<CpuCas01Action*>(var->get_id());
 
     get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(),
                                                             action->requested_core() * speed_.scale * speed_.peak);
index cdb4e0f..e1218f8 100644 (file)
@@ -673,7 +673,7 @@ void sg_platf_new_Zone_seal()
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
 void sg_platf_new_hostlink(const simgrid::kernel::routing::HostLinkCreationArgs* hostlink)
 {
-  simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
+  const simgrid::kernel::routing::NetPoint* netpoint = simgrid::s4u::Host::by_name(hostlink->id)->get_netpoint();
   xbt_assert(netpoint, "Host '%s' not found!", hostlink->id.c_str());
   xbt_assert(dynamic_cast<simgrid::kernel::routing::ClusterZone*>(current_routing),
              "Only hosts from Cluster and Vivaldi ASes can get a host_link.");
index e509b37..14bf657 100644 (file)
@@ -50,7 +50,7 @@ public:
 
 int main(int argc, char** argv)
 {
-  simgrid::s4u::Engine* engine = new simgrid::s4u::Engine(&argc, argv);
+  const simgrid::s4u::Engine* engine = new simgrid::s4u::Engine(&argc, argv);
 
   engine->load_platform(argv[1]);
   simgrid::s4u::Host* host = simgrid::s4u::Host::by_name("Tremblay");