Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Remove redundant casts.
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 1 Jul 2020 14:41:22 +0000 (16:41 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Wed, 1 Jul 2020 20:23:07 +0000 (22:23 +0200)
37 files changed:
examples/c/dht-kademlia/node.c
examples/s4u/dht-kademlia/node.cpp
src/kernel/lmm/maxmin.cpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/TorusZone.cpp
src/mc/checker/CommunicationDeterminismChecker.cpp
src/mc/checker/LivenessChecker.cpp
src/mc/compare.cpp
src/mc/inspect/mc_dwarf.cpp
src/mc/mc_base.cpp
src/mc/mc_comm_pattern.cpp
src/mc/mc_request.cpp
src/mc/mc_state.cpp
src/mc/remote/AppSide.cpp
src/plugins/vm/VirtualMachineImpl.cpp
src/smpi/bindings/smpi_f77.cpp
src/smpi/bindings/smpi_pmpi.cpp
src/smpi/bindings/smpi_pmpi_comm.cpp
src/smpi/bindings/smpi_pmpi_info.cpp
src/smpi/bindings/smpi_pmpi_op.cpp
src/smpi/bindings/smpi_pmpi_request.cpp
src/smpi/bindings/smpi_pmpi_win.cpp
src/smpi/internals/smpi_bench.cpp
src/smpi/internals/smpi_global.cpp
src/smpi/mpi/smpi_errhandler.cpp
src/smpi/mpi/smpi_group.cpp
src/smpi/mpi/smpi_request.cpp
src/surf/cpu_cas01.cpp
src/surf/network_interface.cpp
src/surf/ptask_L07.cpp
src/surf/sg_platf.cpp
src/xbt/dynar.cpp
src/xbt/mmalloc/mfree.c
src/xbt/mmalloc/mmalloc.c
src/xbt/mmalloc/mmorecore.c
src/xbt/xbt_os_time.c

index 13d287f..79d228b 100644 (file)
@@ -320,7 +320,7 @@ unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix)
   if (prefix == 0) {
     return 0;
   } else {
-    return (1U << ((unsigned int)(prefix - 1))) ^ id;
+    return (1U << (prefix - 1)) ^ id;
   }
 }
 
index d331cc3..c8ac463 100644 (file)
@@ -295,7 +295,7 @@ unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix)
   if (prefix == 0) {
     return 0;
   } else {
-    return (1U << ((unsigned int)(prefix - 1))) ^ id;
+    return (1U << (prefix - 1)) ^ id;
   }
 }
 
index f506faf..7e25ce0 100644 (file)
@@ -514,7 +514,7 @@ template <class CnstList> void System::lmm_solve(CnstList& cnst_list)
           cnst.usage_ = elem.consumption_weight / elem.variable->sharing_penalty_;
 
         elem.make_active();
-        resource::Action* action = static_cast<resource::Action*>(elem.variable->id_);
+        resource::Action* action = elem.variable->id_;
         if (modified_set_ && not action->is_within_modified_set())
           modified_set_->push_back(*action);
       }
index b9d79f8..d5c854f 100644 (file)
@@ -118,7 +118,7 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr
     for (auto const& link : e_route->link_list) {
       route->link_list.insert(route->link_list.begin(), link);
       if (lat)
-        *lat += static_cast<resource::LinkImpl*>(link)->get_latency();
+        *lat += link->get_latency();
     }
   }
 
@@ -209,7 +209,7 @@ void DijkstraZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationAr
     for (auto const& link : e_route->link_list) {
       route->link_list.insert(route->link_list.begin(), link);
       if (lat)
-        *lat += static_cast<resource::LinkImpl*>(link)->get_latency();
+        *lat += link->get_latency();
     }
   }
 
