Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Inform scan-build that (bucket_id + i) cannot wrap around.
[simgrid.git] / examples / s4u / dht-kademlia / node.cpp
index 46d7e1d..b5e10fe 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2012-2017. The SimGrid Team.
+/* Copyright (c) 2010, 2012-2018. The SimGrid Team.
  * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
@@ -59,6 +59,7 @@ bool Node::join(unsigned int known_id)
 
   /* Second step: Send a FIND_NODE to a a random node in buckets */
   unsigned int bucket_id = table->findBucket(known_id)->getId();
+  xbt_assert(bucket_id <= identifier_size);
   for (i = 0; ((bucket_id > i) || (bucket_id + i) <= identifier_size) && i < JOIN_BUCKETS_QUERIES; i++) {
     if (bucket_id > i) {
       unsigned int id_in_bucket = get_id_in_prefix(id_, bucket_id - i);
@@ -216,7 +217,7 @@ bool Node::findNode(unsigned int id_to_find, bool count_in_stats)
           answers++;
 
           nodes_added = node_list->merge(msg->answer_);
-          XBT_DEBUG("Received an answer from %s (%s) with %lu nodes on it", msg->answer_to_->getCname(),
+          XBT_DEBUG("Received an answer from %s (%s) with %zu nodes on it", msg->answer_to_->getCname(),
                     msg->issuer_host_name_, msg->answer_->nodes.size());
         } else {
           if (msg->answer_) {