From d4990c9d98bb16fa8b2f2d9cd6108afc9f86f7a1 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Wed, 15 Feb 2017 21:46:26 +0100 Subject: [PATCH] crush: allow uniform buckets with no items When a uniform bucket is created with zero size, it returns on error because crush_multiplication_is_unsafe returns false. Since the goal of this safegard is to avoid overflow, it should not fail. Signed-off-by: Loic Dachary --- src/crush/builder.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/crush/builder.c b/src/crush/builder.c index 71a6264e76a9..364db9256c07 100644 --- a/src/crush/builder.c +++ b/src/crush/builder.c @@ -1416,6 +1416,8 @@ int crush_addition_is_unsafe(__u32 a, __u32 b) int crush_multiplication_is_unsafe(__u32 a, __u32 b) { /* prevent division by zero */ + if (!a) + return 0; if (!b) return 1; if ((((__u32)(-1)) / b) < a) -- 2.47.3