]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Make CEIL_DIV() slightly more overflow-safe
authorTaylor Yu <catalyst@torproject.org>
Wed, 5 Apr 2017 18:52:48 +0000 (14:52 -0400)
committerTaylor Yu <catalyst@torproject.org>
Thu, 6 Apr 2017 17:54:46 +0000 (13:54 -0400)
src/common/util.h

index cfe47f07f27bf602401885d85847dc3e3387b1be..18eb57f1bca284bea300ca04971b37d7f62a5fbb 100644 (file)
@@ -163,9 +163,9 @@ int64_t clamp_double_to_int64(double number);
 void simplify_fraction64(uint64_t *numer, uint64_t *denom);
 
 /* Compute the CEIL of <b>a</b> divided by <b>b</b>, for nonnegative <b>a</b>
- * and positive <b>b</b>.  Works on integer types only. Not defined if a+b can
- * overflow. */
-#define CEIL_DIV(a,b) (((a)+(b)-1)/(b))
+ * and positive <b>b</b>.  Works on integer types only. Not defined if a+(b-1)
+ * can overflow. */
+#define CEIL_DIV(a,b) (((a)+((b)-1))/(b))
 
 /* Return <b>v</b> if it's between <b>min</b> and <b>max</b>.  Otherwise
  * return <b>min</b> if <b>v</b> is smaller than <b>min</b>, or <b>max</b> if