From 5e8fa3e06b68fae1582c9230a3a8d1abc6146286 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 21 Jul 2017 15:18:10 -0400 Subject: [PATCH] crush: assume weight_set != null imples weight_set_size > 0 Signed-off-by: Sage Weil --- src/crush/CrushWrapper.h | 1 + src/crush/mapper.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crush/CrushWrapper.h b/src/crush/CrushWrapper.h index 251357335fb1..ec6a9ea85816 100644 --- a/src/crush/CrushWrapper.h +++ b/src/crush/CrushWrapper.h @@ -1329,6 +1329,7 @@ public: void create_choose_args(int id, int positions) { if (choose_args.count(id)) return; + assert(positions); auto &cmap = choose_args[id]; cmap.args = (crush_choose_arg*)calloc(sizeof(crush_choose_arg), crush->max_buckets); diff --git a/src/crush/mapper.c b/src/crush/mapper.c index 8ea91897dfa4..e15039ed944b 100644 --- a/src/crush/mapper.c +++ b/src/crush/mapper.c @@ -304,8 +304,7 @@ static inline __u32 *get_choose_arg_weights(const struct crush_bucket_straw2 *bu int position) { if ((arg == NULL) || - (arg->weight_set == NULL) || - (arg->weight_set_size == 0)) + (arg->weight_set == NULL)) return bucket->item_weights; if (position >= arg->weight_set_size) position = arg->weight_set_size - 1; -- 2.47.3