From f39a7fd627847a196ad119db9364936e21e94db9 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Wed, 3 Jul 2019 21:06:54 +0200 Subject: [PATCH] util/macros: rework DIV_ROUND_UP macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Simplify used math. Signed-off-by: Christian Gmeiner Reviewed-by: Marek Olšák Reviewed-by: Kristian H. Kristensen Reviewed-by: Erik Faye-Lund --- src/util/macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/macros.h b/src/util/macros.h index 73d4e68b99a..fb0d154370a 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -268,7 +268,7 @@ do { \ /** Compute ceiling of integer quotient of A divided by B. */ -#define DIV_ROUND_UP( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 ) +#define DIV_ROUND_UP( A, B ) ( ((A) + (B) - 1) / (B) ) /** Clamp X to [MIN,MAX]. Turn NaN into MIN, arbitrarily. */ #define CLAMP( X, MIN, MAX ) ( (X)>(MIN) ? ((X)>(MAX) ? (MAX) : (X)) : (MIN) ) -- 2.30.2