From 87cd3a8f6e190aed06e361595afc4ec83148da98 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Mon, 25 Aug 2014 17:05:04 +0200 Subject: [PATCH] common: ROUND_UP_TO accepts any rounding factor The ROUND_UP_TO function was limited to rounding factors that are powers of two. This saves a modulo but it is not used where it would make a difference. The implementation is changed so it is generic. http://tracker.ceph.com/issues/9209 Fixes: #9209 Signed-off-by: Loic Dachary (cherry picked from commit 9449520b121fc6ce0c64948386d4ff77f46f4f5f) --- src/include/intarith.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/intarith.h b/src/include/intarith.h index 640129cea4681..2c27cecd16dcb 100644 --- a/src/include/intarith.h +++ b/src/include/intarith.h @@ -28,7 +28,7 @@ #endif #ifndef ROUND_UP_TO -# define ROUND_UP_TO(n, d) (((n)+(d)-1) & ~((d)-1)) +# define ROUND_UP_TO(n, d) ((n)%(d) ? ((n)+(d)-(n)%(d)) : (n)) #endif #ifndef SHIFT_ROUND_UP -- 2.39.5