index 5085d81..0849a03 100644 (file)
@@ -202,13 +202,13 @@ static void find_common_ancestors(NetPoint* src, NetPoint* dst,
   NetZoneImpl* current = src->get_englobing_zone();
   while (current != nullptr) {
     path_src.push_back(current);
-    current = static_cast<NetZoneImpl*>(current->get_father());
+    current = current->get_father();
   }
   std::vector<NetZoneImpl*> path_dst;
   current = dst->get_englobing_zone();
   while (current != nullptr) {
     path_dst.push_back(current);
-    current = static_cast<NetZoneImpl*>(current->get_father());
+    current = current->get_father();
   }
 
   /* (3) find the common father.
@@ -265,14 +265,14 @@ bool NetZoneImpl::get_bypass_route(NetPoint* src, NetPoint* dst,
   std::vector<NetZoneImpl*> path_src;
   NetZoneImpl* current = src->get_englobing_zone();
   while (current != nullptr) {
-    path_src.push_back(static_cast<NetZoneImpl*>(current));
+    path_src.push_back(current);
     current = current->father_;
   }
 
   std::vector<NetZoneImpl*> path_dst;
   current = dst->get_englobing_zone();
   while (current != nullptr) {
-    path_dst.push_back(static_cast<NetZoneImpl*>(current));
+    path_dst.push_back(current);
     current = current->father_;
   }
 
index bca85bd..574153e 100644 (file)
@@ -33,7 +33,7 @@ void TorusZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int
     int current_dimension = dimensions_[j]; // which dimension are we currently in?
                                             // we need to iterate over all dimensions and create all links there
     // The other node the link connects
-    int neighbor_rank_id = ((static_cast<int>(rank) / dim_product) % current_dimension == current_dimension - 1)
+    int neighbor_rank_id = ((rank / dim_product) % current_dimension == current_dimension - 1)
                                ? rank - (current_dimension - 1) * dim_product
                                : rank + dim_product;
     // name of neighbor is not right for non contiguous cluster radicals (as id != rank in this case)
index 7d11206..37acf2e 100644 (file)
@@ -185,9 +185,8 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_
     pattern->comm_addr = static_cast<kernel::activity::CommImpl*>(simcall_comm_isend__getraw__result(request));
 
     Remote<kernel::activity::CommImpl> temp_synchro;
-    mc_model_checker->get_remote_simulation().read(
-        temp_synchro, remote(static_cast<kernel::activity::CommImpl*>(pattern->comm_addr)));
-    const kernel::activity::CommImpl* synchro = static_cast<kernel::activity::CommImpl*>(temp_synchro.get_buffer());
+    mc_model_checker->get_remote_simulation().read(temp_synchro, remote(pattern->comm_addr));
+    const kernel::activity::CommImpl* synchro = temp_synchro.get_buffer();
 
     char* remote_name = mc_model_checker->get_remote_simulation().read<char*>(RemotePtr<char*>(
         (uint64_t)(synchro->get_mailbox() ? &synchro->get_mailbox()->name_ : &synchro->mbox_cpy->name_)));
@@ -233,8 +232,7 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_
 #endif
 
     Remote<kernel::activity::CommImpl> temp_comm;
-    mc_model_checker->get_remote_simulation().read(
-        temp_comm, remote(static_cast<kernel::activity::CommImpl*>(pattern->comm_addr)));
+    mc_model_checker->get_remote_simulation().read(temp_comm, remote(pattern->comm_addr));
     const kernel::activity::CommImpl* comm = temp_comm.get_buffer();
 
     char* remote_name;
index 2d62e2e..3598ae0 100644 (file)
@@ -408,8 +408,8 @@ void LivenessChecker::run()
     // For each enabled transition in the property automaton, push a
     // (application_state, automaton_state) pair to the exploration stack:
     for (int i = xbt_dynar_length(current_pair->automaton_state->out) - 1; i >= 0; i--) {
-      const xbt_automaton_transition* transition_succ = (xbt_automaton_transition_t)xbt_dynar_get_as(
-          current_pair->automaton_state->out, i, xbt_automaton_transition_t);
+      const xbt_automaton_transition* transition_succ =
+          xbt_dynar_get_as(current_pair->automaton_state->out, i, xbt_automaton_transition_t);
       if (evaluate_label(transition_succ->label, *prop_values))
         exploration_stack_.push_back(this->create_pair(current_pair.get(), transition_succ->dst, prop_values));
      }
index 98128c7..70c2982 100644 (file)
@@ -873,8 +873,8 @@ static bool heap_area_differ(StateComparator& state, const void* area1, const vo
 
   } else if ((heapinfo1->type > 0) && (heapinfo2->type > 0)) {      /* Fragmented block */
     // Fragment number:
-    ssize_t frag1 = ((uintptr_t)(ADDR2UINT(area1) % (BLOCKSIZE))) >> heapinfo1->type;
-    ssize_t frag2 = ((uintptr_t)(ADDR2UINT(area2) % (BLOCKSIZE))) >> heapinfo2->type;
+    ssize_t frag1 = (ADDR2UINT(area1) % BLOCKSIZE) >> heapinfo1->type;
+    ssize_t frag2 = (ADDR2UINT(area2) % BLOCKSIZE) >> heapinfo2->type;
 
     // Process address of the fragment_:
     void* real_addr_frag1 = (void*)((char*)real_addr_block1 + (frag1 << heapinfo1->type));
@@ -1147,8 +1147,7 @@ static bool global_variables_differ(simgrid::mc::StateComparator& state,
     // If the variable is not in this object, skip it:
     // We do not expect to find a pointer to something which is not reachable
     // by the global variables.
-    if ((char *) current_var.address < (char *) object_info->start_rw
-        || (char *) current_var.address > (char *) object_info->end_rw)
+    if ((char*)current_var.address < object_info->start_rw || (char*)current_var.address > object_info->end_rw)
       continue;
 
     const simgrid::mc::Type* bvariable_type = current_var.type;
index ad2cd74..f6f8601 100644 (file)
@@ -790,7 +790,7 @@ static void MC_dwarf_handle_scope_die(simgrid::mc::ObjectInformation* info, Dwar
 
   // TODO, support DW_AT_ranges
   uint64_t low_pc     = MC_dwarf_attr_integrate_addr(die, DW_AT_low_pc);
-  frame.range.begin() = low_pc ? (std::uint64_t)base + low_pc : 0;
+  frame.range.begin() = low_pc ? base + low_pc : 0;
   if (low_pc) {
     // DW_AT_high_pc:
     Dwarf_Attribute attr;
@@ -955,7 +955,7 @@ static std::vector<char> get_build_id(Elf* elf)
           memcmp((char*)data->d_buf + name_pos, "GNU", sizeof("GNU")) == 0) {
         XBT_DEBUG("Found GNU/NT_GNU_BUILD_ID note");
         char* start = (char*)data->d_buf + desc_pos;
-        char* end   = (char*)start + nhdr.n_descsz;
+        char* end   = start + nhdr.n_descsz;
         return std::vector<char>(start, end);
       }
     }
index fcb4fa0..2a59567 100644 (file)
@@ -89,8 +89,7 @@ bool actor_is_enabled(smx_actor_t actor)
 
     case SIMCALL_COMM_WAIT: {
       /* FIXME: check also that src and dst processes are not suspended */
-      const kernel::activity::CommImpl* act =
-          static_cast<kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
+      const kernel::activity::CommImpl* act = simcall_comm_wait__getraw__comm(req);
 
       if (act->src_timeout_ || act->dst_timeout_) {
         /* If it has a timeout it will be always be enabled (regardless of who declared the timeout),
index bdbf88b..661d830 100644 (file)
@@ -65,7 +65,7 @@ void MC_handle_comm_pattern(e_mc_call_type_t call_type, smx_simcall_t req, int v
     {
     simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> comm_addr{nullptr};
     if (call_type == MC_CALL_TYPE_WAIT)
-      comm_addr = remote(static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req)));
+      comm_addr = remote(simcall_comm_wait__getraw__comm(req));
 
     else {
       simgrid::kernel::activity::ActivityImpl* addr;
index 565aeec..53428fd 100644 (file)
@@ -22,9 +22,9 @@ static inline simgrid::kernel::activity::CommImpl* MC_get_comm(smx_simcall_t r)
 {
   switch (r->call_) {
     case SIMCALL_COMM_WAIT:
-      return static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(r));
+      return simcall_comm_wait__getraw__comm(r);
     case SIMCALL_COMM_TEST:
-      return static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_test__getraw__comm(r));
+      return simcall_comm_test__getraw__comm(r);
     default:
       return nullptr;
   }
@@ -225,8 +225,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
     }
 
     case SIMCALL_COMM_WAIT: {
-      simgrid::kernel::activity::CommImpl* remote_act =
-          static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(req));
+      simgrid::kernel::activity::CommImpl* remote_act = simcall_comm_wait__getraw__comm(req);
       char* p;
       if (value == -1) {
         type = "WaitTimeout";
@@ -239,8 +238,7 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
         simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
         const simgrid::kernel::activity::CommImpl* act;
         if (use_remote_comm) {
-          mc_model_checker->get_remote_simulation().read(
-              temp_synchro, remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
+          mc_model_checker->get_remote_simulation().read(temp_synchro, remote(remote_act));
           act = temp_synchro.get_buffer();
         } else
           act = remote_act;
@@ -260,13 +258,11 @@ std::string simgrid::mc::request_to_string(smx_simcall_t req, int value, simgrid
     }
 
     case SIMCALL_COMM_TEST: {
-      simgrid::kernel::activity::CommImpl* remote_act =
-          static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_test__getraw__comm(req));
+      simgrid::kernel::activity::CommImpl* remote_act = simcall_comm_test__getraw__comm(req);
       simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_synchro;
       const simgrid::kernel::activity::CommImpl* act;
       if (use_remote_comm) {
-        mc_model_checker->get_remote_simulation().read(
-            temp_synchro, remote(static_cast<simgrid::kernel::activity::CommImpl*>(remote_act)));
+        mc_model_checker->get_remote_simulation().read(temp_synchro, remote(remote_act));
         act = temp_synchro.get_buffer();
       } else
         act = remote_act;
index ec1e42a..d5e0c20 100644 (file)
@@ -109,7 +109,7 @@ static inline smx_simcall_t MC_state_choose_request_for_process(simgrid::mc::Sta
 
     case SIMCALL_COMM_WAIT: {
       simgrid::mc::RemotePtr<simgrid::kernel::activity::CommImpl> remote_act =
-          remote(static_cast<simgrid::kernel::activity::CommImpl*>(simcall_comm_wait__getraw__comm(&actor->simcall_)));
+          remote(simcall_comm_wait__getraw__comm(&actor->simcall_));
       simgrid::mc::Remote<simgrid::kernel::activity::CommImpl> temp_act;
       mc_model_checker->get_remote_simulation().read(temp_act, remote_act);
       const simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer();
index 05019fb..af8d7c0 100644 (file)
@@ -184,7 +184,7 @@ void AppSide::ignore_heap(void* address, std::size_t size)
     message.fragment = -1;
     heap->heapinfo[message.block].busy_block.ignore++;
   } else {
-    message.fragment = ((uintptr_t)(ADDR2UINT(address) % (BLOCKSIZE))) >> heap->heapinfo[message.block].type;
+    message.fragment = (ADDR2UINT(address) % BLOCKSIZE) >> heap->heapinfo[message.block].type;
     heap->heapinfo[message.block].busy_frag.ignore[message.fragment]++;
   }
 
index 2d79dcb..4fab967 100644 (file)
@@ -291,8 +291,7 @@ void VirtualMachineImpl::set_physical_host(s4u::Host* destination)
 
   /* Update vcpu's action for the new pm */
   /* create a cpu action bound to the pm model at the destination. */
-  kernel::resource::CpuAction* new_cpu_action =
-      static_cast<kernel::resource::CpuAction*>(destination->pimpl_cpu->execution_start(0, this->core_amount_));
+  kernel::resource::CpuAction* new_cpu_action = destination->pimpl_cpu->execution_start(0, this->core_amount_);
 
   if (action_->get_remains_no_update() > 0)
     XBT_CRITICAL("FIXME: need copy the state(?), %f", action_->get_remains_no_update());
index 809002d..4d108c2 100644 (file)
@@ -217,7 +217,8 @@ void mpi_win_get_name_(int* win, char* name, int* len, int* ierr)
 void mpi_win_allocate_(MPI_Aint* size, int* disp_unit, int* info, int* comm, void* base, int* win, int* ierr)
 {
   MPI_Win tmp;
-  *ierr =  MPI_Win_allocate( *size, *disp_unit, simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm),static_cast<void*>(base),&tmp);
+  *ierr =
+      MPI_Win_allocate(*size, *disp_unit, simgrid::smpi::Info::f2c(*info), simgrid::smpi::Comm::f2c(*comm), base, &tmp);
  if(*ierr == MPI_SUCCESS) {
    *win = tmp->add_f();
  }
index 4189478..66346e8 100644 (file)
@@ -232,7 +232,7 @@ int PMPI_Keyval_free(int* keyval) {
 MPI_Errhandler PMPI_Errhandler_f2c(MPI_Fint errhan){
   if(errhan==-1)
     return MPI_ERRHANDLER_NULL;
-  return static_cast<MPI_Errhandler>(simgrid::smpi::Errhandler::f2c(errhan));
+  return simgrid::smpi::Errhandler::f2c(errhan);
 }
 
 MPI_Fint PMPI_Errhandler_c2f(MPI_Errhandler errhan){
index 85dd53a..4e24a76 100644 (file)
@@ -157,7 +157,7 @@ int PMPI_Comm_create_group(MPI_Comm comm, MPI_Group group, int, MPI_Comm* comm_o
 MPI_Comm PMPI_Comm_f2c(MPI_Fint comm){
   if(comm==-1)
     return MPI_COMM_NULL;
-  return static_cast<MPI_Comm>(simgrid::smpi::Comm::f2c(comm));
+  return simgrid::smpi::Comm::f2c(comm);
 }
 
 MPI_Fint PMPI_Comm_c2f(MPI_Comm comm){
index d96a263..b8a2144 100644 (file)
@@ -81,7 +81,7 @@ int PMPI_Info_get_valuelen( MPI_Info info, const char *key, int *valuelen, int *
 MPI_Info PMPI_Info_f2c(MPI_Fint info){
   if(info==-1)
     return MPI_INFO_NULL;
-  return static_cast<MPI_Info>(simgrid::smpi::Info::f2c(info));
+  return simgrid::smpi::Info::f2c(info);
 }
 
 MPI_Fint PMPI_Info_c2f(MPI_Info info){
index 5dedee4..8c14f06 100644 (file)
@@ -37,7 +37,7 @@ int PMPI_Op_commutative(MPI_Op op, int* commute){
 MPI_Op PMPI_Op_f2c(MPI_Fint op){
   if(op==-1)
     return MPI_OP_NULL;
-  return static_cast<MPI_Op>(simgrid::smpi::Op::f2c(op));
+  return simgrid::smpi::Op::f2c(op);
 }
 
 MPI_Fint PMPI_Op_c2f(MPI_Op op){
index 34b7654..c64a63a 100644 (file)
@@ -788,7 +788,7 @@ int PMPI_Request_get_status( MPI_Request request, int *flag, MPI_Status *status)
 MPI_Request PMPI_Request_f2c(MPI_Fint request){
   if(request==-1)
     return MPI_REQUEST_NULL;
-  return static_cast<MPI_Request>(simgrid::smpi::Request::f2c(request));
+  return simgrid::smpi::Request::f2c(request);
 }
 
 MPI_Fint PMPI_Request_c2f(MPI_Request request) {
index 45b7844..42f1b92 100644 (file)
@@ -669,7 +669,7 @@ int PMPI_Win_free_keyval(int* keyval) {
 MPI_Win PMPI_Win_f2c(MPI_Fint win){
   if(win==-1)
     return MPI_WIN_NULL;
-  return static_cast<MPI_Win>(simgrid::smpi::Win::f2c(win));
+  return simgrid::smpi::Win::f2c(win);
 }
 
 MPI_Fint PMPI_Win_c2f(MPI_Win win){
index c28f90a..b54cd49 100644 (file)
@@ -283,7 +283,7 @@ unsigned long long smpi_rastro_timestamp ()
   unsigned long long sec = static_cast<unsigned long long>(now);
   unsigned long long pre = (now - sec) * smpi_rastro_resolution();
   smpi_bench_begin();
-  return static_cast<unsigned long long>(sec) * smpi_rastro_resolution() + pre;
+  return sec * smpi_rastro_resolution() + pre;
 }
 
 /* ****************************** Functions related to the SMPI_SAMPLE_ macros ************************************/
index c3e32fa..c2ff4c6 100644 (file)
@@ -196,7 +196,7 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v
       (static_cast<char*>(buff) < smpi_data_exe_start + smpi_data_exe_size)) {
     XBT_DEBUG("Privatization : We are copying from a zone inside global memory... Saving data to temp buffer !");
     smpi_switch_data_segment(comm->src_actor_->iface());
-    tmpbuff = static_cast<void*>(xbt_malloc(buff_size));
+    tmpbuff = xbt_malloc(buff_size);
     memcpy_private(tmpbuff, buff, private_blocks);
   }
 
index 5db2285..f62e638 100644 (file)
@@ -21,7 +21,7 @@ MPI_Errhandler Errhandler::f2c(int id) {
     char key[KEY_SIZE];
     return static_cast<MPI_Errhandler>(F2C::f2c_lookup()->at(get_key(key, id)));
   } else {
-    return static_cast<MPI_Errhandler>(MPI_ERRHANDLER_NULL);
+    return MPI_ERRHANDLER_NULL;
   }
 }
 
index 162b8de..92cee30 100644 (file)
@@ -322,7 +322,7 @@ MPI_Group Group::f2c(int id) {
     char key[KEY_SIZE];
     return static_cast<MPI_Group>(F2C::f2c_lookup()->at(get_key(key, id)));
   } else {
-    return static_cast<MPI_Group>(MPI_GROUP_NULL);
+    return MPI_GROUP_NULL;
   }
 }
 
index 58892ed..5018da9 100644 (file)
@@ -138,7 +138,7 @@ void Request::init_buffer(int count){
   // This part handles the problem of non-contiguous memory (for the unserialization at the reception)
   if ((((flags_ & MPI_REQ_RECV) != 0) && ((flags_ & MPI_REQ_ACCUMULATE) != 0)) || (old_type_->flags() & DT_FLAG_DERIVED)) {
     // This part handles the problem of non-contiguous memory
-    old_buf = const_cast<void*>(buf_);
+    old_buf = buf_;
     if (count==0){
       buf_ = nullptr;
     }else {
@@ -1055,8 +1055,8 @@ int Request::waitall(int count, MPI_Request requests[], MPI_Status status[])
       wait(&requests[c],pstat);
       index = c;
     } else {
-      index = waitany(count, (MPI_Request*)requests, pstat);
-      
+      index = waitany(count, requests, pstat);
+
       if (index == MPI_UNDEFINED)
         break;
 
@@ -1090,7 +1090,7 @@ int Request::waitsome(int incount, MPI_Request requests[], int *indices, MPI_Sta
   int index = 0;
   MPI_Status stat;
   MPI_Status *pstat = status == MPI_STATUSES_IGNORE ? MPI_STATUS_IGNORE : &stat;
-  index = waitany(incount, (MPI_Request*)requests, pstat);
+  index             = waitany(incount, requests, pstat);
   if(index==MPI_UNDEFINED) return MPI_UNDEFINED;
   if(status != MPI_STATUSES_IGNORE) {
     status[count] = *pstat;
@@ -1119,7 +1119,7 @@ MPI_Request Request::f2c(int id)
 {
   char key[KEY_SIZE];
   if(id==MPI_FORTRAN_REQUEST_NULL)
-    return static_cast<MPI_Request>(MPI_REQUEST_NULL);
+    return MPI_REQUEST_NULL;
   return static_cast<MPI_Request>(F2C::f2c_lookup()->at(get_key(key,id)));
 }
 
index 557e549..a76cf60 100644 (file)
@@ -145,7 +145,7 @@ void CpuCas01::apply_event(profile::Event* event, double value)
       get_host()->turn_off();
 
       while ((var = cnst->get_variable(&elem))) {
-        auto* action = static_cast<Action*>(var->get_id());
+        Action* action = var->get_id();
 
         if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED ||
             action->get_state() == Action::State::IGNORED) {
index 5d9a7a5..e5e7b92 100644 (file)
@@ -142,7 +142,7 @@ void LinkImpl::turn_off()
     const kernel::lmm::Element* elem = nullptr;
     double now                       = surf_get_clock();
     while ((var = get_constraint()->get_variable(&elem))) {
-      Action* action = static_cast<Action*>(var->get_id());
+      Action* action = var->get_id();
       if (action->get_state() == Action::State::INITED || action->get_state() == Action::State::STARTED) {
         action->set_finish_time(now);
         action->set_state(Action::State::FAILED);
index ea60e12..f6087ff 100644 (file)
@@ -295,7 +295,7 @@ void CpuL07::on_speed_change()
 
   get_model()->get_maxmin_system()->update_constraint_bound(get_constraint(), speed_.peak * speed_.scale);
   while ((var = get_constraint()->get_variable(&elem))) {
-    const kernel::resource::Action* action = static_cast<kernel::resource::Action*>(var->get_id());
+    const kernel::resource::Action* action = var->get_id();
 
     get_model()->get_maxmin_system()->update_variable_bound(action->get_variable(), speed_.scale * speed_.peak);
   }
index 291b2a1..cdb4e0f 100644 (file)
@@ -238,7 +238,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster
       linkUp   = simgrid::s4u::Link::by_name_or_null(tmp_link);
       linkDown = simgrid::s4u::Link::by_name_or_null(tmp_link);
 
-      auto* as_cluster = static_cast<ClusterZone*>(current_as);
+      ClusterZone* as_cluster = current_as;
       as_cluster->private_links_.insert({as_cluster->node_pos(rankId), {linkUp->get_impl(), linkDown->get_impl()}});
     }
 
@@ -667,7 +667,7 @@ void sg_platf_new_Zone_seal()
   xbt_assert(current_routing, "Cannot seal the current AS: none under construction");
   current_routing->seal();
   simgrid::s4u::NetZone::on_seal(*current_routing->get_iface());
-  current_routing = static_cast<simgrid::kernel::routing::NetZoneImpl*>(current_routing->get_father());
+  current_routing = current_routing->get_father();
 }
 
 /** @brief Add a link connecting a host to the rest of its AS (which must be cluster or vivaldi) */
index 31bbef2..6778ca1 100644 (file)
@@ -160,7 +160,7 @@ void xbt_dynar_free(xbt_dynar_t* dynar)
  */
 unsigned long xbt_dynar_length(const_xbt_dynar_t dynar)
 {
-  return (dynar ? (unsigned long) dynar->used : (unsigned long) 0);
+  return (dynar ? dynar->used : 0UL);
 }
 
 /**@brief check if a dynar is empty
@@ -399,7 +399,7 @@ void xbt_dynar_map(const_xbt_dynar_t dynar, void_f_pvoid_t op)
   _sanity_check_dynar(dynar);
 
   for (i = 0; i < used; i++) {
-    char* elm = (char*) data + i * elmsize;
+    char* elm = data + i * elmsize;
     op(elm);
   }
 }
index 0da4878..ce7b5e2 100644 (file)
@@ -82,8 +82,10 @@ void mfree(struct mdesc *mdp, void *ptr)
       /* Mark all my ex-blocks as free */
       for (it=0; it<mdp->heapinfo[block].busy_block.size; it++) {
         if (mdp->heapinfo[block+it].type < 0) {
-          fprintf(stderr,"Internal Error: Asked to free a block already marked as free (block=%lu it=%d type=%lu). Please report this bug.\n",
-                  (unsigned long)block,it,(unsigned long)mdp->heapinfo[block].type);
+          fprintf(stderr,
+                  "Internal Error: Asked to free a block already marked as free (block=%zu it=%d type=%d). "
+                  "Please report this bug.\n",
+                  block, it, mdp->heapinfo[block].type);
           abort();
         }
         mdp->heapinfo[block+it].type = MMALLOC_TYPE_FREE;
@@ -101,8 +103,10 @@ void mfree(struct mdesc *mdp, void *ptr)
       /* Mark all my ex-blocks as free */
       for (it=0; it<mdp->heapinfo[block].free_block.size; it++) {
         if (mdp->heapinfo[block+it].type <0) {
-          fprintf(stderr,"Internal error: Asked to free a block already marked as free (block=%lu it=%d/%lu type=%lu). Please report this bug.\n",
-                  (unsigned long)block,it,(unsigned long)mdp->heapinfo[block].free_block.size,(unsigned long)mdp->heapinfo[block].type);
+          fprintf(stderr,
+                  "Internal error: Asked to free a block already marked as free (block=%zu it=%d/%zu type=%d). "
+                  "Please report this bug.\n",
+                  block, it, mdp->heapinfo[block].free_block.size, mdp->heapinfo[block].type);
           abort();
         }
         mdp->heapinfo[block+it].type = MMALLOC_TYPE_FREE;
@@ -189,7 +193,7 @@ void mfree(struct mdesc *mdp, void *ptr)
       mdp -> heapstats.chunks_free -= BLOCKSIZE >> type;
       mdp -> heapstats.bytes_free -= BLOCKSIZE;
 
-      mfree((void *) mdp, (void *) ADDRESS(block));
+      mfree(mdp, ADDRESS(block));
     } else if (mdp->heapinfo[block].busy_frag.nfree != 0) {
       /* If some fragments of this block are free, you know what? I'm already happy. */
       ++mdp->heapinfo[block].busy_frag.nfree;
index e3ba23c..d9a44ef 100644 (file)
@@ -282,7 +282,9 @@ void *mmalloc_no_memset(xbt_mheap_t mdp, size_t size)
     block         = MALLOC_SEARCH_START;
     while (mdp->heapinfo[block].free_block.size < blocks) {
       if (mdp->heapinfo[block].type >=0) { // Don't trust xbt_die and friends in malloc-level library, you fool!
-        fprintf(stderr,"Internal error: found a free block not marked as such (block=%lu type=%lu). Please report this bug.\n",(unsigned long)block,(unsigned long)mdp->heapinfo[block].type);
+        fprintf(stderr,
+                "Internal error: found a free block not marked as such (block=%zu type=%d). Please report this bug.\n",
+                block, mdp->heapinfo[block].type);
         abort();
       }
 
index 99bc655..d59a2a3 100644 (file)
@@ -79,7 +79,7 @@ void *mmorecore(struct mdesc *mdp, ssize_t size)
     /* We are deallocating memory.  If the amount requested would cause us to try to deallocate back past the base of
      * the mmap'd region then die verbosely.  Otherwise, deallocate the memory and return the old break value. */
     if (((char*)mdp->breakval) + size >= (char*)mdp->base) {
-      result        = (void*)mdp->breakval;
+      result        = mdp->breakval;
       mdp->breakval = (char*)mdp->breakval + size;
       moveto = PAGE_ALIGN(mdp->breakval);
       munmap(moveto, (size_t)(((char*)mdp->top) - ((char*)moveto)) - 1);
@@ -134,11 +134,11 @@ void *mmorecore(struct mdesc *mdp, ssize_t size)
         mdp->base = mdp->breakval = mapto;
 
       mdp->top      = PAGE_ALIGN((char*)mdp->breakval + size);
-      result = (void *) mdp->breakval;
+      result        = mdp->breakval;
       mdp->breakval = (char*)mdp->breakval + size;
     } else {
       /* Memory is already mapped, we only need to increase the breakval: */
-      result = (void *) mdp->breakval;
+      result        = mdp->breakval;
       mdp->breakval = (char*)mdp->breakval + size;
     }
   }
index 4d67b49..b80030c 100644 (file)
@@ -80,7 +80,7 @@ double xbt_os_time(void)
   return (double) (time(NULL));
 #endif                          /* HAVE_GETTIMEOFDAY? */
 
-  return (double) (tv.tv_sec + tv.tv_usec / 1000000.0);
+  return tv.tv_sec + tv.tv_usec / 1000000.0;
 }
 
 void xbt_os_sleep(double sec)