projects
/
oweals
/
gnunet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4309ab2
)
rps profiler: prevent division by zero
author
Julius Bünger
<buenger@mytum.de>
Sun, 8 Apr 2018 21:55:45 +0000
(23:55 +0200)
committer
Julius Bünger
<buenger@mytum.de>
Sun, 8 Apr 2018 21:55:45 +0000
(23:55 +0200)
src/rps/test_rps.c
patch
|
blob
|
history
diff --git
a/src/rps/test_rps.c
b/src/rps/test_rps.c
index 4c10133d23490a073a33231256c3c72670d13859..00835794b29ab77db4097c8a6fc10ce8465f5f7a 100644
(file)
--- a/
src/rps/test_rps.c
+++ b/
src/rps/test_rps.c
@@
-1994,9
+1994,17
@@
static void compute_probabilities (uint32_t peer_idx)
if (0 != probs[i]) count_non_zero_prob++;
}
/* normalize */
-
for (i = 0; i < num_peers; i++
)
+
if (0 != count_non_zero_prob
)
{
- probs[i] = probs[i] * (1.0 / count_non_zero_prob);
+ for (i = 0; i < num_peers; i++)
+ {
+ probs[i] = probs[i] * (1.0 / count_non_zero_prob);
+ }
+ } else {
+ for (i = 0; i < num_peers; i++)
+ {
+ probs[i] = 0;
+ }
}
/* str repr */
for (i = 0; i < num_peers; i++)