From c66bb944af7d961fa6908a18a9d5ea949d2d390a Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 1 Jul 2020 16:41:22 +0200 Subject: [PATCH] [sonar] Remove redundant casts. --- examples/c/dht-kademlia/node.c | 2 +- examples/s4u/dht-kademlia/node.cpp | 2 +- src/kernel/lmm/maxmin.cpp | 2 +- src/kernel/routing/DijkstraZone.cpp | 4 ++-- src/kernel/routing/NetZoneImpl.cpp | 8 ++++---- src/kernel/routing/TorusZone.cpp | 2 +- .../checker/CommunicationDeterminismChecker.cpp | 8 +++----- src/mc/checker/LivenessChecker.cpp | 4 ++-- src/mc/compare.cpp | 7 +++---- src/mc/inspect/mc_dwarf.cpp | 4 ++-- src/mc/mc_base.cpp | 3 +-- src/mc/mc_comm_pattern.cpp | 2 +- src/mc/mc_request.cpp | 16 ++++++---------- src/mc/mc_state.cpp | 2 +- src/mc/remote/AppSide.cpp | 2 +- src/plugins/vm/VirtualMachineImpl.cpp | 3 +-- src/smpi/bindings/smpi_f77.cpp | 3 ++- src/smpi/bindings/smpi_pmpi.cpp | 2 +- src/smpi/bindings/smpi_pmpi_comm.cpp | 2 +- src/smpi/bindings/smpi_pmpi_info.cpp | 2 +- src/smpi/bindings/smpi_pmpi_op.cpp | 2 +- src/smpi/bindings/smpi_pmpi_request.cpp | 2 +- src/smpi/bindings/smpi_pmpi_win.cpp | 2 +- src/smpi/internals/smpi_bench.cpp | 2 +- src/smpi/internals/smpi_global.cpp | 2 +- src/smpi/mpi/smpi_errhandler.cpp | 2 +- src/smpi/mpi/smpi_group.cpp | 2 +- src/smpi/mpi/smpi_request.cpp | 10 +++++----- src/surf/cpu_cas01.cpp | 2 +- src/surf/network_interface.cpp | 2 +- src/surf/ptask_L07.cpp | 2 +- src/surf/sg_platf.cpp | 4 ++-- src/xbt/dynar.cpp | 4 ++-- src/xbt/mmalloc/mfree.c | 14 +++++++++----- src/xbt/mmalloc/mmalloc.c | 4 +++- src/xbt/mmalloc/mmorecore.c | 6 +++--- src/xbt/xbt_os_time.c | 2 +- 37 files changed, 71 insertions(+), 73 deletions(-) diff --git a/examples/c/dht-kademlia/node.c b/examples/c/dht-kademlia/node.c index 13d287f4ff..79d228b4f6 100644 --- a/examples/c/dht-kademlia/node.c +++ b/examples/c/dht-kademlia/node.c @@ -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; } } diff --git a/examples/s4u/dht-kademlia/node.cpp b/examples/s4u/dht-kademlia/node.cpp index d331cc361b..c8ac4633f5 100644 --- a/examples/s4u/dht-kademlia/node.cpp +++ b/examples/s4u/dht-kademlia/node.cpp @@ -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; } } diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index f506fafe6c..7e25ce0a58 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -514,7 +514,7 @@ template void System::lmm_solve(CnstList& cnst_list) cnst.usage_ = elem.consumption_weight / elem.variable->sharing_penalty_; elem.make_active(); - resource::Action* action = static_cast(elem.variable->id_); + resource::Action* action = elem.variable->id_; if (modified_set_ && not action->is_within_modified_set()) modified_set_->push_back(*action); } diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index b9d79f8eec..d5c854f40c 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -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(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(link)->get_latency(); + *lat += link->get_latency(); } } diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 5085d81410..0849a033dc 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -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(current->get_father()); + current = current->get_father(); } std::vector path_dst; current = dst->get_englobing_zone(); while (current != nullptr) { path_dst.push_back(current); - current = static_cast(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 path_src; NetZoneImpl* current = src->get_englobing_zone(); while (current != nullptr) { - path_src.push_back(static_cast(current)); + path_src.push_back(current); current = current->father_; } std::vector path_dst; current = dst->get_englobing_zone(); while (current != nullptr) { - path_dst.push_back(static_cast(current)); + path_dst.push_back(current); current = current->father_; } diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index bca85bdd66..574153e556 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -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(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) diff --git a/src/mc/checker/CommunicationDeterminismChecker.cpp b/src/mc/checker/CommunicationDeterminismChecker.cpp index 7d112063e6..37acf2e629 100644 --- a/src/mc/checker/CommunicationDeterminismChecker.cpp +++ b/src/mc/checker/CommunicationDeterminismChecker.cpp @@ -185,9 +185,8 @@ void CommunicationDeterminismChecker::get_comm_pattern(smx_simcall_t request, e_ pattern->comm_addr = static_cast(simcall_comm_isend__getraw__result(request)); Remote temp_synchro; - mc_model_checker->get_remote_simulation().read( - temp_synchro, remote(static_cast(pattern->comm_addr))); - const kernel::activity::CommImpl* synchro = static_cast(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(RemotePtr( (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 temp_comm; - mc_model_checker->get_remote_simulation().read( - temp_comm, remote(static_cast(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; diff --git a/src/mc/checker/LivenessChecker.cpp b/src/mc/checker/LivenessChecker.cpp index 2d62e2e5ac..3598ae060a 100644 --- a/src/mc/checker/LivenessChecker.cpp +++ b/src/mc/checker/LivenessChecker.cpp @@ -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)); } diff --git a/src/mc/compare.cpp b/src/mc/compare.cpp index 98128c78ed..70c2982251 100644 --- a/src/mc/compare.cpp +++ b/src/mc/compare.cpp @@ -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; diff --git a/src/mc/inspect/mc_dwarf.cpp b/src/mc/inspect/mc_dwarf.cpp index ad2cd742d9..f6f8601e95 100644 --- a/src/mc/inspect/mc_dwarf.cpp +++ b/src/mc/inspect/mc_dwarf.cpp @@ -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 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(start, end); } } diff --git a/src/mc/mc_base.cpp b/src/mc/mc_base.cpp index fcb4fa08e5..2a59567386 100644 --- a/src/mc/mc_base.cpp +++ b/src/mc/mc_base.cpp @@ -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(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), diff --git a/src/mc/mc_comm_pattern.cpp b/src/mc/mc_comm_pattern.cpp index bdbf88bb14..661d8301d2 100644 --- a/src/mc/mc_comm_pattern.cpp +++ b/src/mc/mc_comm_pattern.cpp @@ -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 comm_addr{nullptr}; if (call_type == MC_CALL_TYPE_WAIT) - comm_addr = remote(static_cast(simcall_comm_wait__getraw__comm(req))); + comm_addr = remote(simcall_comm_wait__getraw__comm(req)); else { simgrid::kernel::activity::ActivityImpl* addr; diff --git a/src/mc/mc_request.cpp b/src/mc/mc_request.cpp index 565aeec692..53428fdc89 100644 --- a/src/mc/mc_request.cpp +++ b/src/mc/mc_request.cpp @@ -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(simcall_comm_wait__getraw__comm(r)); + return simcall_comm_wait__getraw__comm(r); case SIMCALL_COMM_TEST: - return static_cast(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(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 temp_synchro; const simgrid::kernel::activity::CommImpl* act; if (use_remote_comm) { - mc_model_checker->get_remote_simulation().read( - temp_synchro, remote(static_cast(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(simcall_comm_test__getraw__comm(req)); + simgrid::kernel::activity::CommImpl* remote_act = simcall_comm_test__getraw__comm(req); simgrid::mc::Remote temp_synchro; const simgrid::kernel::activity::CommImpl* act; if (use_remote_comm) { - mc_model_checker->get_remote_simulation().read( - temp_synchro, remote(static_cast(remote_act))); + mc_model_checker->get_remote_simulation().read(temp_synchro, remote(remote_act)); act = temp_synchro.get_buffer(); } else act = remote_act; diff --git a/src/mc/mc_state.cpp b/src/mc/mc_state.cpp index ec1e42ac48..d5e0c204c0 100644 --- a/src/mc/mc_state.cpp +++ b/src/mc/mc_state.cpp @@ -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 remote_act = - remote(static_cast(simcall_comm_wait__getraw__comm(&actor->simcall_))); + remote(simcall_comm_wait__getraw__comm(&actor->simcall_)); simgrid::mc::Remote temp_act; mc_model_checker->get_remote_simulation().read(temp_act, remote_act); const simgrid::kernel::activity::CommImpl* act = temp_act.get_buffer(); diff --git a/src/mc/remote/AppSide.cpp b/src/mc/remote/AppSide.cpp index 05019fb49d..af8d7c0d29 100644 --- a/src/mc/remote/AppSide.cpp +++ b/src/mc/remote/AppSide.cpp @@ -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]++; } diff --git a/src/plugins/vm/VirtualMachineImpl.cpp b/src/plugins/vm/VirtualMachineImpl.cpp index 2d79dcbbb6..4fab967633 100644 --- a/src/plugins/vm/VirtualMachineImpl.cpp +++ b/src/plugins/vm/VirtualMachineImpl.cpp @@ -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(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()); diff --git a/src/smpi/bindings/smpi_f77.cpp b/src/smpi/bindings/smpi_f77.cpp index 809002d7c8..4d108c298c 100644 --- a/src/smpi/bindings/smpi_f77.cpp +++ b/src/smpi/bindings/smpi_f77.cpp @@ -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(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(); } diff --git a/src/smpi/bindings/smpi_pmpi.cpp b/src/smpi/bindings/smpi_pmpi.cpp index 41894787d9..66346e8e01 100644 --- a/src/smpi/bindings/smpi_pmpi.cpp +++ b/src/smpi/bindings/smpi_pmpi.cpp @@ -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(simgrid::smpi::Errhandler::f2c(errhan)); + return simgrid::smpi::Errhandler::f2c(errhan); } MPI_Fint PMPI_Errhandler_c2f(MPI_Errhandler errhan){ diff --git a/src/smpi/bindings/smpi_pmpi_comm.cpp b/src/smpi/bindings/smpi_pmpi_comm.cpp index 85dd53aa74..4e24a76a6c 100644 --- a/src/smpi/bindings/smpi_pmpi_comm.cpp +++ b/src/smpi/bindings/smpi_pmpi_comm.cpp @@ -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(simgrid::smpi::Comm::f2c(comm)); + return simgrid::smpi::Comm::f2c(comm); } MPI_Fint PMPI_Comm_c2f(MPI_Comm comm){ diff --git a/src/smpi/bindings/smpi_pmpi_info.cpp b/src/smpi/bindings/smpi_pmpi_info.cpp index d96a263052..b8a21443c2 100644 --- a/src/smpi/bindings/smpi_pmpi_info.cpp +++ b/src/smpi/bindings/smpi_pmpi_info.cpp @@ -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(simgrid::smpi::Info::f2c(info)); + return simgrid::smpi::Info::f2c(info); } MPI_Fint PMPI_Info_c2f(MPI_Info info){ diff --git a/src/smpi/bindings/smpi_pmpi_op.cpp b/src/smpi/bindings/smpi_pmpi_op.cpp index 5dedee4a9b..8c14f06d5b 100644 --- a/src/smpi/bindings/smpi_pmpi_op.cpp +++ b/src/smpi/bindings/smpi_pmpi_op.cpp @@ -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(simgrid::smpi::Op::f2c(op)); + return simgrid::smpi::Op::f2c(op); } MPI_Fint PMPI_Op_c2f(MPI_Op op){ diff --git a/src/smpi/bindings/smpi_pmpi_request.cpp b/src/smpi/bindings/smpi_pmpi_request.cpp index 34b7654bbf..c64a63a6a3 100644 --- a/src/smpi/bindings/smpi_pmpi_request.cpp +++ b/src/smpi/bindings/smpi_pmpi_request.cpp @@ -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(simgrid::smpi::Request::f2c(request)); + return simgrid::smpi::Request::f2c(request); } MPI_Fint PMPI_Request_c2f(MPI_Request request) { diff --git a/src/smpi/bindings/smpi_pmpi_win.cpp b/src/smpi/bindings/smpi_pmpi_win.cpp index 45b784428d..42f1b92681 100644 --- a/src/smpi/bindings/smpi_pmpi_win.cpp +++ b/src/smpi/bindings/smpi_pmpi_win.cpp @@ -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(simgrid::smpi::Win::f2c(win)); + return simgrid::smpi::Win::f2c(win); } MPI_Fint PMPI_Win_c2f(MPI_Win win){ diff --git a/src/smpi/internals/smpi_bench.cpp b/src/smpi/internals/smpi_bench.cpp index c28f90a63c..b54cd4944b 100644 --- a/src/smpi/internals/smpi_bench.cpp +++ b/src/smpi/internals/smpi_bench.cpp @@ -283,7 +283,7 @@ unsigned long long smpi_rastro_timestamp () unsigned long long sec = static_cast(now); unsigned long long pre = (now - sec) * smpi_rastro_resolution(); smpi_bench_begin(); - return static_cast(sec) * smpi_rastro_resolution() + pre; + return sec * smpi_rastro_resolution() + pre; } /* ****************************** Functions related to the SMPI_SAMPLE_ macros ************************************/ diff --git a/src/smpi/internals/smpi_global.cpp b/src/smpi/internals/smpi_global.cpp index c3e32fa864..c2ff4c60a6 100644 --- a/src/smpi/internals/smpi_global.cpp +++ b/src/smpi/internals/smpi_global.cpp @@ -196,7 +196,7 @@ void smpi_comm_copy_buffer_callback(simgrid::kernel::activity::CommImpl* comm, v (static_cast(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(xbt_malloc(buff_size)); + tmpbuff = xbt_malloc(buff_size); memcpy_private(tmpbuff, buff, private_blocks); } diff --git a/src/smpi/mpi/smpi_errhandler.cpp b/src/smpi/mpi/smpi_errhandler.cpp index 5db2285323..f62e6387a6 100644 --- a/src/smpi/mpi/smpi_errhandler.cpp +++ b/src/smpi/mpi/smpi_errhandler.cpp @@ -21,7 +21,7 @@ MPI_Errhandler Errhandler::f2c(int id) { char key[KEY_SIZE]; return static_cast(F2C::f2c_lookup()->at(get_key(key, id))); } else { - return static_cast(MPI_ERRHANDLER_NULL); + return MPI_ERRHANDLER_NULL; } } diff --git a/src/smpi/mpi/smpi_group.cpp b/src/smpi/mpi/smpi_group.cpp index 162b8deb08..92cee3055b 100644 --- a/src/smpi/mpi/smpi_group.cpp +++ b/src/smpi/mpi/smpi_group.cpp @@ -322,7 +322,7 @@ MPI_Group Group::f2c(int id) { char key[KEY_SIZE]; return static_cast(F2C::f2c_lookup()->at(get_key(key, id))); } else { - return static_cast(MPI_GROUP_NULL); + return MPI_GROUP_NULL; } } diff --git a/src/smpi/mpi/smpi_request.cpp b/src/smpi/mpi/smpi_request.cpp index 58892ed47c..5018da95b2 100644 --- a/src/smpi/mpi/smpi_request.cpp +++ b/src/smpi/mpi/smpi_request.cpp @@ -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(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_NULL); + return MPI_REQUEST_NULL; return static_cast(F2C::f2c_lookup()->at(get_key(key,id))); } diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index 557e549d78..a76cf6076f 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -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(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) { diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 5d9a7a522c..e5e7b923b7 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -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(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); diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index ea60e12d58..f6087ffd53 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -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(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); } diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index 291b2a18f9..cdb4e0ff91 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -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(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(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) */ diff --git a/src/xbt/dynar.cpp b/src/xbt/dynar.cpp index 31bbef2572..6778ca1f92 100644 --- a/src/xbt/dynar.cpp +++ b/src/xbt/dynar.cpp @@ -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); } } diff --git a/src/xbt/mmalloc/mfree.c b/src/xbt/mmalloc/mfree.c index 0da4878d8e..ce7b5e2d50 100644 --- a/src/xbt/mmalloc/mfree.c +++ b/src/xbt/mmalloc/mfree.c @@ -82,8 +82,10 @@ void mfree(struct mdesc *mdp, void *ptr) /* Mark all my ex-blocks as free */ for (it=0; itheapinfo[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; itheapinfo[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; diff --git a/src/xbt/mmalloc/mmalloc.c b/src/xbt/mmalloc/mmalloc.c index e3ba23c211..d9a44efb87 100644 --- a/src/xbt/mmalloc/mmalloc.c +++ b/src/xbt/mmalloc/mmalloc.c @@ -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(); } diff --git a/src/xbt/mmalloc/mmorecore.c b/src/xbt/mmalloc/mmorecore.c index 99bc655ac7..d59a2a3c75 100644 --- a/src/xbt/mmalloc/mmorecore.c +++ b/src/xbt/mmalloc/mmorecore.c @@ -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; } } diff --git a/src/xbt/xbt_os_time.c b/src/xbt/xbt_os_time.c index 4d67b49857..b80030cbbb 100644 --- a/src/xbt/xbt_os_time.c +++ b/src/xbt/xbt_os_time.c @@ -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) -- 2.20.1