Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce scope for variables.
[simgrid.git] / examples / c / dht-kademlia / node.c
index da155cc306f10dbffa52b55423df66fea4fefa10..7e2ff568aa2bb6b9c3c972986028f24fd28690d5 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2020. The SimGrid Team. All rights reserved.          */
+/* Copyright (c) 2010-2021. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -81,7 +81,7 @@ unsigned int join(node_t node, unsigned int id_known)
     }
   } while (got_answer == 0);
 
-  /* Second step: Send a FIND_NODE to a random node in buckets */
+  /* Second step: Send a FIND_NODE to a random node in buckets */
   unsigned int bucket_id = routing_table_find_bucket(node->table, id_known)->id;
   xbt_assert(bucket_id <= IDENTIFIER_SIZE);
   for (i = 0; ((bucket_id > i) || (bucket_id + i) <= IDENTIFIER_SIZE) && i < JOIN_BUCKETS_QUERIES; i++) {
@@ -203,7 +203,6 @@ answer_t find_closest(const_node_t node, unsigned int destination_id)
 
 unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_in_stats)
 {
-  unsigned int i = 0;
   unsigned int queries;
   unsigned int answers;
   unsigned int destination_found = 0;
@@ -240,6 +239,7 @@ unsigned int find_node(node_t node, unsigned int id_to_find, unsigned int count_
           // Handle the answer
           routing_table_update(node, msg->sender_id);
           node_contact_t contact;
+          unsigned int i;
           xbt_dynar_foreach (node_list->nodes, i, contact)
             routing_table_update(node, contact->id);