]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: ROUND_UP_TO accepts any rounding factor 2319/head
authorLoic Dachary <loic-201408@dachary.org>
Mon, 25 Aug 2014 15:05:04 +0000 (17:05 +0200)
committerLoic Dachary <loic-201408@dachary.org>
Mon, 25 Aug 2014 19:56:13 +0000 (21:56 +0200)
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 <loic-201408@dachary.org>
src/include/intarith.h

index 640129cea46812777ed0fc5eab973dc0bc5c7484..2c27cecd16dcb5e9513a13bda3fcfed6c3a56915 100644 (file)
@@ -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