gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet] branch master updated: rps profiler: prevent divis


From: gnunet
Subject: [GNUnet-SVN] [gnunet] branch master updated: rps profiler: prevent division by zero
Date: Sun, 08 Apr 2018 23:56:27 +0200

This is an automated email from the git hooks/post-receive script.

julius-buenger pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new ebee6164b rps profiler: prevent division by zero
ebee6164b is described below

commit ebee6164ba4e1d50e66d0e195a33e63abac31faa
Author: Julius Bünger <address@hidden>
AuthorDate: Sun Apr 8 23:55:45 2018 +0200

    rps profiler: prevent division by zero
---
 src/rps/test_rps.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/rps/test_rps.c b/src/rps/test_rps.c
index 4c10133d2..00835794b 100644
--- 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++)

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]