summaryrefslogtreecommitdiff
path: root/src/common/util.h
diff options
context:
space:
mode:
authorTaylor Yu <catalyst@torproject.org>2017-04-05 14:52:48 -0400
committerTaylor Yu <catalyst@torproject.org>2017-04-06 13:54:46 -0400
commitc5adab025852c68bc637c4fbfa34c44cde7397bb (patch)
tree7aa686bc3652cf757c282eb71f701271a97f02fd /src/common/util.h
parent489ef6b38ba66f59bb6562a4702c0500478a7495 (diff)
downloadtor-c5adab025852c68bc637c4fbfa34c44cde7397bb.tar.gz
tor-c5adab025852c68bc637c4fbfa34c44cde7397bb.zip
Make CEIL_DIV() slightly more overflow-safe
Diffstat (limited to 'src/common/util.h')
-rw-r--r--src/common/util.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/common/util.h b/src/common/util.h
index cfe47f07f2..18eb57f1bc 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -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