From: Nathan S. Evans Date: Wed, 1 Sep 2010 13:21:45 +0000 (+0000) Subject: klocwork fixes X-Git-Tag: initial-import-from-subversion-38251~20485 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c09f6eb6d32f57778cf8f8baf0456cbe7158eb79;p=oweals%2Fgnunet.git klocwork fixes --- diff --git a/src/dv/gnunet-service-dv.c b/src/dv/gnunet-service-dv.c index 233ea74a5..cd3a531b7 100644 --- a/src/dv/gnunet-service-dv.c +++ b/src/dv/gnunet-service-dv.c @@ -647,6 +647,11 @@ static struct GNUNET_CONTAINER_Heap *neighbor_min_heap; */ static struct GNUNET_CONTAINER_Heap *neighbor_max_heap; +/** + * Handle for the statistics service. + */ +struct GNUNET_STATISTICS_Handle *stats; + /** * How far out to keep peers we learn about. */ @@ -2803,12 +2808,19 @@ process_peerinfo (void *cls, } sent = GNUNET_CONTAINER_multihashmap_iterate (extended_neighbors, &add_all_extended_peers, neighbor->send_context); - + if (stats != NULL) + { + GNUNET_STATISTICS_update (stats, "# distant peers gossiped to direct neighbors", sent, GNUNET_NO); + } #if DEBUG_DV_PEER_NUMBERS neighbor_pid = GNUNET_strdup(GNUNET_i2s(&neighbor->identity)); GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped %d extended peers to %s\n", GNUNET_i2s(&my_identity), sent, neighbor_pid); #endif sent = GNUNET_CONTAINER_multihashmap_iterate (direct_neighbors, &add_all_direct_neighbors, neighbor); + if (stats != NULL) + { + GNUNET_STATISTICS_update (stats, "# direct peers gossiped to direct neighbors", sent, GNUNET_NO); + } #if DEBUG_DV_PEER_NUMBERS GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "%s: Gossipped about %s to %d direct peers\n", GNUNET_i2s(&my_identity), neighbor_pid, sent); GNUNET_free(neighbor_pid); @@ -2875,7 +2887,13 @@ void handle_core_connect (void *cls, { about = GNUNET_CONTAINER_multihashmap_get(extended_neighbors, &peer->hashPubKey); if ((GNUNET_CONTAINER_multihashmap_get(direct_neighbors, &peer->hashPubKey) == NULL) && (about != NULL)) - sent = GNUNET_CONTAINER_multihashmap_iterate(direct_neighbors, &add_distant_all_direct_neighbors, about); + { + sent = GNUNET_CONTAINER_multihashmap_iterate(direct_neighbors, &add_distant_all_direct_neighbors, about); + if (stats != NULL) + { + GNUNET_STATISTICS_update (stats, "# direct peers gossiped to new direct neighbors", sent, GNUNET_NO); + } + } #if DEBUG_DV GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "%s: Distance (%d) greater than %d or already know about peer (%s), not re-adding!\n", "dv", distance, DIRECT_NEIGHBOR_COST, GNUNET_i2s(peer)); diff --git a/src/dv/test_transport_api_dv.c b/src/dv/test_transport_api_dv.c index 3e66388fe..244966300 100644 --- a/src/dv/test_transport_api_dv.c +++ b/src/dv/test_transport_api_dv.c @@ -198,7 +198,6 @@ finish_testing () struct PeerContext *free_peer_pos; struct TestMessageContext *pos; struct TestMessageContext *free_pos; - int count; #if VERBOSE GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, @@ -215,7 +214,6 @@ finish_testing () } all_peers = NULL; - count = 0; pos = test_messages; while (pos != NULL) { @@ -834,6 +832,7 @@ static void all_connect_handler (void *cls, if (second_daemon == NULL) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Couldn't find second peer!\n"); + GNUNET_free(second_shortname); return; } #if !TEST_ALL @@ -1059,6 +1058,7 @@ run (void *cls, main_cfg = cfg; + GNUNET_assert(num_peers > 0 && num_peers < (unsigned int)-1); peers_left = num_peers; /* Set up a task to end testing if peer start fails */