Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Replace redundant type with "auto" (include/ and src/).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 3 Oct 2020 19:53:46 +0000 (21:53 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 4 Oct 2020 20:18:38 +0000 (22:18 +0200)
50 files changed:
include/simgrid/s4u/Engine.hpp
include/xbt/automaton.hpp
include/xbt/config.hpp
include/xbt/functional.hpp
src/bindings/lua/lua_host.cpp
src/bindings/lua/lua_platf.cpp
src/bindings/python/simgrid_python.cpp
src/include/xbt/parmap.hpp
src/instr/instr_platform.cpp
src/instr/jedule/jedule_platform.cpp
src/kernel/activity/CommImpl.cpp
src/kernel/activity/MailboxImpl.cpp
src/kernel/activity/SemaphoreImpl.cpp
src/kernel/actor/ActorImpl.cpp
src/kernel/context/Context.hpp
src/kernel/context/ContextBoost.cpp
src/kernel/context/ContextSwapped.cpp
src/kernel/context/ContextThread.cpp
src/kernel/lmm/maxmin.cpp
src/kernel/resource/profile/Profile.cpp
src/kernel/routing/DijkstraZone.cpp
src/kernel/routing/FatTreeZone.cpp
src/kernel/routing/NetZoneImpl.cpp
src/kernel/routing/RoutedZone.cpp
src/kernel/routing/TorusZone.cpp
src/plugins/file_system/s4u_FileSystem.cpp
src/plugins/host_energy.cpp
src/plugins/vm/VmLiveMigration.cpp
src/s4u/s4u_Actor.cpp
src/s4u/s4u_Mailbox.cpp
src/simdag/sd_global.cpp
src/simdag/sd_task.cpp
src/simix/smx_global.cpp
src/surf/HostImpl.cpp
src/surf/cpu_interface.cpp
src/surf/network_cm02.cpp
src/surf/network_ib.cpp
src/surf/network_interface.cpp
src/surf/network_wifi.cpp
src/surf/ptask_L07.cpp
src/surf/sg_platf.cpp
src/surf/surf_interface.cpp
src/surf/xml/surfxml_sax_cb.cpp
src/xbt/config.cpp
src/xbt/dict.cpp
src/xbt/dict_test.cpp
src/xbt/dynar.cpp
src/xbt/xbt_log_appender_file.cpp
src/xbt/xbt_log_layout_format.cpp
src/xbt/xbt_str_test.cpp

index 2490007..086849f 100644 (file)
@@ -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<T*>(elem->get_impl());
+    auto* elem_impl = dynamic_cast<T*>(elem->get_impl());
     if (elem_impl != nullptr)
       whereto->push_back(elem_impl);
   }
index 58fdd75..b9bea1e 100644 (file)
@@ -21,7 +21,7 @@ namespace xbt {
  */
 template <class F> 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)(); },
