Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
please sonar with a few const
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Wed, 18 Mar 2020 15:04:08 +0000 (16:04 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 19 Mar 2020 10:55:40 +0000 (11:55 +0100)
examples/c/dht-kademlia/message.h
examples/c/dht-kademlia/node.c
examples/c/dht-kademlia/node.h

index cf20f26..a55d5ef 100644 (file)
@@ -20,6 +20,7 @@ typedef struct s_kademlia_message {
 } s_kademlia_message_t;
 
 typedef s_kademlia_message_t* kademlia_message_t;
+const typedef s_kademlia_message_t* const_kademlia_message_t;
 
 // Task handling functions
 kademlia_message_t task_new_find_node(unsigned int sender_id, unsigned int destination_id, sg_mailbox_t mailbox,
index cf7dec0..3b4dec9 100644 (file)
@@ -102,7 +102,7 @@ unsigned int join(node_t node, unsigned int id_known)
  * @param id node we are querying
  * @param destination node we are trying to find.
  */
-void send_find_node(node_t node, unsigned int id, unsigned int destination)
+void send_find_node(const_node_t node, unsigned int id, unsigned int destination)
 {
   /* Gets the mailbox to send to */
   sg_mailbox_t mailbox = get_node_mailbox(id);
@@ -298,7 +298,7 @@ void random_lookup(node_t node)
 }
 
 /** @brief Handles the answer to an incoming "find_node" message */
-void handle_find_node(node_t node, kademlia_message_t msg)
+void handle_find_node(const_node_t node, const_kademlia_message_t msg)
 {
   routing_table_update(node, msg->sender_id);
   XBT_VERB("Received a FIND_NODE from %s (%s), he's trying to find %08x", sg_mailbox_get_name(msg->answer_to),
index e269cbe..f87c7ad 100644 (file)
@@ -64,9 +64,9 @@ unsigned int join(node_t node, unsigned int id_known);
 unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_in_stats);
 void random_lookup(node_t node);
 
-void send_find_node(node_t node, unsigned int id, unsigned int destination);
+void send_find_node(const_node_t node, unsigned int id, unsigned int destination);
 unsigned int send_find_node_to_best(node_t node, const_answer_t node_list);
 
-void handle_find_node(node_t node, kademlia_message_t data);
+void handle_find_node(const_node_t node, const_kademlia_message_t data);
 
 #endif