aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-26 20:39:59 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-26 20:39:59 +0000
commit4f3250dfb068d6f378f4d504e06a9126d9dac99b (patch)
treea1d2f4d4c57bf51eef3a53eaa33f6776b250a40d
parent65a922f1144a89ad9aa95a29899fc3338ad8a35a (diff)
downloadgnunet-4f3250dfb068d6f378f4d504e06a9126d9dac99b.tar.gz
gnunet-4f3250dfb068d6f378f4d504e06a9126d9dac99b.zip
-avoid overflow in calculation for very large values
-rw-r--r--src/util/bandwidth.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c
index 008963c3c..980af764a 100644
--- a/src/util/bandwidth.c
+++ b/src/util/bandwidth.c
@@ -203,10 +203,9 @@ update_excess (struct GNUNET_BANDWIDTH_Tracker *av)
203 } 203 }
204 else 204 else
205 { 205 {
206 double factor = 1.0 * left_bytes / (double) av->available_bytes_per_s__;
206 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 207 delay = GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS,
207 left_bytes); 208 (unsigned long long) factor);
208 delay = GNUNET_TIME_relative_divide (delay,
209 av->available_bytes_per_s__);
210 } 209 }
211 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
212 "At %llu bps it will take us %s for %lld bytes to reach excess threshold\n", 211 "At %llu bps it will take us %s for %lld bytes to reach excess threshold\n",