Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Replace redundant type with "auto" (examples/).
authorArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sat, 3 Oct 2020 19:48:41 +0000 (21:48 +0200)
committerArnaud Giersch <arnaud.giersch@univ-fcomte.fr>
Sun, 4 Oct 2020 19:53:35 +0000 (21:53 +0200)
38 files changed:
examples/s4u/actor-create/s4u-actor-create.cpp
examples/s4u/app-bittorrent/s4u-peer.cpp
examples/s4u/app-bittorrent/s4u-tracker.cpp
examples/s4u/app-chainsend/s4u-app-chainsend.cpp
examples/s4u/app-masterworkers/s4u-app-masterworkers-class.cpp
examples/s4u/app-masterworkers/s4u-app-masterworkers-fun.cpp
examples/s4u/app-pingpong/s4u-app-pingpong.cpp
examples/s4u/app-token-ring/s4u-app-token-ring.cpp
examples/s4u/cloud-capping/s4u-cloud-capping.cpp
examples/s4u/cloud-migration/s4u-cloud-migration.cpp
examples/s4u/cloud-simple/s4u-cloud-simple.cpp
examples/s4u/comm-dependent/s4u-comm-dependent.cpp
examples/s4u/comm-ready/s4u-comm-ready.cpp
examples/s4u/comm-suspend/s4u-comm-suspend.cpp
examples/s4u/comm-wait/s4u-comm-wait.cpp
examples/s4u/comm-waitall/s4u-comm-waitall.cpp
examples/s4u/comm-waitany/s4u-comm-waitany.cpp
examples/s4u/comm-waituntil/s4u-comm-waituntil.cpp
examples/s4u/dht-chord/s4u-dht-chord-node.cpp
examples/s4u/dht-kademlia/node.cpp
examples/s4u/dht-kademlia/s4u-dht-kademlia.cpp
examples/s4u/energy-link/s4u-energy-link.cpp
examples/s4u/energy-vm/s4u-energy-vm.cpp
examples/s4u/io-disk-raw/s4u-io-disk-raw.cpp
examples/s4u/io-file-system/s4u-io-file-system.cpp
examples/s4u/maestro-set/s4u-maestro-set.cpp
examples/s4u/mc-bugged1-liveness/s4u-mc-bugged1-liveness.cpp
examples/s4u/mc-bugged1/s4u-mc-bugged1.cpp
examples/s4u/mc-bugged2/s4u-mc-bugged2.cpp
examples/s4u/mc-electric-fence/s4u-mc-electric-fence.cpp
examples/s4u/mc-failing-assert/s4u-mc-failing-assert.cpp
examples/s4u/network-ns3/s4u-network-ns3.cpp
examples/s4u/platform-failures/s4u-platform-failures.cpp
examples/s4u/replay-comm/s4u-replay-comm.cpp
examples/s4u/replay-io/s4u-replay-io.cpp
examples/s4u/synchro-semaphore/s4u-synchro-semaphore.cpp
examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp
examples/smpi/smpi_s4u_masterworker/masterworker_mailbox_smpi.cpp

index ee1e6ef..874e36a 100644 (file)
@@ -33,9 +33,9 @@ static void receiver(const std::string& mailbox_name)
 
   XBT_INFO("Hello s4u, I'm ready to get any message you'd want on %s", mailbox->get_cname());
 
-  const std::string* msg1 = static_cast<std::string*>(mailbox->get());
-  const std::string* msg2 = static_cast<std::string*>(mailbox->get());
-  const std::string* msg3 = static_cast<std::string*>(mailbox->get());
+  const auto* msg1 = static_cast<std::string*>(mailbox->get());
+  const auto* msg2 = static_cast<std::string*>(mailbox->get());
+  const auto* msg3 = static_cast<std::string*>(mailbox->get());
   XBT_INFO("I received '%s', '%s' and '%s'", msg1->c_str(), msg2->c_str(), msg3->c_str());
   delete msg1;
   delete msg2;
@@ -49,7 +49,7 @@ static void forwarder(int argc, char** argv)
   xbt_assert(argc >= 3, "Actor forwarder requires 2 parameters, but got only %d", argc - 1);
   simgrid::s4u::Mailbox* in    = simgrid::s4u::Mailbox::by_name(argv[1]);
   simgrid::s4u::Mailbox* out   = simgrid::s4u::Mailbox::by_name(argv[2]);
-  std::string* msg             = static_cast<std::string*>(in->get());
+  auto* msg                    = static_cast<std::string*>(in->get());
   XBT_INFO("Forward '%s'.", msg->c_str());
   out->put(msg, msg->size());
 }