index 7dedb71..28a83ec 100644 (file)
@@ -162,7 +162,7 @@ bind_flag(T& value, const char* name, const char* description, std::map<T, std::
                      found = true;
                  }
                  if (not found || std::string(val) == "help") {
-                   std::string mesg = std::string("\n");
+                   std::string mesg = "\n";
                    if (std::string(val) == "help")
                      mesg += std::string("Possible values for option ") + name + ":\n";
                    else
index b2d1043..b16e947 100644 (file)
@@ -184,7 +184,7 @@ private:
     const static TaskVtable vtable {
       // Call:
       [](TaskUnion& buffer, Args... args) {
-        F* src = reinterpret_cast<F*>(&buffer);
+        auto* src = reinterpret_cast<F*>(&buffer);
         F code = std::move(*src);
         src->~F();
         // NOTE: std::forward<Args>(args)... is correct.
@@ -194,13 +194,13 @@ private:
       std::is_trivially_destructible<F>::value ?
       static_cast<destroy_function>(nullptr) :
       [](TaskUnion& buffer) {
-        F* code = reinterpret_cast<F*>(&buffer);
+        auto* code = reinterpret_cast<F*>(&buffer);
         code->~F();
       },
       // Move:
       [](TaskUnion& dst, TaskUnion& src) {
-        F* src_code = reinterpret_cast<F*>(&src);
-        F* dst_code = reinterpret_cast<F*>(&dst);
+        auto* src_code = reinterpret_cast<F*>(&src);
+        auto* dst_code = reinterpret_cast<F*>(&dst);
         new(dst_code) F(std::move(*src_code));
         src_code->~F();
       }
index 59361fe..298f30f 100644 (file)
@@ -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<sg_host_t*>(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<sg_host_t*>(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<sg_host_t> 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<sg_host_t*>(lua_newuserdata(L, sizeof(sg_host_t)));
   *lua_host = host;
   luaL_getmetatable(L, HOST_MODULE_NAME);
   lua_setmetatable(L, -2);
index b29dcde..b10982d 100644 (file)
@@ -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<simgrid::kernel::routing::NetZoneImpl**>(
+     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 */
index c92a795..75d9f75 100644 (file)
@@ -152,7 +152,7 @@ PYBIND11_MODULE(simgrid, m)
   py::class_<Engine>(m, "Engine", "Simulation Engine")
       .def(py::init([](std::vector<std::string> args) {
         static char noarg[] = {'\0'};
-        int argc            = static_cast<int>(args.size());
+        auto argc           = static_cast<int>(args.size());
         auto argv           = std::make_unique<char*[]>(argc + 1);
         for (int i = 0; i != argc; ++i)
           argv[i] = args[i].empty() ? noarg : &args[i].front();
index 295ad66..ac909e7 100644 (file)
@@ -167,7 +167,7 @@ template <typename T> Parmap<T>::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 */
index f0f6442..26acc23 100644 (file)
@@ -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<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
-  std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
+  auto* graph = xbt_graph_new_graph(0, nullptr);
+  auto* nodes = new std::map<std::string, xbt_node_t>();
+  auto* edges = new std::map<std::string, xbt_edge_t>();
 
   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<std::string, xbt_node_t>* nodes = new std::map<std::string, xbt_node_t>();
-  std::map<std::string, xbt_edge_t>* edges = new std::map<std::string, xbt_edge_t>();
+  auto* g     = xbt_graph_new_graph(0, nullptr);
+  auto* nodes = new std::map<std::string, xbt_node_t>();
+  auto* edges = new std::map<std::string, xbt_edge_t>();
   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<unsigned>(currentContainer.size());
-    NetZoneContainer* container = new NetZoneContainer(id, level, currentContainer.back());
+    auto level      = static_cast<unsigned>(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<unsigned>(action.get_variable()->get_number_of_constraint());
+  auto n = static_cast<unsigned>(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<std::string>* filter = new std::set<std::string>();
+  auto* filter = new std::set<std::string>();
   XBT_DEBUG("Starting graph extraction.");
   recursiveGraphExtraction(s4u::Engine::get_instance()->get_netzone_root(), Container::get_root(), filter);
   XBT_DEBUG("Graph extraction finished.");
index 2b06531..1a6ce7e 100644 (file)
@@ -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);
     }
index 63cb6a5..91e3f17 100644 (file)
@@ -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());
 
index 7be3b40..8c752ce 100644 (file)
@@ -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;
index bf3407e..fd9877f 100644 (file)
@@ -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);
index 0c9d9a5..e01aa34 100644 (file)
@@ -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<void()>& 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));
index 7dc6420..be67dd6 100644 (file)
@@ -34,7 +34,7 @@ public:
 protected:
   template <class T, class... Args> T* new_context(Args&&... args)
   {
-    T* context = new T(std::forward<Args>(args)...);
+    auto* context = new T(std::forward<Args>(args)...);
     context->declare_context(sizeof(T));
     return context;
   }
index f7d76cb..37aa9e8 100644 (file)
@@ -51,7 +51,7 @@ void BoostContext::wrapper(BoostContext::arg_type arg)
 
 void BoostContext::swap_into_for_real(SwappedContext* to_)
 {
-  BoostContext* to = static_cast<BoostContext*>(to_);
+  auto* to = static_cast<BoostContext*>(to_);
 #if BOOST_VERSION < 106100
   boost::context::jump_fcontext(&this->fc_, to->fc_, reinterpret_cast<intptr_t>(to));
 #else
index 5a54a95..a0d7a4c 100644 (file)
@@ -89,7 +89,7 @@ SwappedContext::SwappedContext(std::function<void()>&& 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<unsigned char*>(xbt_malloc0(size + xbt_pagesize));
+      auto* alloc          = static_cast<unsigned char*>(xbt_malloc0(size + xbt_pagesize));
       stack_               = alloc - (reinterpret_cast<uintptr_t>(alloc) & (xbt_pagesize - 1)) + xbt_pagesize;
       reinterpret_cast<unsigned char**>(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<SwappedContext*>(process->context_.get());
+          auto* context = static_cast<SwappedContext*>(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<SwappedContext*>(self());
+  auto* old = static_cast<SwappedContext*>(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;
index f31f2e3..42d2be6 100644 (file)
@@ -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<ThreadContext*>(simix_global->maestro_->context_.get());
+  auto* maestro = static_cast<ThreadContext*>(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<ThreadContext*>(simix_global->maestro_->context_.get());
+  auto* maestro = static_cast<ThreadContext*>(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<ThreadContext*>(actor->context_.get());
+    auto* context = static_cast<ThreadContext*>(actor->context_.get());
     context->release();
     context->wait();
   }
index eff10f6..88c40cf 100644 (file)
@@ -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<Variable*>(xbt_mallocator_get(variable_mallocator_));
+  auto* var = static_cast<Variable*>(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)
index b6bdcfd..25457dc 100644 (file)
@@ -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());
index bb78082..763a67f 100644 (file)
@@ -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<GraphNodeData*>(xbt_graph_node_get_data(node));
+    auto* data          = static_cast<GraphNodeData*>(xbt_graph_node_get_data(node));
     data->graph_id_     = cursor;
   }
 }
index ab62664..d891b6f 100644 (file)
@@ -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) {
index 0528a43..ed7e84b 100644 (file)
@@ -68,7 +68,7 @@ int NetZoneImpl::get_host_count() const
 s4u::Host* NetZoneImpl::create_host(const std::string& name, const std::vector<double>& speed_per_pstate,
                                     int coreAmount, const std::map<std::string, std::string>* 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);
 
index b6b01f6..0b7f207 100644 (file)
@@ -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<std::string, xbt_edge_t>* edges)
 {
-  const char* sn   = static_cast<const char*>(xbt_graph_node_get_data(s));
-  const char* dn   = static_cast<const char*>(xbt_graph_node_get_data(d));
+  const auto* sn   = static_cast<const char*>(xbt_graph_node_get_data(s));
+  const auto* dn   = static_cast<const char*>(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<std::string, xbt
       if (my_src == my_dst)
         continue;
 
-      RouteCreationArgs* route = new RouteCreationArgs();
+      auto* route = new RouteCreationArgs();
 
       get_local_route(my_src, my_dst, route, nullptr);
 
@@ -120,7 +120,7 @@ RouteCreationArgs* RoutedZone::new_extended_route(RoutingMode hierarchy, NetPoin
                                                   std::vector<resource::LinkImpl*>& 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.");
index 574153e..6323da9 100644 (file)
@@ -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];
index 2411894..7bdd4ef 100644 (file)
@@ -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<FileSystemStorageExt>()->incr_used_size(write_size);
@@ -509,7 +509,7 @@ std::map<std::string, sg_size_t>* FileSystemDiskExt::parse_content(const std::st
   if (filename.empty())
     return nullptr;
 
-  std::map<std::string, sg_size_t>* parse_content = new std::map<std::string, sg_size_t>();
+  auto* parse_content = new std::map<std::string, sg_size_t>();
 
   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<std::string, sg_size_t>* FileSystemStorageExt::parse_content(const std:
   if (filename.empty())
     return nullptr;
 
-  std::map<std::string, sg_size_t>* parse_content = new std::map<std::string, sg_size_t>();
+  auto* parse_content = new std::map<std::string, sg_size_t>();
 
   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;
index 866e9f6..9f6dc51 100644 (file)
@@ -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 '") +
index 0712e95..aebcd31 100644 (file)
@@ -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<sg_size_t>(computed * dp_rate);
+  auto updated_size = static_cast<sg_size_t>(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<sg_size_t>(comm->get_remaining());
+    auto remaining = static_cast<sg_size_t>(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<sg_size_t>(ramsize) * 1024 * 1024);
+  auto* vm = new simgrid::s4u::VirtualMachine(name, pm, coreAmount, static_cast<sg_size_t>(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);
index b9cc222..9353748 100644 (file)
@@ -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<s4u::Host*>& hosts, const std::vector<do
 
 ExecPtr exec_init(double flops_amount)
 {
-  ExecPtr exec = ExecPtr(new Exec());
+  ExecPtr exec(new Exec());
   exec->set_flops_amount(flops_amount)->set_host(get_host());
   return exec;
 }
@@ -398,7 +398,7 @@ ExecPtr exec_init(const std::vector<s4u::Host*>& hosts, const std::vector<double
   xbt_assert(std::all_of(bytes_amounts.begin(), bytes_amounts.end(), [](double elm) { return std::isfinite(elm); }),
              "flops_amounts comprises infinite values!");
 
-  ExecPtr exec = ExecPtr(new Exec());
+  ExecPtr exec(new Exec());
   exec->set_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<double>(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();
index 3a3c205..01cb3eb 100644 (file)
@@ -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;
index ee13102..80a6105 100644 (file)
@@ -44,7 +44,7 @@ std::set<SD_task_t>* 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<SD_task_t>(action->get_data());
+        auto* task = static_cast<SD_task_t>(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<SD_task_t>* 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<SD_task_t>(action->get_data());
+        auto* task = static_cast<SD_task_t>(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);
index 05a3afc..102acfd 100644 (file)
@@ -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<FILE*>(out);
+  auto* fout = static_cast<FILE*>(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<count; i++)
     list[i] = va_arg(ap, sg_host_t);
index 4e90c3d..63bdd27 100644 (file)
@@ -136,7 +136,7 @@ namespace simix {
 
 Timer* Timer::set(double date, xbt::Task<void()>&& 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;
 }
index ff17a48..8e920dd 100644 (file)
@@ -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<const char*> HostImpl::get_attached_storages()
 }
 std::unordered_map<std::string, s4u::Storage*>* HostImpl::get_mounted_storages()
 {
-  std::unordered_map<std::string, s4u::Storage*>* mounts = new std::unordered_map<std::string, s4u::Storage*>();
+  auto* mounts = new std::unordered_map<std::string, s4u::Storage*>();
   for (auto const& m : storage_) {
     mounts->insert({m.first, m.second->get_iface()});
   }
index 6cbbe10..63effaa 100644 (file)
@@ -196,7 +196,7 @@ std::list<Cpu*> 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<Cpu*>(resource);
+    auto* cpu          = dynamic_cast<Cpu*>(resource);
     if (cpu != nullptr)
       retlist.push_back(cpu);
   }
index 1c1241d..f6b424c 100644 (file)
@@ -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<NetworkCm02Action&>(*it);
+    auto& action = static_cast<NetworkCm02Action&>(*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;
index 0a8c889..ce8a68c 100644 (file)
@@ -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<simgrid::kernel::resource::NetworkIBModel*>(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);
index 764c414..2532035 100644 (file)
@@ -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<const NetworkAction&>(action);
+    const auto& net_action = static_cast<const NetworkAction&>(action);
     if (net_action.latency_ > 0)
       minRes = (minRes < 0) ? net_action.latency_ : std::min(minRes, net_action.latency_);
   }
@@ -190,7 +190,7 @@ std::list<LinkImpl*> 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<LinkImpl*>(resource);
+    auto* link         = dynamic_cast<LinkImpl*>(resource);
     if (link != nullptr)
       retlist.push_back(link);
   }
index 9c60524..76f2f57 100644 (file)
@@ -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<int>(host_rates_.size());
+  size_t nSTA = host_rates_.size();
 
   std::vector<Metric> new_bandwidths;
   for (auto bandwidth : bandwidths_){
index d1f2593..fb4cb6e 100644 (file)
@@ -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<const L07Action&>(action);
+    const auto& net_action = static_cast<const L07Action&>(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<L07Action&>(*it);
+    auto& action = static_cast<L07Action&>(*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<s4u::Host
 kernel::resource::Action* NetworkL07Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
 {
   std::vector<s4u::Host*> 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<s4u::Host*> 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<L07Action*>(execution_start(1.0));
+  auto* action = static_cast<L07Action*>(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);
index e493ca1..9ae69ac 100644 (file)
@@ -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<ClusterZone*>(routing_get_current());
+  auto* current_as = static_cast<ClusterZone*>(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<simgrid::kernel::routing::ClusterZone*>(current_routing);
+  auto* cluster = dynamic_cast<simgrid::kernel::routing::ClusterZone*>(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<std::unordered_map<std::string, std::string>> 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<simgrid::kernel::routing::VivaldiZone*>(current_routing);
+  auto* as = dynamic_cast<simgrid::kernel::routing::VivaldiZone*>(current_routing);
   xbt_assert(as, "<peer> tag can only be used in Vivaldi netzones.");
 
   std::vector<double> speed_per_pstate;
index 9c8f230..5216e3c 100644 (file)
@@ -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);
   }
index f8fcade..09f67cd 100644 (file)
@@ -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<int>* explodesRadical(const std::string& radicals)
 {
-  std::vector<int>* exploded = new std::vector<int>();
+  auto* exploded = new std::vector<int>();
 
   // Make all hosts
   std::vector<std::string> radical_elements;
index f317be5..ef9fcf6 100644 (file)
@@ -265,7 +265,7 @@ public:
   {
     xbt_assert(options.find(name) == options.end(), "Refusing to register the config element '%s' twice.",
                name.c_str());
-    TypedConfigurationElement<T>* variable = new TypedConfigurationElement<T>(name, std::forward<A>(a)...);
+    auto* variable = new TypedConfigurationElement<T>(name, std::forward<A>(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);
index 8753f29..af97e2d 100644 (file)
@@ -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_dictelm_t*>(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;
index 5891394..168a9b4 100644 (file)
@@ -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<char*>(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<char*>(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<char*>(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<char*>(xbt_malloc(10));
     for (int i = 0; i < 20; i++) {
       for (int j = 0; j < NB_ELM; j++) {
         snprintf(key, 10, "%d", j);
index ae898ab..cab503c 100644 (file)
@@ -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<char*>(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<char*>(dynar->data);
   const unsigned long elmsize = dynar->elmsize;
   const unsigned long used = dynar->used;
 
index 344dab7..8e8831d 100644 (file)
@@ -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<xbt_log_append2_file_t>(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<xbt_log_append2_file_t>(this_->data);
+  auto* data = static_cast<xbt_log_append2_file_t>(this_->data);
   if (data->file)
     fclose(data->file);
   xbt_free(data->filename);
index 00e58fd..6680282 100644 (file)
@@ -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<char*>(l->data);
+  auto* q = static_cast<char*>(l->data);
   while (*q != '\0') {
     if (*q == '%') {
       q++;
index 81ed1aa..8d4a82e 100644 (file)
@@ -35,7 +35,7 @@ template <typename F> void test_parse_error(F function, const std::string& name,
 template <typename F, typename T> void test_parse_ok(F function, const std::string& name, const char* str, T value)
 {
   INFO(name);
-  T variable = static_cast<T>(-9999);
+  auto variable = static_cast<T>(-9999);
   REQUIRE_NOTHROW(variable = function(str, "Parse error"));
   REQUIRE(variable == value); /* Fail to parse str */
 }