X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/417742f1c7f6545db82079acd702fde03547d400..fa4e03e6589cdadc2145fb3483c8517bb0316cee:/examples/msg/dht-kademlia/routing_table.c diff --git a/examples/msg/dht-kademlia/routing_table.c b/examples/msg/dht-kademlia/routing_table.c index 20757af158..f0d6a6e6e5 100644 --- a/examples/msg/dht-kademlia/routing_table.c +++ b/examples/msg/dht-kademlia/routing_table.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2016. The SimGrid Team. +/* Copyright (c) 2012-2017. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it @@ -13,10 +13,9 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(msg_kademlia_routing_table, "Messages specific for /** @brief Initialization of a node routing table. */ routing_table_t routing_table_init(unsigned int node_id) { - unsigned int i; routing_table_t table = xbt_new(s_routing_table_t, 1); table->buckets = xbt_new(s_bucket_t, identifier_size + 1); - for (i = 0; i < identifier_size + 1; i++) { + for (unsigned int i = 0; i < identifier_size + 1; i++) { table->buckets[i].nodes = xbt_dynar_new(sizeof(unsigned int), NULL); table->buckets[i].id = i; } @@ -46,10 +45,11 @@ unsigned int routing_table_contains(routing_table_t table, unsigned int node_id) /**@brief prints the routing table, to debug stuff. */ void routing_table_print(routing_table_t table) { - unsigned int i, j, value; + unsigned int j; + unsigned int value; XBT_INFO("Routing table of %08x:", table->id); - for (i = 0; i <= identifier_size; i++) { + for (unsigned int i = 0; i <= identifier_size; i++) { if (!xbt_dynar_is_empty(table->buckets[i].nodes)) { XBT_INFO("Bucket number %d: ", i); xbt_dynar_foreach(table->buckets[i].nodes, j, value) { @@ -65,7 +65,8 @@ void routing_table_print(routing_table_t table) */ unsigned int bucket_find_id(bucket_t bucket, unsigned int id) { - unsigned int i, current_id; + unsigned int i; + unsigned int current_id; xbt_dynar_foreach(bucket->nodes, i, current_id){ if (id == current_id){ return i; @@ -89,7 +90,7 @@ bucket_t routing_table_find_bucket(routing_table_t table, unsigned int id) { unsigned int xor_number = table->id ^ id; unsigned int prefix = get_node_prefix(xor_number, identifier_size); - xbt_assert(prefix >= 0 && prefix <= identifier_size, "Tried to return a bucket that doesn't exist."); + xbt_assert(prefix <= identifier_size, "Tried to return a bucket that doesn't exist."); bucket_t bucket = &table->buckets[prefix]; return bucket; }