From 379b23128b670922fe8a6da55e0b46d698d7cdcb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Julius=20B=C3=BCnger?= Date: Mon, 25 Jun 2018 01:03:38 +0200 Subject: [PATCH] rps: fixed bugs reported by coverity --- src/rps/gnunet-rps-profiler.c | 19 ++++++++----------- src/rps/rps-test_util.c | 5 ++++- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rps/gnunet-rps-profiler.c b/src/rps/gnunet-rps-profiler.c index b43ce2fa2..16f23e86c 100644 --- a/src/rps/gnunet-rps-profiler.c +++ b/src/rps/gnunet-rps-profiler.c @@ -1951,9 +1951,13 @@ static void compute_probabilities (uint32_t peer_idx) if ((GNUNET_YES == is_in_view (i, peer_idx)) && (1 <= (0.45 * view_size))) { - prob_push = 1.0 * binom (0.45 * view_size, 1) - / - binom (view_size, 0.45 * view_size); + if (0 == binom (view_size, 0.45 * view_size)) prob_push = 0; + else + { + prob_push = 1.0 * binom (0.45 * view_size, 1) + / + binom (view_size, 0.45 * view_size); + } GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n", peer_idx, @@ -2318,6 +2322,7 @@ post_test_shutdown_ready_cb (void *cls, rps_peer->index); GNUNET_free (stat_cls); GNUNET_break (0); + return; } if (NULL != rps_peer->stat_op && @@ -2494,7 +2499,6 @@ test_run (void *cls, struct OpListEntry *entry; GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); - printf ("test 1\n"); /* Check whether we timed out */ if (n_peers != num_peers || @@ -2578,7 +2582,6 @@ test_run (void *cls, * * @param argc unused * @param argv unused - * @return 0 on success */ static void run (void *cls, @@ -2654,8 +2657,6 @@ run (void *cls, with the malicious portion */ ok = 1; - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "before _run()\n"); GNUNET_TESTBED_run (NULL, cfg, num_peers, @@ -2664,10 +2665,6 @@ run (void *cls, NULL, &test_run, NULL); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "after _run()\n"); - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "gnunet-rps-profiler returned.\n"); } /** diff --git a/src/rps/rps-test_util.c b/src/rps/rps-test_util.c index 9a1dfe0d8..0ee290e67 100644 --- a/src/rps/rps-test_util.c +++ b/src/rps/rps-test_util.c @@ -155,6 +155,9 @@ to_file_raw (const char *file_name, const char *buf, size_t size_buf) return; } + if (GNUNET_YES != GNUNET_DISK_file_close (f)) + LOG (GNUNET_ERROR_TYPE_WARNING, + "Unable to close file\n"); } void @@ -384,7 +387,7 @@ store_prefix_file_name (const struct GNUNET_PeerIdentity *peer, const char *prefix) { unsigned int len_file_name; - unsigned int out_size; + int out_size; char *file_name; const char *pid_long; -- 2.25.1