From c5adab025852c68bc637c4fbfa34c44cde7397bb Mon Sep 17 00:00:00 2001 From: Taylor Yu Date: Wed, 5 Apr 2017 14:52:48 -0400 Subject: [PATCH] Make CEIL_DIV() slightly more overflow-safe --- src/common/util.h | 6 +++--- 1 file 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 a divided by b, for nonnegative a - * and positive 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. Works on integer types only. Not defined if a+(b-1) + * can overflow. */ +#define CEIL_DIV(a,b) (((a)+((b)-1))/(b)) /* Return v if it's between min and max. Otherwise * return min if v is smaller than min, or max if