From: Sage Weil Date: Fri, 21 Jul 2017 19:18:10 +0000 (-0400) Subject: crush: assume weight_set != null imples weight_set_size > 0 X-Git-Tag: v12.1.2~150^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5e8fa3e06b68fae1582c9230a3a8d1abc6146286;p=ceph.git crush: assume weight_set != null imples weight_set_size > 0 Signed-off-by: Sage Weil --- 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;