index d653c2a..fe653ac 100644 (file)
@@ -78,7 +78,7 @@ bool Peer::getPeersFromTracker()
 {
   simgrid::s4u::Mailbox* tracker_mailbox = simgrid::s4u::Mailbox::by_name(TRACKER_MAILBOX);
   // Build the task to send to the tracker
-  TrackerQuery* peer_request = new TrackerQuery(id, mailbox_);
+  auto* peer_request = new TrackerQuery(id, mailbox_);
   try {
     XBT_DEBUG("Sending a peer request to the tracker.");
     tracker_mailbox->put(peer_request, TRACKER_COMM_SIZE, GET_PEERS_TIMEOUT);
@@ -89,7 +89,7 @@ bool Peer::getPeersFromTracker()
   }
 
   try {
-    TrackerAnswer* answer = static_cast<TrackerAnswer*>(mailbox_->get(GET_PEERS_TIMEOUT));
+    auto* answer = static_cast<TrackerAnswer*>(mailbox_->get(GET_PEERS_TIMEOUT));
     // Add the peers the tracker gave us to our peer list.
     for (auto const& peer_id : answer->getPeers())
       if (id != peer_id)
@@ -106,7 +106,7 @@ void Peer::sendHandshakeToAllPeers()
 {
   for (auto const& kv : connected_peers) {
     const Connection& remote_peer = kv.second;
-    Message* handshake      = new Message(MESSAGE_HANDSHAKE, id, mailbox_);
+    auto* handshake               = new Message(MESSAGE_HANDSHAKE, id, mailbox_);
     remote_peer.mailbox_->put_init(handshake, MESSAGE_HANDSHAKE_SIZE)->detach();
     XBT_DEBUG("Sending a HANDSHAKE to %d", remote_peer.id);
   }
index ee4a401..ba7c3fd 100644 (file)
@@ -36,7 +36,7 @@ void Tracker::operator()()
     if (comm->test()) {
       // Retrieve the data sent by the peer.
       xbt_assert(received != nullptr);
-      TrackerQuery* tq = static_cast<TrackerQuery*>(received);
+      auto* tq = static_cast<TrackerQuery*>(received);
 
       // Add the peer to our peer list, if not already known.
       if (known_peers.find(tq->getPeerId()) == known_peers.end()) {
@@ -44,7 +44,7 @@ void Tracker::operator()()
       }
 
       // Sending back peers to the requesting peer
-      TrackerAnswer* ta = new TrackerAnswer(TRACKER_QUERY_INTERVAL);
+      auto* ta = new TrackerAnswer(TRACKER_QUERY_INTERVAL);
       std::set<int>::iterator next_peer;
       int nb_known_peers = static_cast<int>(known_peers.size());
       int max_tries      = std::min(MAXIMUM_PEERS, nb_known_peers);
index 6da10d6..ffce1cd 100644 (file)
@@ -47,7 +47,7 @@ public:
 
   void joinChain()
   {
-    const ChainMessage* msg = static_cast<ChainMessage*>(me->get());
+    const auto* msg   = static_cast<ChainMessage*>(me->get());
     prev              = msg->prev_;
     next              = msg->next_;
     total_pieces      = msg->num_pieces;
@@ -139,7 +139,7 @@ static void peer()
 {
   XBT_DEBUG("peer");
 
-  Peer* p = new Peer();
+  auto* p = new Peer();
 
   double start_time = simgrid::s4u::Engine::get_clock();
   p->joinChain();
@@ -158,7 +158,7 @@ static void broadcaster(int hostcount, unsigned int piece_count)
 {
   XBT_DEBUG("broadcaster");
 
-  Broadcaster* bc = new Broadcaster(hostcount, piece_count);
+  auto* bc = new Broadcaster(hostcount, piece_count);
   bc->buildChain();
   bc->sendFile();
 
index 9c83964..7dd3860 100644 (file)
@@ -67,7 +67,7 @@ public:
   {
     double compute_cost;
     do {
-      const double* msg = static_cast<double*>(mailbox->get());
+      const auto* msg = static_cast<double*>(mailbox->get());
       compute_cost = *msg;
       delete msg;
 
index a348d98..72ff9cd 100644 (file)
@@ -54,7 +54,7 @@ static void worker(std::vector<std::string> args)
 
   double compute_cost;
   do {
-    const double* msg = static_cast<double*>(mailbox->get());
+    const auto* msg = static_cast<double*>(mailbox->get());
     compute_cost = *msg;
     delete msg;
 
index f80ef71..9407c7c 100644 (file)
@@ -12,12 +12,11 @@ static void pinger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mai
   XBT_INFO("Ping from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str());
 
   /* - Do the ping with a 1-Byte payload (latency bound) ... */
-  double* payload = new double();
-  *payload        = simgrid::s4u::Engine::get_clock();
+  auto* payload = new double(simgrid::s4u::Engine::get_clock());
 
   mailbox_out->put(payload, 1);
   /* - ... then wait for the (large) pong */
-  const double* sender_time = static_cast<double*>(mailbox_in->get());
+  const auto* sender_time = static_cast<double*>(mailbox_in->get());
 
   double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
   XBT_INFO("Payload received : large communication (bandwidth bound)");
@@ -30,15 +29,14 @@ static void ponger(simgrid::s4u::Mailbox* mailbox_in, simgrid::s4u::Mailbox* mai
   XBT_INFO("Pong from mailbox %s to mailbox %s", mailbox_in->get_name().c_str(), mailbox_out->get_name().c_str());
 
   /* - Receive the (small) ping first ....*/
-  const double* sender_time = static_cast<double*>(mailbox_in->get());
+  const auto* sender_time   = static_cast<double*>(mailbox_in->get());
   double communication_time = simgrid::s4u::Engine::get_clock() - *sender_time;
   XBT_INFO("Payload received : small communication (latency bound)");
   XBT_INFO("Ping time (latency bound) %f", communication_time);
   delete sender_time;
 
   /*  - ... Then send a 1GB pong back (bandwidth bound) */
-  double* payload = new double();
-  *payload        = simgrid::s4u::Engine::get_clock();
+  auto* payload = new double(simgrid::s4u::Engine::get_clock());
   XBT_INFO("payload = %.3f", *payload);
 
   mailbox_out->put(payload, 1e9);
index 9ead2ac..ea3ad78 100644 (file)
@@ -40,10 +40,10 @@ public:
       XBT_INFO("Host \"%u\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox->get_cname());
       std::string msg = "Token";
       neighbor_mailbox->put(&msg, token_size);
-      const std::string* res = static_cast<std::string*>(my_mailbox->get());
+      const auto* res = static_cast<std::string*>(my_mailbox->get());
       XBT_INFO("Host \"%u\" received \"%s\"", rank, res->c_str());
     } else {
-      std::string* res = static_cast<std::string*>(my_mailbox->get());
+      auto* res = static_cast<std::string*>(my_mailbox->get());
       XBT_INFO("Host \"%u\" received \"%s\"", rank, res->c_str());
       XBT_INFO("Host \"%u\" send 'Token' to Host \"%s\"", rank, neighbor_mailbox->get_cname());
       neighbor_mailbox->put(res, token_size);
index 5860b85..b39b519 100644 (file)
@@ -56,8 +56,8 @@ static void test_dynamic_change()
 {
   simgrid::s4u::Host* pm0 = simgrid::s4u::Host::by_name("Fafard");
 
-  simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
-  simgrid::s4u::VirtualMachine* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
+  auto* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+  auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
   vm0->start();
   vm1->start();
 
@@ -165,7 +165,7 @@ static void master_main()
   test_two_activities(pm0, pm0);
   XBT_INFO(" ");
 
-  simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+  auto* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
   vm0->start();
 
   XBT_INFO("# 3. Put a single activity on a VM. ");
index 11c690b..b0ada3d 100644 (file)
@@ -30,7 +30,7 @@ static void master_main()
   simgrid::s4u::Host* pm1 = simgrid::s4u::Host::by_name("Tremblay");
   simgrid::s4u::Host* pm2 = simgrid::s4u::Host::by_name("Bourassa");
 
-  simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+  auto* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
   vm0->set_ramsize(1e9); // 1Gbytes
   vm0->start();
 
@@ -48,8 +48,8 @@ static void master_main()
 
   vm0->destroy();
 
-  vm0                               = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
-  simgrid::s4u::VirtualMachine* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
+  vm0       = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+  auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
 
   vm0->set_ramsize(1e9); // 1Gbytes
   vm1->set_ramsize(1e9); // 1Gbytes
index f8b83b9..65cc5fe 100644 (file)
@@ -33,7 +33,7 @@ struct s_payload {
 static void communication_tx_fun(std::vector<std::string> args)
 {
   simgrid::s4u::Mailbox* mbox   = simgrid::s4u::Mailbox::by_name(args.at(0));
-  s_payload* payload            = new s_payload;
+  auto* payload                 = new s_payload;
   payload->tx_actor_name        = simgrid::s4u::Actor::self()->get_cname();
   payload->tx_host              = simgrid::s4u::this_actor::get_host();
   payload->clock_sta            = simgrid::s4u::Engine::get_clock();
@@ -47,7 +47,7 @@ static void communication_rx_fun(std::vector<std::string> args)
   const char* host_name         = simgrid::s4u::this_actor::get_host()->get_cname();
   simgrid::s4u::Mailbox* mbox   = simgrid::s4u::Mailbox::by_name(args.at(0));
 
-  const s_payload* payload  = static_cast<struct s_payload*>(mbox->get());
+  const auto* payload       = static_cast<struct s_payload*>(mbox->get());
   double clock_end          = simgrid::s4u::Engine::get_clock();
 
   XBT_INFO("%s:%s to %s:%s => %g sec", payload->tx_host->get_cname(), payload->tx_actor_name, host_name, actor_name,
@@ -95,7 +95,7 @@ static void master_main()
       "## Test 2 (started): check impact of running an activity inside a VM (there is no degradation for the moment)");
 
   XBT_INFO("### Put a VM on a PM, and put an activity to the VM");
-  simgrid::s4u::VirtualMachine* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
+  auto* vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
   vm0->start();
   launch_computation_worker(vm0);
   simgrid::s4u::this_actor::sleep_for(2);
@@ -121,7 +121,7 @@ static void master_main()
   XBT_INFO("### Put two VMs on a PM, and put an activity to each VM");
   vm0 = new simgrid::s4u::VirtualMachine("VM0", pm0, 1);
   vm0->start();
-  simgrid::s4u::VirtualMachine* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
+  auto* vm1 = new simgrid::s4u::VirtualMachine("VM1", pm0, 1);
   launch_computation_worker(vm0);
   launch_computation_worker(vm1);
   simgrid::s4u::this_actor::sleep_for(2);
index 0e5f9ba..b1add65 100644 (file)
@@ -9,8 +9,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_comm_dependent, "Messages specific for this s4u
 
 static void sender(simgrid::s4u::Mailbox* mailbox)
 {
-  double* computation_amount = new double();
-  *computation_amount        = simgrid::s4u::this_actor::get_host()->get_speed();
+  auto* computation_amount   = new double(simgrid::s4u::this_actor::get_host()->get_speed());
   simgrid::s4u::ExecPtr exec = simgrid::s4u::this_actor::exec_init(2 * (*computation_amount));
   simgrid::s4u::CommPtr comm = mailbox->put_init(computation_amount, 7e6);
 
index 85867a6..ec1cf06 100644 (file)
@@ -48,7 +48,7 @@ static void peer(int argc, char** argv)
         simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
         std::string msgName =
             std::string("Message ") + std::to_string(i) + std::string(" from peer ") + std::to_string(my_id);
-        std::string* payload = new std::string(msgName); // copy the data we send:
+        auto* payload = new std::string(msgName); // copy the data we send:
         // 'msgName' is not a stable storage location
         XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
         /* Create a communication representing the ongoing communication */
@@ -62,7 +62,7 @@ static void peer(int argc, char** argv)
     if (peer_id != my_id) {
       std::string mboxName        = std::string("peer-") + std::to_string(peer_id);
       simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
-      std::string* payload        = new std::string("finalize"); // Make a copy of the data we will send
+      auto* payload               = new std::string("finalize"); // Make a copy of the data we will send
       pending_comms.push_back(mbox->put_async(payload, msg_size));
       XBT_INFO("Send 'finalize' to 'peer-%d'", peer_id);
     }
@@ -75,7 +75,7 @@ static void peer(int argc, char** argv)
   while (pending_finalize_messages > 0) {
     if (my_mbox->ready()) {
       double start                = simgrid::s4u::Engine::get_clock();
-      const std::string* received = static_cast<std::string*>(my_mbox->get());
+      const auto* received        = static_cast<std::string*>(my_mbox->get());
       double waiting_time         = simgrid::s4u::Engine::get_clock() - start;
       xbt_assert(
           waiting_time == 0,
index 144a029..b0c7c8a 100644 (file)
@@ -20,7 +20,7 @@ static void sender(int argc, char**)
 
   // Copy the data we send: the 'msg_content' variable is not a stable storage location.
   // It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
-  std::string* payload = new std::string("Sent message");
+  auto* payload = new std::string("Sent message");
 
   /* Create a communication representing the ongoing communication and then */
   simgrid::s4u::CommPtr comm = mbox->put_init(payload, 13194230);
@@ -49,7 +49,7 @@ static void receiver(int, char**)
   XBT_INFO("Wait for the message.");
   void* payload = mbox->get();
 
-  const std::string* received = static_cast<std::string*>(payload);
+  const auto* received = static_cast<std::string*>(payload);
   XBT_INFO("I got '%s'.", received->c_str());
 
   delete received;
index 1664f4b..b2e5314 100644 (file)
@@ -35,7 +35,7 @@ static void sender(int argc, char** argv)
     std::string msg_content = std::string("Message ") + std::to_string(i);
     // Copy the data we send: the 'msg_content' variable is not a stable storage location.
     // It will be destroyed when this actor leaves the loop, ie before the receiver gets the data
-    std::string* payload = new std::string(msg_content);
+    auto* payload = new std::string(msg_content);
 
     /* Create a communication representing the ongoing communication and then */
     simgrid::s4u::CommPtr comm = mbox->put_async(payload, msg_size);
@@ -79,7 +79,7 @@ static void receiver(int, char**)
       comm->wait();
     }
 
-    const std::string* received = static_cast<std::string*>(payload);
+    const auto* received = static_cast<std::string*>(payload);
     XBT_INFO("I got a '%s'.", received->c_str());
     if (*received == "finalize")
       cont = false; // If it's a finalize message, we're done.
index 34cb0f5..2c2a60b 100644 (file)
@@ -49,7 +49,7 @@ public:
       std::string msg_content = std::string("Message ") + std::to_string(i);
       // Copy the data we send: the 'msg_content' variable is not a stable storage location.
       // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
-      std::string* payload = new std::string(msg_content);
+      auto* payload = new std::string(msg_content);
 
       XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname());
 
@@ -89,7 +89,7 @@ public:
   {
     XBT_INFO("Wait for my first message");
     for (bool cont = true; cont;) {
-      const std::string* received = static_cast<std::string*>(mbox->get());
+      const auto* received = static_cast<std::string*>(mbox->get());
       XBT_INFO("I got a '%s'.", received->c_str());
       cont = (*received != "finalize"); // If it's a finalize message, we're done
       // Receiving the message was all we were supposed to do
index 825de57..98b3e56 100644 (file)
@@ -52,7 +52,7 @@ public:
       std::string msg_content = std::string("Message ") + std::to_string(i);
       // Copy the data we send: the 'msg_content' variable is not a stable storage location.
       // It will be destroyed when this actor leaves the loop, ie before the receiver gets it
-      std::string* payload = new std::string(msg_content);
+      auto* payload = new std::string(msg_content);
 
       XBT_INFO("Send '%s' to '%s'", msg_content.c_str(), mboxes[i % receivers_count]->get_cname());
 
@@ -102,7 +102,7 @@ public:
   {
     XBT_INFO("Wait for my first message");
     for (bool cont = true; cont;) {
-      const std::string* received = static_cast<std::string*>(mbox->get());
+      const auto* received = static_cast<std::string*>(mbox->get());
       XBT_INFO("I got a '%s'.", received->c_str());
       cont = (*received != "finalize"); // If it's a finalize message, we're done
       // Receiving the message was all we were supposed to do
index d887e37..33597a4 100644 (file)
@@ -31,7 +31,7 @@ static void sender(int argc, char** argv)
     std::string mboxName        = std::string("receiver-") + std::to_string(i % receivers_count);
     simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
     std::string msgName         = std::string("Message ") + std::to_string(i);
-    std::string* payload        = new std::string(msgName); // copy the data we send:
+    auto* payload               = new std::string(msgName); // copy the data we send:
 
     // 'msgName' is not a stable storage location
     XBT_INFO("Send '%s' to '%s'", msgName.c_str(), mboxName.c_str());
@@ -45,7 +45,7 @@ static void sender(int argc, char** argv)
   for (int i = 0; i < receivers_count; i++) {
     std::string mboxName        = std::string("receiver-") + std::to_string(i % receivers_count);
     simgrid::s4u::Mailbox* mbox = simgrid::s4u::Mailbox::by_name(mboxName);
-    std::string* payload        = new std::string("finalize"); // Make a copy of the data we will send
+    auto* payload               = new std::string("finalize"); // Make a copy of the data we will send
 
     simgrid::s4u::CommPtr comm = mbox->put_async(payload, 0);
     pending_comms.push_back(comm);
@@ -71,7 +71,7 @@ static void receiver(int argc, char** argv)
 
   XBT_INFO("Wait for my first message");
   for (bool cont = true; cont;) {
-    const std::string* received = static_cast<std::string*>(mbox->get());
+    const auto* received = static_cast<std::string*>(mbox->get());
     XBT_INFO("I got a '%s'.", received->c_str());
     if (*received == "finalize")
       cont = false; // If it's a finalize message, we're done.
index fbfdec6..abb632b 100644 (file)
@@ -104,7 +104,7 @@ void Node::leave()
 void Node::notifyAndQuit()
 {
   // send the PREDECESSOR_LEAVING to our successor
-  ChordMessage* pred_msg = new ChordMessage(PREDECESSOR_LEAVING);
+  auto* pred_msg         = new ChordMessage(PREDECESSOR_LEAVING);
   pred_msg->request_id   = pred_id_;
   pred_msg->answer_to    = mailbox_;
 
@@ -118,7 +118,7 @@ void Node::notifyAndQuit()
 
   if (pred_id_ != -1 && pred_id_ != id_) {
     // send the SUCCESSOR_LEAVING to our predecessor (only if I have one that is not me)
-    ChordMessage* succ_msg = new ChordMessage(SUCCESSOR_LEAVING);
+    auto* succ_msg         = new ChordMessage(SUCCESSOR_LEAVING);
     succ_msg->request_id   = fingers_[0];
     succ_msg->answer_to    = mailbox_;
     XBT_DEBUG("Sending a 'SUCCESSOR_LEAVING' to my predecessor %d", pred_id_);
@@ -208,7 +208,7 @@ void Node::checkPredecessor()
   simgrid::s4u::Mailbox* mailbox        = simgrid::s4u::Mailbox::by_name(std::to_string(pred_id_));
   simgrid::s4u::Mailbox* return_mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_is_alive");
 
-  ChordMessage* message = new ChordMessage(PREDECESSOR_ALIVE);
+  auto* message         = new ChordMessage(PREDECESSOR_ALIVE);
   message->request_id   = pred_id_;
   message->answer_to    = return_mailbox;
 
@@ -248,7 +248,7 @@ int Node::remoteGetPredecessor(int ask_to)
   simgrid::s4u::Mailbox* mailbox          = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
   simgrid::s4u::Mailbox* return_mailbox   = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_pred");
 
-  ChordMessage* message = new ChordMessage(GET_PREDECESSOR);
+  auto* message         = new ChordMessage(GET_PREDECESSOR);
   message->request_id   = id_;
   message->answer_to    = return_mailbox;
 
@@ -269,7 +269,7 @@ int Node::remoteGetPredecessor(int ask_to)
 
   try {
     comm->wait_for(timeout);
-    const ChordMessage* answer = static_cast<ChordMessage*>(data);
+    const auto* answer = static_cast<ChordMessage*>(data);
     XBT_DEBUG("Received the answer to my 'Get Predecessor' request: the predecessor of node %d is %d", ask_to,
               answer->answer_id);
     predecessor_id = answer->answer_id;
@@ -320,7 +320,7 @@ int Node::remoteFindSuccessor(int ask_to, int id)
   simgrid::s4u::Mailbox* mailbox          = simgrid::s4u::Mailbox::by_name(std::to_string(ask_to));
   simgrid::s4u::Mailbox* return_mailbox   = simgrid::s4u::Mailbox::by_name(std::to_string(id_) + "_succ");
 
-  ChordMessage* message = new ChordMessage(FIND_SUCCESSOR);
+  auto* message         = new ChordMessage(FIND_SUCCESSOR);
   message->request_id   = id_;
   message->answer_to    = return_mailbox;
 
@@ -366,7 +366,7 @@ void Node::notify(int predecessor_candidate_id)
 /* Notifies a remote node that its predecessor may have changed. */
 void Node::remoteNotify(int notify_id, int predecessor_candidate_id) const
 {
-  ChordMessage* message = new ChordMessage(NOTIFY);
+  auto* message         = new ChordMessage(NOTIFY);
   message->request_id   = predecessor_candidate_id;
   message->answer_to    = nullptr;
 
@@ -510,7 +510,7 @@ void Node::operator()()
 
     if (comm_completed) {
       if (data != nullptr) {
-        ChordMessage* message = static_cast<ChordMessage*>(data);
+        auto* message = static_cast<ChordMessage*>(data);
         handleMessage(message);
         data = nullptr;
       }
index f98c9ef..c119239 100644 (file)
@@ -11,7 +11,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(kademlia_node, "Messages specific for this example"
 namespace kademlia {
 static void destroy(void* message)
 {
-  const Message* msg = static_cast<Message*>(message);
+  const auto* msg = static_cast<Message*>(message);
   delete msg->answer_;
   delete msg;
 }
@@ -40,7 +40,7 @@ bool Node::join(unsigned int known_id)
       XBT_DEBUG("Received an answer from the node I know.");
       got_answer = true;
       // retrieve the node list and ping them.
-      const Message* msg = static_cast<Message*>(received_msg);
+      const auto* msg = static_cast<Message*>(received_msg);
       node_list    = msg->answer_;
       if (node_list) {
         for (auto const& contact : node_list->getNodes())
@@ -81,8 +81,8 @@ void Node::sendFindNode(unsigned int id, unsigned int destination) const
   simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id));
   /* Build the task */
 
-  Message* msg = new Message(id_, destination, simgrid::s4u::Mailbox::by_name(std::to_string(id_)),
-                             simgrid::s4u::Host::current()->get_cname());
+  auto* msg = new Message(id_, destination, simgrid::s4u::Mailbox::by_name(std::to_string(id_)),
+                          simgrid::s4u::Host::current()->get_cname());
 
   /* Send the task */
   mailbox->put_init(msg, 1)->detach(kademlia::destroy);
@@ -144,7 +144,7 @@ void Node::routingTableUpdate(unsigned int id)
   */
 Answer* Node::findClosest(unsigned int destination_id)
 {
-  Answer* answer = new Answer(destination_id);
+  auto* answer = new Answer(destination_id);
   /* We find the corresponding bucket for the id */
   const Bucket* bucket = table.findBucket(destination_id);
   int bucket_id  = bucket->getId();
@@ -205,7 +205,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
         receive_comm = mailbox->get_async(&received_msg);
 
       if (receive_comm->test()) {
-        const Message* msg = static_cast<Message*>(received_msg);
+        const auto* msg = static_cast<Message*>(received_msg);
         // Check if what we have received is what we are looking for.
         if (msg->answer_ && msg->answer_->getDestinationId() == id_to_find) {
           routingTableUpdate(msg->sender_id_);
@@ -273,7 +273,7 @@ void Node::handleFindNode(const Message* msg)
   XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", msg->answer_to_->get_cname(),
            msg->issuer_host_name_.c_str(), msg->destination_id_);
   // Building the answer to the request
-  Message* answer =
+  auto* answer =
       new Message(id_, msg->destination_id_, findClosest(msg->destination_id_),
                   simgrid::s4u::Mailbox::by_name(std::to_string(id_)), simgrid::s4u::Host::current()->get_cname());
   // Sending the answer
index 1912ef6..0c7f779 100644 (file)
@@ -52,7 +52,7 @@ static void node(int argc, char* argv[])
 
       if (node.receive_comm->test()) {
         // There has been a message, we need to handle it !
-        const kademlia::Message* msg = static_cast<kademlia::Message*>(node.received_msg);
+        const auto* msg = static_cast<kademlia::Message*>(node.received_msg);
         if (msg) {
           node.handleFindNode(msg);
           delete msg->answer_;
index a44c445..ff0359f 100644 (file)
@@ -52,7 +52,7 @@ static void receiver(std::vector<std::string> args)
     void* res = mailbox->get();
     xbt_free(res);
   } else {
-    void** data= new void*[flow_amount];
+    auto* data = new void*[flow_amount];
 
     // Start all comms in parallel, and wait for their completion in one shot
     std::vector<simgrid::s4u::CommPtr> comms;
index 91b97bf..d276c7e 100644 (file)
@@ -23,9 +23,9 @@ static void dvfs()
 
   /* Host 1 */
   XBT_INFO("Creating and starting two VMs");
-  simgrid::s4u::VirtualMachine* vm_host1 = new simgrid::s4u::VirtualMachine("vm_host1", host1, 1);
+  auto* vm_host1 = new simgrid::s4u::VirtualMachine("vm_host1", host1, 1);
   vm_host1->start();
-  simgrid::s4u::VirtualMachine* vm_host2 = new simgrid::s4u::VirtualMachine("vm_host2", host2, 1);
+  auto* vm_host2 = new simgrid::s4u::VirtualMachine("vm_host2", host2, 1);
   vm_host2->start();
 
   XBT_INFO("Create two activities on Host1: both inside a VM");
index 7ec2999..d7ebe32 100644 (file)
@@ -34,7 +34,7 @@ static void host()
   /* - Attach some user data to disk1 */
   XBT_INFO("*** Get/set data for storage element: Disk1 ***");
 
-  const std::string* data = static_cast<std::string*>(disk->get_data());
+  const auto* data = static_cast<std::string*>(disk->get_data());
 
   XBT_INFO("Get storage data: '%s'", data ? data->c_str() : "No user data");
 
index bdc6629..229479f 100644 (file)
@@ -32,7 +32,7 @@ public:
 
     // Open an non-existing file to create it
     std::string filename     = "/scratch/tmp/data.txt";
-    simgrid::s4u::File* file = new simgrid::s4u::File(filename, nullptr);
+    auto* file               = new simgrid::s4u::File(filename, nullptr);
 
     sg_size_t write = file->write(200000); // Write 200,000 bytes
     XBT_INFO("Create a %llu bytes file named '%s' on /scratch", write, filename.c_str());
@@ -57,7 +57,7 @@ public:
 
     // Test attaching some user data to the file
     file->set_data(new std::string("777"));
-    const std::string* file_data = static_cast<std::string*>(file->get_data());
+    const auto* file_data = static_cast<std::string*>(file->get_data());
     XBT_INFO("User data attached to the file: %s", file_data->c_str());
     delete file_data;
 
index 00982ec..8188c9c 100644 (file)
@@ -40,7 +40,7 @@ static void ensure_other_tid()
 static void sender()
 {
   ensure_root_tid();
-  std::string* payload = new std::string("some message");
+  auto* payload = new std::string("some message");
   simgrid::s4u::Mailbox::by_name("some mailbox")->put((void*)payload, 10e8);
 }
 
@@ -48,7 +48,7 @@ static void receiver()
 {
   ensure_other_tid();
 
-  const std::string* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
+  const auto* payload = static_cast<std::string*>(simgrid::s4u::Mailbox::by_name("some mailbox")->get());
   XBT_INFO("Task received");
   delete payload;
 }
index 175d561..2e23b12 100644 (file)
@@ -101,7 +101,7 @@ static void client(int id)
       XBT_INFO("Propositions changed : r=1, cs=0");
     }
 
-    const Message* grant = static_cast<Message*>(my_mailbox->get());
+    const auto* grant = static_cast<Message*>(my_mailbox->get());
 
     if ((id == 1) && (grant->kind == Message::Kind::GRANT)) {
       cs = 1;
index 74ca56f..e642594 100644 (file)
@@ -35,8 +35,7 @@ static void server()
 
 static void client(int id)
 {
-  int* payload = new int();
-  *payload     = id;
+  auto* payload = new int(id);
   simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload, 10000);
 
   XBT_INFO("Sent!");
index 66c085e..6555885 100644 (file)
@@ -43,10 +43,8 @@ static void server()
 
 static void client(int id)
 {
-  int* payload1 = new int();
-  *payload1     = id;
-  int* payload2 = new int();
-  *payload2     = id;
+  auto* payload1 = new int(id);
+  auto* payload2 = new int(id);
 
   XBT_INFO("Send %d", id);
   simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload1, 10000);
index 66c250d..6583635 100644 (file)
@@ -32,8 +32,7 @@ static void server()
 
 static void client(int id)
 {
-  int* payload = new int();
-  *payload     = id;
+  auto* payload = new int(id);
   simgrid::s4u::Mailbox::by_name("mymailbox")->put(payload, 10000);
   XBT_INFO("Sent!");
 }
index 7efc445..fb78611 100644 (file)
@@ -18,7 +18,7 @@ static int server(int worker_amount)
   int value_got             = -1;
   simgrid::s4u::Mailbox* mb = simgrid::s4u::Mailbox::by_name("server");
   for (int count = 0; count < worker_amount; count++) {
-    const int* msg = static_cast<int*>(mb->get());
+    const auto* msg = static_cast<int*>(mb->get());
     value_got = *msg;
     delete msg;
   }
index d655c63..3c150a4 100644 (file)
@@ -73,7 +73,7 @@ static void worker(int argc, char* argv[])
 
   XBT_DEBUG("Worker started");
 
-  const double* payload = static_cast<double*>(mbox->get());
+  const auto* payload = static_cast<double*>(mbox->get());
 
   count_finished--;
   if (count_finished == 0) {
index f55e2b0..0d4006e 100644 (file)
@@ -36,7 +36,7 @@ static void master(int argc, char* argv[])
 
   for (int i = 0; i < number_of_tasks; i++) {
     mailbox         = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(i % workers_count));
-    double* payload = new double(comp_size);
+    auto* payload   = new double(comp_size);
     try {
       XBT_INFO("Send a message to %s", mailbox->get_cname());
       mailbox->put(payload, comm_size, 10.0);
@@ -54,7 +54,7 @@ static void master(int argc, char* argv[])
   for (int i = 0; i < workers_count; i++) {
     /* - Eventually tell all the workers to stop by sending a "finalize" task */
     mailbox         = simgrid::s4u::Mailbox::by_name(std::string("worker-") + std::to_string(i));
-    double* payload = new double(-1.0);
+    auto* payload   = new double(-1.0);
     try {
       mailbox->put(payload, 0, 1.0);
     } catch (const simgrid::TimeoutException&) {
@@ -77,7 +77,7 @@ static void worker(int argc, char* argv[])
   while (true) {
     try {
       XBT_INFO("Waiting a message on %s", mailbox->get_cname());
-      const double* payload = static_cast<double*>(mailbox->get());
+      const auto* payload = static_cast<double*>(mailbox->get());
       xbt_assert(payload != nullptr, "mailbox->get() failed");
       double comp_size = *payload;
       delete payload;
index d22c13c..5d3a430 100644 (file)
@@ -53,8 +53,8 @@ public:
 
   static void send(simgrid::xbt::ReplayAction& action)
   {
-    uint64_t size             = static_cast<uint64_t>(std::stod(action[3]));
-    std::string* payload      = new std::string(action[3]);
+    auto size                 = static_cast<uint64_t>(std::stod(action[3]));
+    auto* payload             = new std::string(action[3]);
     double clock              = simgrid::s4u::Engine::get_clock();
     simgrid::s4u::Mailbox* to = simgrid::s4u::Mailbox::by_name(simgrid::s4u::this_actor::get_name() + "_" + action[2]);
     ACT_DEBUG("Entering Send: %s (size: %" PRIu64 ") -- Actor %s on mailbox %s", NAME.c_str(), size,
index 509995c..6f6ae9d 100644 (file)
@@ -57,7 +57,7 @@ public:
     std::string full_name = simgrid::s4u::this_actor::get_name() + ":" + file_name;
 
     ACT_DEBUG("Entering Open: %s (filename: %s)", NAME.c_str(), file_name.c_str());
-    simgrid::s4u::File* file = new simgrid::s4u::File(file_name, NULL);
+    auto* file = new simgrid::s4u::File(file_name, NULL);
 
     opened_files.insert({full_name, file});
 
index 3921539..ed5a2b8 100644 (file)
@@ -42,7 +42,7 @@ static void consumer()
 
 int main(int argc, char **argv)
 {
-  std::vector<std::string> args = std::vector<std::string>({"one", "two", "three", ""});
+  std::vector<std::string> args({"one", "two", "three", ""});
   simgrid::s4u::Engine e(&argc, argv);
   e.load_platform("../../platforms/two_hosts.xml");
   simgrid::s4u::Actor::create("producer", simgrid::s4u::Host::by_name("Tremblay"), producer, &args);
index 191b857..2e769f6 100644 (file)
@@ -79,8 +79,7 @@ static int sleeper_process(const int* param)
 static void pop_some_processes(int nb_processes, simgrid::s4u::Host* host)
 {
   for (int i = 0; i < nb_processes; ++i) {
-    int* param = new int;
-    *param     = i + 1;
+    auto* param = new int(i + 1);
     simgrid::s4u::Actor::create("meh", host, sleeper_process, param);
   }
 }
index 6ed9f33..901e286 100644 (file)
@@ -50,7 +50,7 @@ static void worker(std::vector<std::string> args)
 
   double compute_cost;
   do {
-    const double* msg = static_cast<double*>(mailbox->get());
+    const auto* msg   = static_cast<double*>(mailbox->get());
     compute_cost      = *msg;
     delete msg;