change time multiplication/division API to long long to avoid accidental range reduction
authorChristian Grothoff <christian@grothoff.org>
Tue, 26 Jul 2016 12:27:28 +0000 (12:27 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 26 Jul 2016 12:27:28 +0000 (12:27 +0000)
src/include/gnunet_bandwidth_lib.h
src/include/gnunet_time_lib.h
src/util/bandwidth.c
src/util/time.c

index 7b63de3904326c6507ee8b28b5715b269892679c..178ddaaacaacb0026b61c00aae49b1d10dfc44ae 100644 (file)
@@ -126,7 +126,7 @@ struct GNUNET_BANDWIDTH_Tracker
   struct GNUNET_TIME_Absolute last_update__;
 
   /**
-   * Bandwidth limit to enforce in bytes per s.
+   * Bandwidth limit to enforce in bytes per second.
    */
   uint32_t available_bytes_per_s__;
 
@@ -289,7 +289,7 @@ GNUNET_BANDWIDTH_tracker_consume (struct GNUNET_BANDWIDTH_Tracker *av,
 
 
 /**
- * Compute how long we should wait until consuming 'size'
+ * Compute how long we should wait until consuming @a size
  * bytes of bandwidth in order to stay within the given
  * quota.
  *
index 3dad179b5339058bf543aea898db69418c3752e0..64c5769c62af422dd14f2b40aad98c553bcab4ea 100644 (file)
@@ -417,7 +417,7 @@ GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start,
  */
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
-                               unsigned int factor);
+                               unsigned long long factor);
 
 
 /**
@@ -429,7 +429,7 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
  */
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel,
-                             unsigned int factor);
+                             unsigned long long factor);
 
 
 /**
index 61677fdcf282d9791fa0dd7e040c37b925ca9283..008963c3c0d52c8677506ee4e7ec576781b6d9ec 100644 (file)
@@ -147,7 +147,11 @@ excess_trigger (void *cls)
 
   av->excess_task = NULL;
   if (NULL != av->excess_cb)
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+               "Notifying application about excess bandwidth\n");
     av->excess_cb (av->excess_cb_cls);
+  }
 }
 
 
index 91bbbf72ac93f9fb68e00de8f892d1fb787fc478..eb168d531120a3f1266957e30de06a55be748ee8 100644 (file)
@@ -427,7 +427,7 @@ GNUNET_TIME_absolute_subtract (struct GNUNET_TIME_Absolute start,
  */
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
-                               unsigned int factor)
+                               unsigned long long factor)
 {
   struct GNUNET_TIME_Relative ret;
 
@@ -435,7 +435,7 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
     return GNUNET_TIME_UNIT_ZERO;
   if (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us)
     return GNUNET_TIME_UNIT_FOREVER_REL;
-  ret.rel_value_us = rel.rel_value_us * (unsigned long long) factor;
+  ret.rel_value_us = rel.rel_value_us * factor;
   if (ret.rel_value_us / factor != rel.rel_value_us)
   {
     GNUNET_break (0);
@@ -454,14 +454,14 @@ GNUNET_TIME_relative_multiply (struct GNUNET_TIME_Relative rel,
  */
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_divide (struct GNUNET_TIME_Relative rel,
-                             unsigned int factor)
+                             unsigned long long factor)
 {
   struct GNUNET_TIME_Relative ret;
 
   if ((0 == factor) ||
       (rel.rel_value_us == GNUNET_TIME_UNIT_FOREVER_REL.rel_value_us))
     return GNUNET_TIME_UNIT_FOREVER_REL;
-  ret.rel_value_us = rel.rel_value_us / (unsigned long long) factor;
+  ret.rel_value_us = rel.rel_value_us / factor;
   return ret;
 }