From 6eee2292a93a965a0cff85bf0ff9ea38a3f9abbe Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 28 Nov 2019 13:27:53 -0500 Subject: [PATCH] maple_tree: Fix compile warnings during kernel build Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index b2f846e9f440..d8188f870bf2 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -818,13 +818,14 @@ static inline unsigned long mas_get_prev_pivot(const struct ma_state *mas, { unsigned char p_slot = MAPLE_NODE_SLOTS; // parent slot. + MA_STATE(prev_piv, mas->tree, 0, 0); + if (slot > 0) return mas_get_safe_pivot(mas, slot - 1); if (mas->min == 0) return 0; - MA_STATE(prev_piv, mas->tree, 0, 0); prev_piv.node = mas->node; prev_piv.min = mas->min; @@ -1274,9 +1275,10 @@ static inline unsigned long mas_leaf_max_gap(struct ma_state *mas) unsigned long max_gap = 0; unsigned long gap = 0; unsigned long pstart, pend; + int i; if (ma_is_dense(mt)) { - for (int i = 0; i < mt_slot_count(mas->node); i++) { + for (i = 0; i < mt_slot_count(mas->node); i++) { if (!mt_is_empty(mte_get_rcu_slot(mas->node, i))) { if (gap > max_gap) max_gap = gap; @@ -1291,7 +1293,7 @@ static inline unsigned long mas_leaf_max_gap(struct ma_state *mas) } pstart = mas->min; - for (int i = 0; i < mt_slots[mt]; i++) { + for (i = 0; i < mt_slots[mt]; i++) { pend = mas_get_safe_pivot(mas, i); gap = pend - pstart + 1; @@ -1764,10 +1766,11 @@ static inline int mas_split(struct ma_state *mas, unsigned char slot, if (!mte_is_root(full)) { unsigned long c_max = mas->max; - mas->max = p_max; // Copy the parent data except p_slot, which will later be // replaced. MA_CP(cp, old_parent, new_parent, 0, p_slot - 1); + + mas->max = p_max; if (p_slot) mas_copy(mas, &cp); @@ -2152,6 +2155,7 @@ static inline int _mas_add(struct ma_state *mas, void *entry, bool overwrite, /* Skip possible duplicate entry that contains a NULL */ if (!append) { + MA_CP(cp, prev_enode, mas->node, old_end, slot_cnt - 1); if (mas->last >= last_piv) goto complete; @@ -2166,9 +2170,9 @@ static inline int _mas_add(struct ma_state *mas, void *entry, bool overwrite, } /* Copy remainder of node if this isn't an append */ - MA_CP(cp, prev_enode, mas->node, old_end, slot_cnt - 1); cp.dst_start = slot; cp.dst_end = mt_slot_count(cp.dst) - 1; + cp.src_start = old_end; cp.start_piv = mas->last; cp.src_end = mt_slot_count(cp.src) - 1; // copy to the end to collapse last slot null. mas_copy(mas, &cp); @@ -2887,6 +2891,8 @@ static inline int mas_rebalance(struct ma_state *mas, unsigned char end, enum maple_type new_type; bool p_coalesce = false; // coalesce parent. + MA_CP(cp, this_enode, NULL, 0, end); + if (coalesce) coalesce--; @@ -2969,7 +2975,6 @@ static inline int mas_rebalance(struct ma_state *mas, unsigned char end, mas->max = this_max; mas->min = this_min; // Coalesce this_enode into a new node. - MA_CP(cp, mas->node, NULL, 0, end); cp.dst_end = l_slot_cnt - trimmed; mas_copy(mas, &cp); // cp.dst now has coalesced this_enode. @@ -3756,6 +3761,11 @@ static inline int mas_replace_tree(struct ma_state *mas, void *new_entry) struct maple_enode *r_node = NULL, *last = NULL; unsigned char r_slot = 0, slot; + // Create a new tree. + DEFINE_MTREE(new_tree); + MA_STATE(new_mas, &new_tree, 0, 0); + + MA_STATE(r_mas, mas->tree, mas->last + 1, mas->last + 1); slot_cnt = 1 + mas_get_slot(mas); mas_set_slot(mas, mte_parent_slot(mas->node)); @@ -3807,11 +3817,6 @@ static inline int mas_replace_tree(struct ma_state *mas, void *new_entry) if (mas_is_err(mas)) return 0; - // Create a new tree. - DEFINE_MTREE(new_tree); - - MA_STATE(new_mas, &new_tree, 0, 0); - new_mas.alloc = mas->alloc; mas->alloc = NULL; @@ -4464,6 +4469,7 @@ int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, unsigned long max, gfp_t gfp) { int ret = 0; + MA_STATE(mas, mt, min, max - size); if (!mt_is_alloc(mt)) return -EINVAL; @@ -4480,8 +4486,6 @@ int mtree_alloc_range(struct maple_tree *mt, unsigned long *startp, if (!size) return -EINVAL; - MA_STATE(mas, mt, min, max - size); - mtree_lock(mas.tree); retry: mas.index = min; @@ -4498,6 +4502,7 @@ int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, unsigned long max, gfp_t gfp) { int ret = 0; + MA_STATE(mas, mt, min, max - size); if (!mt_is_alloc(mt)) return -EINVAL; @@ -4514,8 +4519,6 @@ int mtree_alloc_rrange(struct maple_tree *mt, unsigned long *startp, if (!size) return -EINVAL; - MA_STATE(mas, mt, min, max - size); - mtree_lock(mas.tree); retry: mas.index = min; -- 2.50.1