diff options
author | Julius Bünger <buenger@mytum.de> | 2018-06-25 01:03:38 +0200 |
---|---|---|
committer | Julius Bünger <buenger@mytum.de> | 2018-06-25 01:04:25 +0200 |
commit | 379b23128b670922fe8a6da55e0b46d698d7cdcb (patch) | |
tree | 1912da9af80cb3a297b631a5593608a0b5ef7e64 | |
parent | dde9853ec747407f6e408d53df8b5e533db82b29 (diff) | |
download | gnunet-379b23128b670922fe8a6da55e0b46d698d7cdcb.tar.gz gnunet-379b23128b670922fe8a6da55e0b46d698d7cdcb.zip |
rps: fixed bugs reported by coverity
-rw-r--r-- | src/rps/gnunet-rps-profiler.c | 19 | ||||
-rw-r--r-- | 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) | |||
1951 | if ((GNUNET_YES == is_in_view (i, peer_idx)) && | 1951 | if ((GNUNET_YES == is_in_view (i, peer_idx)) && |
1952 | (1 <= (0.45 * view_size))) | 1952 | (1 <= (0.45 * view_size))) |
1953 | { | 1953 | { |
1954 | prob_push = 1.0 * binom (0.45 * view_size, 1) | 1954 | if (0 == binom (view_size, 0.45 * view_size)) prob_push = 0; |
1955 | / | 1955 | else |
1956 | binom (view_size, 0.45 * view_size); | 1956 | { |
1957 | prob_push = 1.0 * binom (0.45 * view_size, 1) | ||
1958 | / | ||
1959 | binom (view_size, 0.45 * view_size); | ||
1960 | } | ||
1957 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1961 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1958 | "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n", | 1962 | "\t\t%" PRIu32 " is in %" PRIu32 "'s view, prob: %f\n", |
1959 | peer_idx, | 1963 | peer_idx, |
@@ -2318,6 +2322,7 @@ post_test_shutdown_ready_cb (void *cls, | |||
2318 | rps_peer->index); | 2322 | rps_peer->index); |
2319 | GNUNET_free (stat_cls); | 2323 | GNUNET_free (stat_cls); |
2320 | GNUNET_break (0); | 2324 | GNUNET_break (0); |
2325 | return; | ||
2321 | } | 2326 | } |
2322 | 2327 | ||
2323 | if (NULL != rps_peer->stat_op && | 2328 | if (NULL != rps_peer->stat_op && |
@@ -2494,7 +2499,6 @@ test_run (void *cls, | |||
2494 | struct OpListEntry *entry; | 2499 | struct OpListEntry *entry; |
2495 | 2500 | ||
2496 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); | 2501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "RUN was called\n"); |
2497 | printf ("test 1\n"); | ||
2498 | 2502 | ||
2499 | /* Check whether we timed out */ | 2503 | /* Check whether we timed out */ |
2500 | if (n_peers != num_peers || | 2504 | if (n_peers != num_peers || |
@@ -2578,7 +2582,6 @@ test_run (void *cls, | |||
2578 | * | 2582 | * |
2579 | * @param argc unused | 2583 | * @param argc unused |
2580 | * @param argv unused | 2584 | * @param argv unused |
2581 | * @return 0 on success | ||
2582 | */ | 2585 | */ |
2583 | static void | 2586 | static void |
2584 | run (void *cls, | 2587 | run (void *cls, |
@@ -2654,8 +2657,6 @@ run (void *cls, | |||
2654 | with the malicious portion */ | 2657 | with the malicious portion */ |
2655 | 2658 | ||
2656 | ok = 1; | 2659 | ok = 1; |
2657 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2658 | "before _run()\n"); | ||
2659 | GNUNET_TESTBED_run (NULL, | 2660 | GNUNET_TESTBED_run (NULL, |
2660 | cfg, | 2661 | cfg, |
2661 | num_peers, | 2662 | num_peers, |
@@ -2664,10 +2665,6 @@ run (void *cls, | |||
2664 | NULL, | 2665 | NULL, |
2665 | &test_run, | 2666 | &test_run, |
2666 | NULL); | 2667 | NULL); |
2667 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2668 | "after _run()\n"); | ||
2669 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2670 | "gnunet-rps-profiler returned.\n"); | ||
2671 | } | 2668 | } |
2672 | 2669 | ||
2673 | /** | 2670 | /** |
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) | |||
155 | 155 | ||
156 | return; | 156 | return; |
157 | } | 157 | } |
158 | if (GNUNET_YES != GNUNET_DISK_file_close (f)) | ||
159 | LOG (GNUNET_ERROR_TYPE_WARNING, | ||
160 | "Unable to close file\n"); | ||
158 | } | 161 | } |
159 | 162 | ||
160 | void | 163 | void |
@@ -384,7 +387,7 @@ store_prefix_file_name (const struct GNUNET_PeerIdentity *peer, | |||
384 | const char *prefix) | 387 | const char *prefix) |
385 | { | 388 | { |
386 | unsigned int len_file_name; | 389 | unsigned int len_file_name; |
387 | unsigned int out_size; | 390 | int out_size; |
388 | char *file_name; | 391 | char *file_name; |
389 | const char *pid_long; | 392 | const char *pid_long; |
390 | 393 | ||