Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[sonar] Constify pointer and reference local variables in examples/.
[simgrid.git] / examples / s4u / dht-kademlia / node.cpp
index 7956ded..961e8b9 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)
 {
-  Message* msg = static_cast<Message*>(message);
+  const Message* msg = static_cast<Message*>(message);
   delete msg->answer_;
   delete msg;
 }
@@ -22,7 +22,7 @@ static void destroy(void* message)
   */
 bool Node::join(unsigned int known_id)
 {
-  Answer* node_list;
+  const Answer* node_list;
   unsigned int i;
   bool got_answer = false;
 
@@ -33,7 +33,7 @@ bool Node::join(unsigned int known_id)
   /* First step: Send a "FIND_NODE" request to the node we know */
   sendFindNode(known_id, id_);
 
-  simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
+  simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
   do {
     if (receive_comm == nullptr)
       receive_comm = mailbox->get_async(&received_msg);
@@ -79,7 +79,7 @@ bool Node::join(unsigned int known_id)
 void Node::sendFindNode(unsigned int id, unsigned int destination)
 {
   /* Gets the mailbox to send to */
-  simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id));
+  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());
@@ -200,7 +200,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
     steps++;
     double time_beginreceive = simgrid::s4u::Engine::get_clock();
 
-    simgrid::s4u::MailboxPtr mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
+    simgrid::s4u::Mailbox* mailbox = simgrid::s4u::Mailbox::by_name(std::to_string(id_));
     do {
       if (receive_comm == nullptr)
         receive_comm = mailbox->get_async(&received_msg);
@@ -262,7 +262,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
 void Node::randomLookup()
 {
   unsigned int id_to_look = RANDOM_LOOKUP_NODE; // Totally random.
-  /* TODO: Use some pseudo-random generator like RngStream. */
+  /* TODO: Use some pseudo-random generator. */
   XBT_DEBUG("I'm doing a random lookup");
   findNode(id_to_look, true);
 }