From 1b89437671ba572a199dd4ff5766ba82720cdf03 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Sat, 3 Oct 2020 21:53:46 +0200 Subject: [PATCH] [sonar] Replace redundant type with "auto" (include/ and src/). --- include/simgrid/s4u/Engine.hpp | 2 +- include/xbt/automaton.hpp | 2 +- include/xbt/config.hpp | 2 +- include/xbt/functional.hpp | 8 ++++---- src/bindings/lua/lua_host.cpp | 6 +++--- src/bindings/lua/lua_platf.cpp | 4 ++-- src/bindings/python/simgrid_python.cpp | 2 +- src/include/xbt/parmap.hpp | 2 +- src/instr/instr_platform.cpp | 24 +++++++++++----------- src/instr/jedule/jedule_platform.cpp | 2 +- src/kernel/activity/CommImpl.cpp | 6 ++---- src/kernel/activity/MailboxImpl.cpp | 2 +- src/kernel/activity/SemaphoreImpl.cpp | 2 +- src/kernel/actor/ActorImpl.cpp | 6 +++--- src/kernel/context/Context.hpp | 2 +- src/kernel/context/ContextBoost.cpp | 2 +- src/kernel/context/ContextSwapped.cpp | 6 +++--- src/kernel/context/ContextThread.cpp | 6 +++--- src/kernel/lmm/maxmin.cpp | 6 +++--- src/kernel/resource/profile/Profile.cpp | 4 ++-- src/kernel/routing/DijkstraZone.cpp | 4 ++-- src/kernel/routing/FatTreeZone.cpp | 2 +- src/kernel/routing/NetZoneImpl.cpp | 4 ++-- src/kernel/routing/RoutedZone.cpp | 8 ++++---- src/kernel/routing/TorusZone.cpp | 4 ++-- src/plugins/file_system/s4u_FileSystem.cpp | 9 ++++---- src/plugins/host_energy.cpp | 2 +- src/plugins/vm/VmLiveMigration.cpp | 12 +++++------ src/s4u/s4u_Actor.cpp | 8 ++++---- src/s4u/s4u_Mailbox.cpp | 4 ++-- src/simdag/sd_global.cpp | 4 ++-- src/simdag/sd_task.cpp | 4 ++-- src/simix/smx_global.cpp | 2 +- src/surf/HostImpl.cpp | 4 ++-- src/surf/cpu_interface.cpp | 2 +- src/surf/network_cm02.cpp | 2 +- src/surf/network_ib.cpp | 8 ++++---- src/surf/network_interface.cpp | 4 ++-- src/surf/network_wifi.cpp | 2 +- src/surf/ptask_L07.cpp | 12 +++++------ src/surf/sg_platf.cpp | 17 ++++++++------- src/surf/surf_interface.cpp | 2 +- src/surf/xml/surfxml_sax_cb.cpp | 2 +- src/xbt/config.cpp | 2 +- src/xbt/dict.cpp | 2 +- src/xbt/dict_test.cpp | 8 ++++---- src/xbt/dynar.cpp | 4 ++-- src/xbt/xbt_log_appender_file.cpp | 4 ++-- src/xbt/xbt_log_layout_format.cpp | 2 +- src/xbt/xbt_str_test.cpp | 2 +- 50 files changed, 119 insertions(+), 123 deletions(-) diff --git a/include/simgrid/s4u/Engine.hpp b/include/simgrid/s4u/Engine.hpp index 249000775f..086849f43a 100644 --- a/include/simgrid/s4u/Engine.hpp +++ b/include/simgrid/s4u/Engine.hpp @@ -198,7 +198,7 @@ XBT_PRIVATE void get_filtered_netzones_recursive(const s4u::NetZone* current, st "Filtering netzones is only possible for subclasses of kernel::routing::NetZoneImpl"); for (auto const& elem : current->get_children()) { get_filtered_netzones_recursive(elem, whereto); - T* elem_impl = dynamic_cast(elem->get_impl()); + auto* elem_impl = dynamic_cast(elem->get_impl()); if (elem_impl != nullptr) whereto->push_back(elem_impl); } diff --git a/include/xbt/automaton.hpp b/include/xbt/automaton.hpp index 58fdd7553c..b9bea1e7fb 100644 --- a/include/xbt/automaton.hpp +++ b/include/xbt/automaton.hpp @@ -21,7 +21,7 @@ namespace xbt { */ template xbt_automaton_propositional_symbol_t add_proposition(const_xbt_automaton_t a, const char* id, F f) { - F* callback = new F(std::move(f)); + auto* callback = new F(std::move(f)); return xbt_automaton_propositional_symbol_new_callback( a, id, [](void* callback) -> int { return (*(F*)callback)(); }, diff --git a/include/xbt/config.hpp b/include/xbt/config.hpp index 7dedb719c5..28a83ecfa6 100644 --- a/include/xbt/config.hpp +++ b/include/xbt/config.hpp @@ -162,7 +162,7 @@ bind_flag(T& value, const char* name, const char* description, std::map(&buffer); + auto* src = reinterpret_cast(&buffer); F code = std::move(*src); src->~F(); // NOTE: std::forward(args)... is correct. @@ -194,13 +194,13 @@ private: std::is_trivially_destructible::value ? static_cast(nullptr) : [](TaskUnion& buffer) { - F* code = reinterpret_cast(&buffer); + auto* code = reinterpret_cast(&buffer); code->~F(); }, // Move: [](TaskUnion& dst, TaskUnion& src) { - F* src_code = reinterpret_cast(&src); - F* dst_code = reinterpret_cast(&dst); + auto* src_code = reinterpret_cast(&src); + auto* dst_code = reinterpret_cast(&dst); new(dst_code) F(std::move(*src_code)); src_code->~F(); } diff --git a/src/bindings/lua/lua_host.cpp b/src/bindings/lua/lua_host.cpp index 59361fe515..298f30fd1c 100644 --- a/src/bindings/lua/lua_host.cpp +++ b/src/bindings/lua/lua_host.cpp @@ -27,7 +27,7 @@ sg_host_t sglua_check_host(lua_State * L, int index) { luaL_checktype(L, index, LUA_TTABLE); lua_getfield(L, index, HOST_FIELDNAME); - sg_host_t *pi = (sg_host_t *) luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME); + auto* pi = static_cast(luaL_checkudata(L, lua_gettop(L), HOST_MODULE_NAME)); lua_pop(L, 1); xbt_assert(pi != nullptr, "luaL_checkudata() returned nullptr"); sg_host_t ht = *pi; @@ -54,7 +54,7 @@ static int l_host_get_by_name(lua_State * L) lua_ensure(host, "No host name '%s' found.", name); lua_newtable(L); /* table */ - sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t)); /* table userdatum */ + auto* lua_host = static_cast(lua_newuserdata(L, sizeof(sg_host_t))); /* table userdatum */ *lua_host = host; luaL_getmetatable(L, HOST_MODULE_NAME); /* table userdatum metatable */ lua_setmetatable(L, -2); /* table userdatum */ @@ -105,7 +105,7 @@ static int l_host_at(lua_State * L) std::vector hosts = simgrid::s4u::Engine::get_instance()->get_all_hosts(); sg_host_t host = hosts[index - 1]; // lua indexing start by 1 (lua[1] <=> C[0]) lua_newtable(L); /* create a table, put the userdata on top of it */ - sg_host_t *lua_host = (sg_host_t *) lua_newuserdata(L, sizeof(sg_host_t)); + auto* lua_host = static_cast(lua_newuserdata(L, sizeof(sg_host_t))); *lua_host = host; luaL_getmetatable(L, HOST_MODULE_NAME); lua_setmetatable(L, -2); diff --git a/src/bindings/lua/lua_platf.cpp b/src/bindings/lua/lua_platf.cpp index b29dcde512..b10982d41d 100644 --- a/src/bindings/lua/lua_platf.cpp +++ b/src/bindings/lua/lua_platf.cpp @@ -499,8 +499,8 @@ int console_AS_open(lua_State *L) { /* Build a Lua representation of the new AS on the stack */ lua_newtable(L); - simgrid::kernel::routing::NetZoneImpl** lua_as = (simgrid::kernel::routing::NetZoneImpl**)lua_newuserdata( - L, sizeof(simgrid::kernel::routing::NetZoneImpl*)); /* table userdatum */ + auto* lua_as = static_cast( + lua_newuserdata(L, sizeof(simgrid::kernel::routing::NetZoneImpl*))); /* table userdatum */ *lua_as = new_as; luaL_getmetatable(L, PLATF_MODULE_NAME); /* table userdatum metatable */ lua_setmetatable(L, -2); /* table userdatum */ diff --git a/src/bindings/python/simgrid_python.cpp b/src/bindings/python/simgrid_python.cpp index c92a795d44..75d9f7560a 100644 --- a/src/bindings/python/simgrid_python.cpp +++ b/src/bindings/python/simgrid_python.cpp @@ -152,7 +152,7 @@ PYBIND11_MODULE(simgrid, m) py::class_(m, "Engine", "Simulation Engine") .def(py::init([](std::vector args) { static char noarg[] = {'\0'}; - int argc = static_cast(args.size()); + auto argc = static_cast(args.size()); auto argv = std::make_unique(argc + 1); for (int i = 0; i != argc; ++i) argv[i] = args[i].empty() ? noarg : &args[i].front(); diff --git a/src/include/xbt/parmap.hpp b/src/include/xbt/parmap.hpp index 295ad660f6..ac909e78dd 100644 --- a/src/include/xbt/parmap.hpp +++ b/src/include/xbt/parmap.hpp @@ -167,7 +167,7 @@ template Parmap::Parmap(unsigned num_workers, e_xbt_parmap_mode_ this->workers[0] = nullptr; for (unsigned i = 1; i < num_workers; i++) { - ThreadData* data = new ThreadData(*this, i); + auto* data = new ThreadData(*this, i); this->workers[i] = new std::thread(worker_main, data); /* Bind the worker to a core if possible */ diff --git a/src/instr/instr_platform.cpp b/src/instr/instr_platform.cpp index f0f6442bf6..26acc23a17 100644 --- a/src/instr/instr_platform.cpp +++ b/src/instr/instr_platform.cpp @@ -134,9 +134,9 @@ static void recursiveGraphExtraction(const simgrid::s4u::NetZone* netzone, conta } } - xbt_graph_t graph = xbt_graph_new_graph(0, nullptr); - std::map* nodes = new std::map(); - std::map* edges = new std::map(); + auto* graph = xbt_graph_new_graph(0, nullptr); + auto* nodes = new std::map(); + auto* edges = new std::map(); netzone->get_impl()->get_graph(graph, nodes, edges); for (auto elm : *edges) { @@ -222,9 +222,9 @@ namespace instr { void platform_graph_export_graphviz(const std::string& output_filename) { - xbt_graph_t g = xbt_graph_new_graph(0, nullptr); - std::map* nodes = new std::map(); - std::map* edges = new std::map(); + auto* g = xbt_graph_new_graph(0, nullptr); + auto* nodes = new std::map(); + auto* edges = new std::map(); s4u::Engine::get_instance()->get_netzone_root()->extract_xbt_graph(g, nodes, edges); std::ofstream fs; @@ -266,7 +266,7 @@ static void on_netzone_creation(s4u::NetZone const& netzone) { std::string id = netzone.get_name(); if (Container::get_root() == nullptr) { - NetZoneContainer* root = new NetZoneContainer(id, 0, nullptr); + auto* root = new NetZoneContainer(id, 0, nullptr); xbt_assert(Container::get_root() == root); if (TRACE_smpi_is_enabled()) { @@ -286,8 +286,8 @@ static void on_netzone_creation(s4u::NetZone const& netzone) } if (TRACE_needs_platform()) { - unsigned level = static_cast(currentContainer.size()); - NetZoneContainer* container = new NetZoneContainer(id, level, currentContainer.back()); + auto level = static_cast(currentContainer.size()); + auto* container = new NetZoneContainer(id, level, currentContainer.back()); currentContainer.push_back(container); } } @@ -297,7 +297,7 @@ static void on_link_creation(s4u::Link const& link) if (currentContainer.empty()) // No ongoing parsing. Are you creating the loopback? return; - Container* container = new Container(link.get_name(), "LINK", currentContainer.back()); + auto* container = new Container(link.get_name(), "LINK", currentContainer.back()); if ((TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) && (not TRACE_disable_link())) { VariableType* bandwidth = container->type_->by_name_or_create("bandwidth", ""); @@ -343,7 +343,7 @@ static void on_host_creation(s4u::Host const& host) static void on_action_state_change(kernel::resource::Action const& action, kernel::resource::Action::State /* previous */) { - unsigned n = static_cast(action.get_variable()->get_number_of_constraint()); + auto n = static_cast(action.get_variable()->get_number_of_constraint()); for (unsigned i = 0; i < n; i++) { double value = action.get_variable()->get_value() * action.get_variable()->get_constraint_weight(i); @@ -366,7 +366,7 @@ static void on_action_state_change(kernel::resource::Action const& action, static void on_platform_created() { currentContainer.clear(); - std::set* filter = new std::set(); + auto* filter = new std::set(); XBT_DEBUG("Starting graph extraction."); recursiveGraphExtraction(s4u::Engine::get_instance()->get_netzone_root(), Container::get_root(), filter); XBT_DEBUG("Graph extraction finished."); diff --git a/src/instr/jedule/jedule_platform.cpp b/src/instr/jedule/jedule_platform.cpp index 2b065312cb..1a6ce7e392 100644 --- a/src/instr/jedule/jedule_platform.cpp +++ b/src/instr/jedule/jedule_platform.cpp @@ -58,7 +58,7 @@ void Container::create_hierarchy(const_sg_netzone_t from_as) this->add_resources(table); } else { for (auto const& nz : from_as->get_children()) { - jed_container_t child_container = new simgrid::jedule::Container(nz->get_name()); + auto* child_container = new simgrid::jedule::Container(nz->get_name()); this->add_child(child_container); child_container->create_hierarchy(nz); } diff --git a/src/kernel/activity/CommImpl.cpp b/src/kernel/activity/CommImpl.cpp index 63cb6a505a..91e3f17297 100644 --- a/src/kernel/activity/CommImpl.cpp +++ b/src/kernel/activity/CommImpl.cpp @@ -41,8 +41,7 @@ XBT_PRIVATE simgrid::kernel::activity::ActivityImplPtr simcall_HANDLER_comm_isen XBT_DEBUG("send from mailbox %p", mbox); /* Prepare a synchro describing us, so that it gets passed to the user-provided filter of other side */ - simgrid::kernel::activity::CommImplPtr this_comm = - simgrid::kernel::activity::CommImplPtr(new simgrid::kernel::activity::CommImpl()); + simgrid::kernel::activity::CommImplPtr this_comm(new simgrid::kernel::activity::CommImpl()); this_comm->set_type(simgrid::kernel::activity::CommImpl::Type::SEND); /* Look for communication synchro matching our needs. We also provide a description of @@ -115,8 +114,7 @@ simcall_HANDLER_comm_irecv(smx_simcall_t /*simcall*/, smx_actor_t receiver, smx_ void (*copy_data_fun)(simgrid::kernel::activity::CommImpl*, void*, size_t), void* data, double rate) { - simgrid::kernel::activity::CommImplPtr this_synchro = - simgrid::kernel::activity::CommImplPtr(new simgrid::kernel::activity::CommImpl()); + simgrid::kernel::activity::CommImplPtr this_synchro(new simgrid::kernel::activity::CommImpl()); this_synchro->set_type(simgrid::kernel::activity::CommImpl::Type::RECEIVE); XBT_DEBUG("recv from mbox %p. this_synchro=%p", mbox, this_synchro.get()); diff --git a/src/kernel/activity/MailboxImpl.cpp b/src/kernel/activity/MailboxImpl.cpp index 7be3b40fc8..8c752cec40 100644 --- a/src/kernel/activity/MailboxImpl.cpp +++ b/src/kernel/activity/MailboxImpl.cpp @@ -42,7 +42,7 @@ MailboxImpl* MailboxImpl::by_name_or_create(const std::string& name) /* two processes may have pushed the same mbox_create simcall at the same time */ auto m = mailboxes.find(name); if (m == mailboxes.end()) { - MailboxImpl* mbox = new MailboxImpl(name); + auto* mbox = new MailboxImpl(name); XBT_DEBUG("Creating a mailbox at %p with name %s", mbox, name.c_str()); mailboxes[name] = mbox; return mbox; diff --git a/src/kernel/activity/SemaphoreImpl.cpp b/src/kernel/activity/SemaphoreImpl.cpp index bf3407eb45..fd9877fe59 100644 --- a/src/kernel/activity/SemaphoreImpl.cpp +++ b/src/kernel/activity/SemaphoreImpl.cpp @@ -16,7 +16,7 @@ void SemaphoreImpl::acquire(actor::ActorImpl* issuer, double timeout) { XBT_DEBUG("Wait semaphore %p (timeout:%f)", this, timeout); if (value_ <= 0) { - RawImplPtr synchro = RawImplPtr(new RawImpl()); + RawImplPtr synchro(new RawImpl()); synchro->set_host(issuer->get_host()).set_timeout(timeout).start(); synchro->register_simcall(&issuer->simcall_); sleeping_.push_back(*issuer); diff --git a/src/kernel/actor/ActorImpl.cpp b/src/kernel/actor/ActorImpl.cpp index 0c9d9a5d6a..e01aa34ca6 100644 --- a/src/kernel/actor/ActorImpl.cpp +++ b/src/kernel/actor/ActorImpl.cpp @@ -85,7 +85,7 @@ ActorImplPtr ActorImpl::attach(const std::string& name, void* data, s4u::Host* h throw HostFailureException(XBT_THROW_POINT, "Cannot attach actor on failed host."); } - ActorImpl* actor = new ActorImpl(xbt::string(name), host); + auto* actor = new ActorImpl(xbt::string(name), host); /* Actor data */ actor->set_user_data(data); actor->code_ = nullptr; @@ -456,7 +456,7 @@ void ActorImpl::set_host(s4u::Host* dest) ActorImplPtr ActorImpl::init(const std::string& name, s4u::Host* host) const { - ActorImpl* actor = new ActorImpl(xbt::string(name), host); + auto* actor = new ActorImpl(xbt::string(name), host); actor->set_ppid(this->pid_); intrusive_ptr_add_ref(actor); @@ -520,7 +520,7 @@ ActorImplPtr ActorImpl::create(const std::string& name, const ActorCode& code, v void create_maestro(const std::function& code) { /* Create maestro actor and initialize it */ - ActorImpl* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr); + auto* maestro = new ActorImpl(xbt::string(""), /*host*/ nullptr); if (not code) { maestro->context_.reset(simix_global->context_factory->create_context(ActorCode(), maestro)); diff --git a/src/kernel/context/Context.hpp b/src/kernel/context/Context.hpp index 7dc642024e..be67dd6a6f 100644 --- a/src/kernel/context/Context.hpp +++ b/src/kernel/context/Context.hpp @@ -34,7 +34,7 @@ public: protected: template T* new_context(Args&&... args) { - T* context = new T(std::forward(args)...); + auto* context = new T(std::forward(args)...); context->declare_context(sizeof(T)); return context; } diff --git a/src/kernel/context/ContextBoost.cpp b/src/kernel/context/ContextBoost.cpp index f7d76cbc31..37aa9e8a1f 100644 --- a/src/kernel/context/ContextBoost.cpp +++ b/src/kernel/context/ContextBoost.cpp @@ -51,7 +51,7 @@ void BoostContext::wrapper(BoostContext::arg_type arg) void BoostContext::swap_into_for_real(SwappedContext* to_) { - BoostContext* to = static_cast(to_); + auto* to = static_cast(to_); #if BOOST_VERSION < 106100 boost::context::jump_fcontext(&this->fc_, to->fc_, reinterpret_cast(to)); #else diff --git a/src/kernel/context/ContextSwapped.cpp b/src/kernel/context/ContextSwapped.cpp index 5a54a95109..a0d7a4cd98 100644 --- a/src/kernel/context/ContextSwapped.cpp +++ b/src/kernel/context/ContextSwapped.cpp @@ -89,7 +89,7 @@ SwappedContext::SwappedContext(std::function&& code, smx_actor_t actor, #if SIMGRID_HAVE_MC /* Cannot use posix_memalign when SIMGRID_HAVE_MC. Align stack by hand, and save the * pointer returned by xbt_malloc0. */ - unsigned char* alloc = static_cast(xbt_malloc0(size + xbt_pagesize)); + auto* alloc = static_cast(xbt_malloc0(size + xbt_pagesize)); stack_ = alloc - (reinterpret_cast(alloc) & (xbt_pagesize - 1)) + xbt_pagesize; reinterpret_cast(stack_)[-1] = alloc; #elif !defined(_WIN32) @@ -223,7 +223,7 @@ void SwappedContextFactory::run_all() // - So, resume() is only launched from the parmap for the first job of each minion. parmap_->apply( [](const actor::ActorImpl* process) { - SwappedContext* context = static_cast(process->context_.get()); + auto* context = static_cast(process->context_.get()); context->resume(); }, simix_global->actors_to_run); @@ -247,7 +247,7 @@ void SwappedContextFactory::run_all() */ void SwappedContext::resume() { - SwappedContext* old = static_cast(self()); + auto* old = static_cast(self()); if (SIMIX_context_is_parallel()) { // Save my current soul (either maestro, or one of the minions) in a thread-specific area worker_context_ = old; diff --git a/src/kernel/context/ContextThread.cpp b/src/kernel/context/ContextThread.cpp index f31f2e3f9d..42d2be6304 100644 --- a/src/kernel/context/ContextThread.cpp +++ b/src/kernel/context/ContextThread.cpp @@ -160,7 +160,7 @@ void ThreadContext::suspend() void ThreadContext::attach_start() { // We're breaking the layers here by depending on the upper layer: - ThreadContext* maestro = static_cast(simix_global->maestro_->context_.get()); + auto* maestro = static_cast(simix_global->maestro_->context_.get()); maestro->begin_.release(); xbt_assert(not this->is_maestro()); this->start(); @@ -171,7 +171,7 @@ void ThreadContext::attach_stop() xbt_assert(not this->is_maestro()); this->yield(); - ThreadContext* maestro = static_cast(simix_global->maestro_->context_.get()); + auto* maestro = static_cast(simix_global->maestro_->context_.get()); maestro->end_.acquire(); Context::set_current(nullptr); @@ -183,7 +183,7 @@ void SerialThreadContext::run_all() { for (smx_actor_t const& actor : simix_global->actors_to_run) { XBT_DEBUG("Handling %p", actor); - ThreadContext* context = static_cast(actor->context_.get()); + auto* context = static_cast(actor->context_.get()); context->release(); context->wait(); } diff --git a/src/kernel/lmm/maxmin.cpp b/src/kernel/lmm/maxmin.cpp index eff10f6a30..88c40cf43a 100644 --- a/src/kernel/lmm/maxmin.cpp +++ b/src/kernel/lmm/maxmin.cpp @@ -175,7 +175,7 @@ Constraint::Constraint(resource::Resource* id_value, double bound_value) : bound Constraint* System::constraint_new(resource::Resource* id, double bound_value) { - Constraint* cnst = new Constraint(id, bound_value); + auto* cnst = new Constraint(id, bound_value); insert_constraint(cnst); return cnst; } @@ -195,7 +195,7 @@ Variable* System::variable_new(resource::Action* id, double sharing_penalty, dou XBT_IN("(sys=%p, id=%p, penalty=%f, bound=%f, num_cons =%zu)", this, id, sharing_penalty, bound, number_of_constraints); - Variable* var = static_cast(xbt_mallocator_get(variable_mallocator_)); + auto* var = static_cast(xbt_mallocator_get(variable_mallocator_)); var->initialize(id, sharing_penalty, bound, number_of_constraints, visited_counter_ - 1); if (sharing_penalty > 0) variable_set.push_front(*var); @@ -428,7 +428,7 @@ static void format_element_list(const ElemList& elem_list, s4u::Link::SharingPol void System::print() const { - std::string buf = std::string("MAX-MIN ( "); + std::string buf = "MAX-MIN ( "; /* Printing Objective */ for (Variable const& var : variable_set) diff --git a/src/kernel/resource/profile/Profile.cpp b/src/kernel/resource/profile/Profile.cpp index b6bdcfd3c2..25457dc4b3 100644 --- a/src/kernel/resource/profile/Profile.cpp +++ b/src/kernel/resource/profile/Profile.cpp @@ -35,7 +35,7 @@ Profile::~Profile() = default; * and get an iterator over the integrated trace */ Event* Profile::schedule(FutureEvtSet* fes, resource::Resource* resource) { - Event* event = new Event(); + auto* event = new Event(); event->profile = this; event->idx = 0; event->resource = resource; @@ -71,7 +71,7 @@ DatedValue Profile::next(Event* event) Profile* Profile::from_string(const std::string& name, const std::string& input, double periodicity) { int linecount = 0; - simgrid::kernel::profile::Profile* profile = new simgrid::kernel::profile::Profile(); + auto* profile = new simgrid::kernel::profile::Profile(); simgrid::kernel::profile::DatedValue* last_event = &(profile->event_list.back()); xbt_assert(trace_list.find(name) == trace_list.end(), "Refusing to define trace %s twice", name.c_str()); diff --git a/src/kernel/routing/DijkstraZone.cpp b/src/kernel/routing/DijkstraZone.cpp index bb780822b1..763a67f3a8 100644 --- a/src/kernel/routing/DijkstraZone.cpp +++ b/src/kernel/routing/DijkstraZone.cpp @@ -57,7 +57,7 @@ void DijkstraZone::seal() } if (not found) { - RouteCreationArgs* route = new simgrid::kernel::routing::RouteCreationArgs(); + auto* route = new simgrid::kernel::routing::RouteCreationArgs(); route->link_list.push_back(network_model_->loopback_); xbt_graph_new_edge(route_graph_.get(), node, node, route); } @@ -68,7 +68,7 @@ void DijkstraZone::seal() const_xbt_dynar_t nodes = xbt_graph_get_nodes(route_graph_.get()); xbt_dynar_foreach (nodes, cursor, node) { - GraphNodeData* data = static_cast(xbt_graph_node_get_data(node)); + auto* data = static_cast(xbt_graph_node_get_data(node)); data->graph_id_ = cursor; } } diff --git a/src/kernel/routing/FatTreeZone.cpp b/src/kernel/routing/FatTreeZone.cpp index ab626648ea..d891b6fd79 100644 --- a/src/kernel/routing/FatTreeZone.cpp +++ b/src/kernel/routing/FatTreeZone.cpp @@ -264,7 +264,7 @@ void FatTreeZone::generate_switches() int k = 0; for (unsigned int i = 0; i < this->levels_; i++) { for (unsigned int j = 0; j < this->nodes_by_level_[i + 1]; j++) { - FatTreeNode* newNode = new FatTreeNode(this->cluster_, --k, i + 1, j); + auto* newNode = new FatTreeNode(this->cluster_, --k, i + 1, j); XBT_DEBUG("We create the switch %d(%u,%u)", newNode->id, newNode->level, newNode->position); newNode->children.resize(this->num_children_per_node_[i] * this->num_port_lower_level_[i]); if (i != this->levels_ - 1) { diff --git a/src/kernel/routing/NetZoneImpl.cpp b/src/kernel/routing/NetZoneImpl.cpp index 0528a43d9f..ed7e84b12c 100644 --- a/src/kernel/routing/NetZoneImpl.cpp +++ b/src/kernel/routing/NetZoneImpl.cpp @@ -68,7 +68,7 @@ int NetZoneImpl::get_host_count() const s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector& speed_per_pstate, int coreAmount, const std::map* props) { - s4u::Host* res = new s4u::Host(name); + auto* res = new s4u::Host(name); if (hierarchy_ == RoutingMode::unset) hierarchy_ = RoutingMode::base; @@ -118,7 +118,7 @@ void NetZoneImpl::add_bypass_route(NetPoint* src, NetPoint* dst, NetPoint* gw_sr } /* Build a copy that will be stored in the dict */ - BypassRoute* newRoute = new BypassRoute(gw_src, gw_dst); + auto* newRoute = new BypassRoute(gw_src, gw_dst); for (auto const& link : link_list) newRoute->links.push_back(link); diff --git a/src/kernel/routing/RoutedZone.cpp b/src/kernel/routing/RoutedZone.cpp index b6b01f6ea5..0b7f207b88 100644 --- a/src/kernel/routing/RoutedZone.cpp +++ b/src/kernel/routing/RoutedZone.cpp @@ -31,8 +31,8 @@ xbt_node_t new_xbt_graph_node(const s_xbt_graph_t* graph, const char* name, std: xbt_edge_t new_xbt_graph_edge(const s_xbt_graph_t* graph, xbt_node_t s, xbt_node_t d, std::map* edges) { - const char* sn = static_cast(xbt_graph_node_get_data(s)); - const char* dn = static_cast(xbt_graph_node_get_data(d)); + const auto* sn = static_cast(xbt_graph_node_get_data(s)); + const auto* dn = static_cast(xbt_graph_node_get_data(d)); std::string name = std::string(sn) + dn; auto elm = edges->find(name); @@ -68,7 +68,7 @@ void RoutedZone::get_graph(const s_xbt_graph_t* graph, std::map& link_list, bool /* symmetrical */, bool change_order) { - RouteCreationArgs* result = new RouteCreationArgs(); + auto* result = new RouteCreationArgs(); xbt_assert(hierarchy == RoutingMode::base || hierarchy == RoutingMode::recursive, "The hierarchy of this netzone is neither BASIC nor RECURSIVE, I'm lost here."); diff --git a/src/kernel/routing/TorusZone.cpp b/src/kernel/routing/TorusZone.cpp index 574153e556..6323da9778 100644 --- a/src/kernel/routing/TorusZone.cpp +++ b/src/kernel/routing/TorusZone.cpp @@ -107,8 +107,8 @@ void TorusZone::get_local_route(NetPoint* src, NetPoint* dst, RouteCreationArgs* * both arrays, we can easily assess whether we need to route into this dimension or not. */ const unsigned int dsize = dimensions_.size(); - unsigned int* myCoords = new unsigned int[dsize]; - unsigned int* targetCoords= new unsigned int[dsize]; + auto* myCoords = new unsigned int[dsize]; + auto* targetCoords = new unsigned int[dsize]; unsigned int dim_size_product = 1; for (unsigned i = 0; i < dsize; i++) { unsigned cur_dim_size = dimensions_[i]; diff --git a/src/plugins/file_system/s4u_FileSystem.cpp b/src/plugins/file_system/s4u_FileSystem.cpp index 241189486b..7bdd4efe37 100644 --- a/src/plugins/file_system/s4u_FileSystem.cpp +++ b/src/plugins/file_system/s4u_FileSystem.cpp @@ -462,7 +462,7 @@ int File::remote_copy(sg_host_t host, const char* fullpath) } /* Create file on remote host, write it and close it */ - File* fd = new File(fullpath, dst_host, nullptr); + auto* fd = new File(fullpath, dst_host, nullptr); if (local_storage_) { sg_size_t write_size = fd->local_storage_->write(read_size); fd->local_storage_->extension()->incr_used_size(write_size); @@ -509,7 +509,7 @@ std::map* FileSystemDiskExt::parse_content(const std::st if (filename.empty()) return nullptr; - std::map* parse_content = new std::map(); + auto* parse_content = new std::map(); std::ifstream* fs = surf_ifsopen(filename); xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(), @@ -538,7 +538,7 @@ std::map* FileSystemStorageExt::parse_content(const std: if (filename.empty()) return nullptr; - std::map* parse_content = new std::map(); + auto* parse_content = new std::map(); std::ifstream* fs = surf_ifsopen(filename); xbt_assert(not fs->fail(), "Cannot open file '%s' (path=%s)", filename.c_str(), @@ -839,8 +839,7 @@ xbt_dict_t sg_storage_get_content(const_sg_storage_t storage) xbt_dict_t content_as_dict = xbt_dict_new_homogeneous(::operator delete); for (auto const& entry : *content) { - sg_size_t* psize = new sg_size_t; - *psize = entry.second; + auto* psize = new sg_size_t(entry.second); xbt_dict_set(content_as_dict, entry.first.c_str(), psize); } return content_as_dict; diff --git a/src/plugins/host_energy.cpp b/src/plugins/host_energy.cpp index 866e9f6c88..9f6dc51b7a 100644 --- a/src/plugins/host_energy.cpp +++ b/src/plugins/host_energy.cpp @@ -350,7 +350,7 @@ void HostEnergy::init_watts_range_list() host_->get_pstate_count()); // XBT_ATTRIB_DEPRECATED_v328: putting this macro name here so that we find it during the deprecation cleanups - std::string msg = std::string("DEPRECATION WARNING: Property 'watt_per_state' will only work until v3.28.\n"); + std::string msg = "DEPRECATION WARNING: Property 'watt_per_state' will only work until v3.28.\n"; msg += std::string("The old syntax 'Idle:OneCore:AllCores' must be converted into 'Idle:Epsilon:AllCores' to " "properly model the consumption of non-whole tasks on mono-core hosts. Here are the values to " "use for host '") + diff --git a/src/plugins/vm/VmLiveMigration.cpp b/src/plugins/vm/VmLiveMigration.cpp index 0712e95848..aebcd31228 100644 --- a/src/plugins/vm/VmLiveMigration.cpp +++ b/src/plugins/vm/VmLiveMigration.cpp @@ -73,8 +73,8 @@ void MigrationRx::operator()() instr::Container::get_root()->get_link("VM_LINK")->end_event(msg, "M", key); } // Inform the SRC that the migration has been correctly performed - std::string* payload = new std::string("__mig_stage4:"); - *payload = *payload + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")"; + auto* payload = new std::string("__mig_stage4:"); + *payload = *payload + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")"; mbox_ctl->put(payload, 0); @@ -83,7 +83,7 @@ void MigrationRx::operator()() static sg_size_t get_updated_size(double computed, double dp_rate, sg_size_t dp_cap) { - sg_size_t updated_size = static_cast(computed * dp_rate); + auto updated_size = static_cast(computed * dp_rate); XBT_DEBUG("updated_size %llu dp_rate %f", updated_size, dp_rate); if (updated_size > dp_cap) { updated_size = dp_cap; @@ -95,7 +95,7 @@ static sg_size_t get_updated_size(double computed, double dp_rate, sg_size_t dp_ sg_size_t MigrationTx::sendMigrationData(sg_size_t size, int stage, int stage2_round, double mig_speed, double timeout) { sg_size_t sent = size; - std::string* msg = new std::string("__mig_stage"); + auto* msg = new std::string("__mig_stage"); *msg = *msg + std::to_string(stage) + ":" + vm_->get_cname() + "(" + src_pm_->get_cname() + "-" + dst_pm_->get_cname() + ")"; @@ -107,7 +107,7 @@ sg_size_t MigrationTx::sendMigrationData(sg_size_t size, int stage, int stage2_r try { comm->wait_for(timeout); } catch (const Exception&) { - sg_size_t remaining = static_cast(comm->get_remaining()); + auto remaining = static_cast(comm->get_remaining()); XBT_VERB("timeout (%lf s) in sending_migration_data, remaining %llu bytes of %llu", timeout, remaining, size); sent -= remaining; delete msg; @@ -298,7 +298,7 @@ simgrid::s4u::VirtualMachine* sg_vm_create_migratable(simgrid::s4u::Host* pm, co /* For the moment, intensity_rate is the percentage against the migration bandwidth */ - sg_vm_t vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount, static_cast(ramsize) * 1024 * 1024); + auto* vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount, static_cast(ramsize) * 1024 * 1024); sg_vm_set_dirty_page_intensity(vm, dp_intensity / 100.0); sg_vm_set_working_set_memory(vm, vm->get_ramsize() * 0.9); // assume working set memory is 90% of ramsize sg_vm_set_migration_speed(vm, mig_netspeed * 1024 * 1024.0); diff --git a/src/s4u/s4u_Actor.cpp b/src/s4u/s4u_Actor.cpp index b9cc2223c6..93537487f8 100644 --- a/src/s4u/s4u_Actor.cpp +++ b/src/s4u/s4u_Actor.cpp @@ -129,7 +129,7 @@ void Actor::set_auto_restart(bool autorestart) xbt_assert(autorestart && not pimpl_->has_to_auto_restart()); // FIXME: handle all cases pimpl_->set_auto_restart(autorestart); - kernel::actor::ProcessArg* arg = new kernel::actor::ProcessArg(pimpl_->get_host(), pimpl_); + auto* arg = new kernel::actor::ProcessArg(pimpl_->get_host(), pimpl_); XBT_DEBUG("Adding %s to the actors_at_boot_ list of Host %s", arg->name.c_str(), arg->host->get_cname()); pimpl_->get_host()->pimpl_->add_actor_at_boot(arg); }); @@ -370,7 +370,7 @@ void parallel_execute(const std::vector& hosts, const std::vectorset_flops_amount(flops_amount)->set_host(get_host()); return exec; } @@ -398,7 +398,7 @@ ExecPtr exec_init(const std::vector& hosts, const std::vectorset_flops_amounts(flops_amounts)->set_bytes_amounts(bytes_amounts)->set_hosts(hosts); return exec; } @@ -851,7 +851,7 @@ sg_exec_t sg_actor_parallel_exec_init(int host_nb, const sg_host_t* host_list, d if (bytes_amount != nullptr) bytes = std::vector(bytes_amount, bytes_amount + host_nb * host_nb); - simgrid::s4u::ExecPtr exec = simgrid::s4u::ExecPtr(new simgrid::s4u::Exec()); + simgrid::s4u::ExecPtr exec(new simgrid::s4u::Exec()); exec->set_flops_amounts(flops)->set_bytes_amounts(bytes)->set_hosts(hosts); exec->add_ref(); return exec.get(); diff --git a/src/s4u/s4u_Mailbox.cpp b/src/s4u/s4u_Mailbox.cpp index 3a3c205747..01cb3eb499 100644 --- a/src/s4u/s4u_Mailbox.cpp +++ b/src/s4u/s4u_Mailbox.cpp @@ -85,7 +85,7 @@ ActorPtr Mailbox::get_receiver() const CommPtr Mailbox::put_init() { - CommPtr res = CommPtr(new Comm()); + CommPtr res(new Comm()); res->sender_ = kernel::actor::ActorImpl::self(); res->mailbox_ = this; return res; @@ -132,7 +132,7 @@ void Mailbox::put(void* payload, uint64_t simulated_size_in_bytes, double timeou CommPtr Mailbox::get_init() { - CommPtr res = CommPtr(new Comm()); + CommPtr res(new Comm()); res->receiver_ = kernel::actor::ActorImpl::self(); res->mailbox_ = this; return res; diff --git a/src/simdag/sd_global.cpp b/src/simdag/sd_global.cpp index ee13102558..80a6105582 100644 --- a/src/simdag/sd_global.cpp +++ b/src/simdag/sd_global.cpp @@ -44,7 +44,7 @@ std::set* simulate(double how_long){ for (auto const& model : all_existing_models) { const simgrid::kernel::resource::Action* action = model->extract_done_action(); while (action != nullptr && action->get_data() != nullptr) { - SD_task_t task = static_cast(action->get_data()); + auto* task = static_cast(action->get_data()); XBT_VERB("Task '%s' done", SD_task_get_name(task)); SD_task_set_state(task, SD_DONE); @@ -94,7 +94,7 @@ std::set* simulate(double how_long){ /* let's see which tasks have just failed */ action = model->extract_failed_action(); while (action != nullptr) { - SD_task_t task = static_cast(action->get_data()); + auto* task = static_cast(action->get_data()); XBT_VERB("Task '%s' failed", SD_task_get_name(task)); SD_task_set_state(task, SD_FAILED); sd_global->return_set.insert(task); diff --git a/src/simdag/sd_task.cpp b/src/simdag/sd_task.cpp index 05a3afc6ec..102acfd101 100644 --- a/src/simdag/sd_task.cpp +++ b/src/simdag/sd_task.cpp @@ -501,7 +501,7 @@ void SD_task_dump(const_SD_task_t task) /** @brief Dumps the task in dotty formalism into the FILE* passed as second argument */ void SD_task_dotty(const_SD_task_t task, void* out) { - FILE *fout = static_cast(out); + auto* fout = static_cast(out); fprintf(fout, " T%p [label=\"%.20s\"", task, task->name); switch (task->kind) { case SD_TASK_COMM_E2E: @@ -962,7 +962,7 @@ void SD_task_schedulev(SD_task_t task, int count, const sg_host_t * list) void SD_task_schedulel(SD_task_t task, int count, ...) { va_list ap; - sg_host_t* list = new sg_host_t[count]; + auto* list = new sg_host_t[count]; va_start(ap, count); for (int i=0; i&& callback) { - Timer* timer = new Timer(date, std::move(callback)); + auto* timer = new Timer(date, std::move(callback)); timer->handle_ = simix_timers.emplace(std::make_pair(date, timer)); return timer; } diff --git a/src/surf/HostImpl.cpp b/src/surf/HostImpl.cpp index ff17a48e31..8e920ddbd3 100644 --- a/src/surf/HostImpl.cpp +++ b/src/surf/HostImpl.cpp @@ -36,7 +36,7 @@ HostImpl::~HostImpl() { /* All actors should be gone when the host is turned off (by the end of the simulation). */ if (not actor_list_.empty()) { - std::string msg = std::string("Shutting down host, but it's not empty:"); + std::string msg = "Shutting down host, but it's not empty:"; for (auto const& actor : actor_list_) msg += "\n\t" + std::string(actor.get_name()); @@ -145,7 +145,7 @@ std::vector HostImpl::get_attached_storages() } std::unordered_map* HostImpl::get_mounted_storages() { - std::unordered_map* mounts = new std::unordered_map(); + auto* mounts = new std::unordered_map(); for (auto const& m : storage_) { mounts->insert({m.first, m.second->get_iface()}); } diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 6cbbe10fcc..63effaaed4 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -196,7 +196,7 @@ std::list CpuAction::cpus() const /* Beware of composite actions: ptasks put links and cpus together */ // extra pb: we cannot dynamic_cast from void*... Resource* resource = get_variable()->get_constraint(i)->get_id(); - Cpu* cpu = dynamic_cast(resource); + auto* cpu = dynamic_cast(resource); if (cpu != nullptr) retlist.push_back(cpu); } diff --git a/src/surf/network_cm02.cpp b/src/surf/network_cm02.cpp index 1c1241dbca..f6b424c038 100644 --- a/src/surf/network_cm02.cpp +++ b/src/surf/network_cm02.cpp @@ -130,7 +130,7 @@ void NetworkCm02Model::update_actions_state_lazy(double now, double /*delta*/) void NetworkCm02Model::update_actions_state_full(double /*now*/, double delta) { for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { - NetworkCm02Action& action = static_cast(*it); + auto& action = static_cast(*it); ++it; // increment iterator here since the following calls to action.finish() may invalidate it XBT_DEBUG("Something happened to action %p", &action); double deltap = delta; diff --git a/src/surf/network_ib.cpp b/src/surf/network_ib.cpp index 0a8c889a61..ce8a68c499 100644 --- a/src/surf/network_ib.cpp +++ b/src/surf/network_ib.cpp @@ -43,9 +43,9 @@ static void IB_action_state_changed_callback(simgrid::kernel::resource::NetworkA static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action) { - simgrid::kernel::resource::NetworkIBModel* ibModel = (simgrid::kernel::resource::NetworkIBModel*)surf_network_model; - simgrid::kernel::resource::IBNode* act_src = &ibModel->active_nodes.at(action.get_src().get_name()); - simgrid::kernel::resource::IBNode* act_dst = &ibModel->active_nodes.at(action.get_dst().get_name()); + auto* ibModel = static_cast(surf_network_model); + auto* act_src = &ibModel->active_nodes.at(action.get_src().get_name()); + auto* act_dst = &ibModel->active_nodes.at(action.get_dst().get_name()); ibModel->active_comms[&action] = std::make_pair(act_src, act_dst); ibModel->updateIBfactors(&action, act_src, act_dst, 0); @@ -196,7 +196,7 @@ void NetworkIBModel::updateIBfactors(NetworkAction* action, IBNode* from, IBNode action->unref(); } else { action->ref(); - ActiveComm* comm = new ActiveComm(); + auto* comm = new ActiveComm(); comm->action = action; comm->destination = to; from->ActiveCommsUp.push_back(comm); diff --git a/src/surf/network_interface.cpp b/src/surf/network_interface.cpp index 764c414c75..25320359a6 100644 --- a/src/surf/network_interface.cpp +++ b/src/surf/network_interface.cpp @@ -59,7 +59,7 @@ double NetworkModel::next_occurring_event_full(double now) double minRes = Model::next_occurring_event_full(now); for (Action const& action : *get_started_action_set()) { - const NetworkAction& net_action = static_cast(action); + const auto& net_action = static_cast(action); if (net_action.latency_ > 0) minRes = (minRes < 0) ? net_action.latency_ : std::min(minRes, net_action.latency_); } @@ -190,7 +190,7 @@ std::list NetworkAction::get_links() const /* Beware of composite actions: ptasks put links and cpus together */ // extra pb: we cannot dynamic_cast from void*... Resource* resource = get_variable()->get_constraint(i)->get_id(); - LinkImpl* link = dynamic_cast(resource); + auto* link = dynamic_cast(resource); if (link != nullptr) retlist.push_back(link); } diff --git a/src/surf/network_wifi.cpp b/src/surf/network_wifi.cpp index 9c60524148..76f2f57199 100644 --- a/src/surf/network_wifi.cpp +++ b/src/surf/network_wifi.cpp @@ -64,7 +64,7 @@ s4u::Link::SharingPolicy NetworkWifiLink::get_sharing_policy() void NetworkWifiLink::refresh_decay_bandwidths(){ // Compute number of STAtion on the Access Point - int nSTA = static_cast(host_rates_.size()); + size_t nSTA = host_rates_.size(); std::vector new_bandwidths; for (auto bandwidth : bandwidths_){ diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index d1f2593df1..fb4cb6e941 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -72,7 +72,7 @@ double HostL07Model::next_occurring_event(double now) { double min = HostModel::next_occurring_event_full(now); for (kernel::resource::Action const& action : *get_started_action_set()) { - const L07Action& net_action = static_cast(action); + const auto& net_action = static_cast(action); if (net_action.get_latency() > 0 && (min < 0 || net_action.get_latency() < min)) { min = net_action.get_latency(); XBT_DEBUG("Updating min with %p (start %f): %f", &net_action, net_action.get_start_time(), min); @@ -86,7 +86,7 @@ double HostL07Model::next_occurring_event(double now) void HostL07Model::update_actions_state(double /*now*/, double delta) { for (auto it = std::begin(*get_started_action_set()); it != std::end(*get_started_action_set());) { - L07Action& action = static_cast(*it); + auto& action = static_cast(*it); ++it; // increment iterator here since the following calls to action.finish() may invalidate it if (action.get_latency() > 0) { if (action.get_latency() > delta) { @@ -212,8 +212,8 @@ L07Action::L07Action(kernel::resource::Model* model, const std::vector host_list = {src, dst}; - const double* flops_amount = new double[2](); - double* bytes_amount = new double[4](); + const auto* flops_amount = new double[2](); + auto* bytes_amount = new double[4](); bytes_amount[1] = size; @@ -263,7 +263,7 @@ kernel::resource::CpuAction* CpuL07::execution_start(double size) { std::vector host_list = {get_host()}; - double* flops_amount = new double[host_list.size()](); + auto* flops_amount = new double[host_list.size()](); flops_amount[0] = size; kernel::resource::CpuAction* res = @@ -274,7 +274,7 @@ kernel::resource::CpuAction* CpuL07::execution_start(double size) kernel::resource::CpuAction* CpuL07::sleep(double duration) { - L07Action *action = static_cast(execution_start(1.0)); + auto* action = static_cast(execution_start(1.0)); action->set_max_duration(duration); action->set_suspend_state(kernel::resource::Action::SuspendStates::SLEEPING); get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), 0.0); diff --git a/src/surf/sg_platf.cpp b/src/surf/sg_platf.cpp index e493ca1b28..9ae69acb6f 100644 --- a/src/surf/sg_platf.cpp +++ b/src/surf/sg_platf.cpp @@ -103,7 +103,7 @@ simgrid::kernel::routing::NetPoint* sg_platf_new_router(const std::string& name, xbt_assert(nullptr == simgrid::s4u::Engine::get_instance()->netpoint_by_name_or_null(name), "Refusing to create a router named '%s': this name already describes a node.", name.c_str()); - simgrid::kernel::routing::NetPoint* netpoint = + auto* netpoint = new simgrid::kernel::routing::NetPoint(name, simgrid::kernel::routing::NetPoint::Type::Router, current_routing); XBT_DEBUG("Router '%s' has the id %u", netpoint->get_cname(), netpoint->id()); @@ -176,7 +176,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster break; } sg_platf_new_Zone_begin(&zone); - simgrid::kernel::routing::ClusterZone* current_as = static_cast(routing_get_current()); + auto* current_as = static_cast(routing_get_current()); current_as->parse_specific_arguments(cluster); if (cluster->properties != nullptr) for (auto const& elm : *cluster->properties) @@ -301,8 +301,7 @@ void sg_platf_new_cluster(simgrid::kernel::routing::ClusterCreationArgs* cluster void routing_cluster_add_backbone(simgrid::kernel::resource::LinkImpl* bb) { - simgrid::kernel::routing::ClusterZone* cluster = - dynamic_cast(current_routing); + auto* cluster = dynamic_cast(current_routing); xbt_assert(cluster, "Only hosts from Cluster can get a backbone."); xbt_assert(nullptr == cluster->backbone_, "Cluster %s already has a backbone link!", cluster->get_cname()); @@ -394,9 +393,9 @@ void sg_platf_new_storage_type(const simgrid::kernel::routing::StorageTypeCreati xbt_assert(storage_types.find(storage_type->id) == storage_types.end(), "Reading a storage type, processing unit \"%s\" already exists", storage_type->id.c_str()); - simgrid::kernel::resource::StorageType* stype = new simgrid::kernel::resource::StorageType( - storage_type->id, storage_type->model, storage_type->content, storage_type->properties, - storage_type->model_properties, storage_type->size); + auto* stype = new simgrid::kernel::resource::StorageType(storage_type->id, storage_type->model, storage_type->content, + storage_type->properties, storage_type->model_properties, + storage_type->size); XBT_DEBUG("Create a storage type id '%s' with model '%s', content '%s'", storage_type->id.c_str(), storage_type->model.c_str(), storage_type->content.c_str()); @@ -461,7 +460,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor) simgrid::kernel::actor::ActorCode code = factory(std::move(actor->args)); std::shared_ptr> properties(actor->properties); - simgrid::kernel::actor::ProcessArg* arg = + auto* arg = new simgrid::kernel::actor::ProcessArg(actor_name, code, nullptr, host, kill_time, properties, auto_restart); host->pimpl_->add_actor_at_boot(arg); @@ -499,7 +498,7 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor) void sg_platf_new_peer(const simgrid::kernel::routing::PeerCreationArgs* peer) { - simgrid::kernel::routing::VivaldiZone* as = dynamic_cast(current_routing); + auto* as = dynamic_cast(current_routing); xbt_assert(as, " tag can only be used in Vivaldi netzones."); std::vector speed_per_pstate; diff --git a/src/surf/surf_interface.cpp b/src/surf/surf_interface.cpp index 9c8f2301c1..5216e3c1a0 100644 --- a/src/surf/surf_interface.cpp +++ b/src/surf/surf_interface.cpp @@ -147,7 +147,7 @@ std::ifstream* surf_ifsopen(const std::string& name) { xbt_assert(not name.empty()); - std::ifstream* fs = new std::ifstream(); + auto* fs = new std::ifstream(); if (is_absolute_file_path(name)) { /* don't mess with absolute file names */ fs->open(name.c_str(), std::ifstream::in); } diff --git a/src/surf/xml/surfxml_sax_cb.cpp b/src/surf/xml/surfxml_sax_cb.cpp index f8fcade127..09f67cdf81 100644 --- a/src/surf/xml/surfxml_sax_cb.cpp +++ b/src/surf/xml/surfxml_sax_cb.cpp @@ -97,7 +97,7 @@ int surf_parse_get_int(const std::string& s) /* Turn something like "1-4,6,9-11" into the vector {1,2,3,4,6,9,10,11} */ static std::vector* explodesRadical(const std::string& radicals) { - std::vector* exploded = new std::vector(); + auto* exploded = new std::vector(); // Make all hosts std::vector radical_elements; diff --git a/src/xbt/config.cpp b/src/xbt/config.cpp index f317be522f..ef9fcf678a 100644 --- a/src/xbt/config.cpp +++ b/src/xbt/config.cpp @@ -265,7 +265,7 @@ public: { xbt_assert(options.find(name) == options.end(), "Refusing to register the config element '%s' twice.", name.c_str()); - TypedConfigurationElement* variable = new TypedConfigurationElement(name, std::forward(a)...); + auto* variable = new TypedConfigurationElement(name, std::forward(a)...); XBT_DEBUG("Register cfg elm %s (%s) of type %s @%p in set %p)", name.c_str(), variable->get_description().c_str(), variable->get_type_name(), variable, this); options[name].reset(variable); diff --git a/src/xbt/dict.cpp b/src/xbt/dict.cpp index 8753f297c2..af97e2d513 100644 --- a/src/xbt/dict.cpp +++ b/src/xbt/dict.cpp @@ -89,7 +89,7 @@ static void xbt_dict_rehash(xbt_dict_t dict) const unsigned oldsize = dict->table_size + 1; unsigned newsize = oldsize * 2; - xbt_dictelm_t* newtable = (xbt_dictelm_t*)xbt_realloc((char*)dict->table, newsize * sizeof(xbt_dictelm_t)); + auto* newtable = static_cast(xbt_realloc((char*)dict->table, newsize * sizeof(xbt_dictelm_t))); memset(&newtable[oldsize], 0, oldsize * sizeof(xbt_dictelm_t)); /* zero second half */ newsize--; dict->table_size = newsize; diff --git a/src/xbt/dict_test.cpp b/src/xbt/dict_test.cpp index 58913944d9..168a9b4ef5 100644 --- a/src/xbt/dict_test.cpp +++ b/src/xbt/dict_test.cpp @@ -52,7 +52,7 @@ static xbt_dict_t new_fixture() static void search_ext(const_xbt_dict_t head, const char* key, const char* data) { INFO("Search " << STR(key)); - char* found = (char*)xbt_dict_get_or_null(head, key); + auto* found = static_cast(xbt_dict_get_or_null(head, key)); INFO("Found " << STR(found)); if (data) { REQUIRE(found); // data do not match expectations: found null while searching for data @@ -271,7 +271,7 @@ TEST_CASE("xbt::dict: dict data container", "dict") xbt_dict_t head = xbt_dict_new_homogeneous(free); for (int j = 0; j < 1000; j++) { const char* data = nullptr; - char* key = (char*)xbt_malloc(SIZEOFKEY); + auto* key = static_cast(xbt_malloc(SIZEOFKEY)); do { for (int k = 0; k < SIZEOFKEY - 1; k++) { @@ -295,7 +295,7 @@ TEST_CASE("xbt::dict: dict data container", "dict") xbt_dict_t head = xbt_dict_new_homogeneous(&free); INFO("Fill " << NB_ELM << " elements, with keys being the number of element"); for (int j = 0; j < NB_ELM; j++) { - char* key = (char*)xbt_malloc(10); + auto* key = static_cast(xbt_malloc(10)); snprintf(key, 10, "%d", j); xbt_dict_set(head, key, key); @@ -305,7 +305,7 @@ TEST_CASE("xbt::dict: dict data container", "dict") INFO("There is " << countelems(head) << " elements"); INFO("Search my " << NB_ELM << " elements 20 times"); - char* key = (char*)xbt_malloc(10); + auto* key = static_cast(xbt_malloc(10)); for (int i = 0; i < 20; i++) { for (int j = 0; j < NB_ELM; j++) { snprintf(key, 10, "%d", j); diff --git a/src/xbt/dynar.cpp b/src/xbt/dynar.cpp index ae898abfee..cab503ccf6 100644 --- a/src/xbt/dynar.cpp +++ b/src/xbt/dynar.cpp @@ -59,7 +59,7 @@ static inline void _xbt_dynar_expand(xbt_dynar_t dynar, unsigned long nb) static inline void* _xbt_dynar_elm(const_xbt_dynar_t dynar, unsigned long idx) { - char *const data = (char *) dynar->data; + auto* const data = static_cast(dynar->data); const unsigned long elmsize = dynar->elmsize; return data + idx * elmsize; @@ -387,7 +387,7 @@ void xbt_dynar_shift(xbt_dynar_t dynar, void* dst) */ void xbt_dynar_map(const_xbt_dynar_t dynar, void_f_pvoid_t op) { - char *const data = (char *) dynar->data; + auto* const data = static_cast(dynar->data); const unsigned long elmsize = dynar->elmsize; const unsigned long used = dynar->used; diff --git a/src/xbt/xbt_log_appender_file.cpp b/src/xbt/xbt_log_appender_file.cpp index 344dab7e27..8e8831d3a7 100644 --- a/src/xbt/xbt_log_appender_file.cpp +++ b/src/xbt/xbt_log_appender_file.cpp @@ -89,7 +89,7 @@ static void open_append2_file(xbt_log_append2_file_t data){ static void append2_file(const s_xbt_log_appender_t* this_, const char* str) { - xbt_log_append2_file_t d = (xbt_log_append2_file_t)this_->data; + auto* d = static_cast(this_->data); xbt_assert(d->file); if (ftell(d->file) >= d->limit) { open_append2_file(d); @@ -103,7 +103,7 @@ static void append2_file(const s_xbt_log_appender_t* this_, const char* str) static void free_append2_(const s_xbt_log_appender_t* this_) { - xbt_log_append2_file_t data = static_cast(this_->data); + auto* data = static_cast(this_->data); if (data->file) fclose(data->file); xbt_free(data->filename); diff --git a/src/xbt/xbt_log_layout_format.cpp b/src/xbt/xbt_log_layout_format.cpp index 00e58fd526..6680282b1a 100644 --- a/src/xbt/xbt_log_layout_format.cpp +++ b/src/xbt/xbt_log_layout_format.cpp @@ -77,7 +77,7 @@ static int xbt_log_layout_format_doit(const s_xbt_log_layout_t* l, xbt_log_event int precision = -1; int length = -1; - char* q = static_cast(l->data); + auto* q = static_cast(l->data); while (*q != '\0') { if (*q == '%') { q++; diff --git a/src/xbt/xbt_str_test.cpp b/src/xbt/xbt_str_test.cpp index 81ed1aa0da..8d4a82e2ea 100644 --- a/src/xbt/xbt_str_test.cpp +++ b/src/xbt/xbt_str_test.cpp @@ -35,7 +35,7 @@ template void test_parse_error(F function, const std::string& name, template void test_parse_ok(F function, const std::string& name, const char* str, T value) { INFO(name); - T variable = static_cast(-9999); + auto variable = static_cast(-9999); REQUIRE_NOTHROW(variable = function(str, "Parse error")); REQUIRE(variable == value); /* Fail to parse str */ } -- 2.20.1