From 26f9f03d20d21d6c939f65cbf404a6e8964320a4 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Wed, 22 May 2019 12:40:26 -0400 Subject: [PATCH] maple_tree: Change erase return to 0 on success. Count isn't used, so return 0 for success. Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 954de5328439..7df531d542b1 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1818,7 +1818,7 @@ static inline int mas_coalesce(struct ma_state *mas) unsigned char pivot_cnt = mt_pivots[type]; if (!pivot_cnt) - return 0; + return ret; for (s_slot = 0; s_slot < slot_cnt; s_slot++) { @@ -1829,7 +1829,7 @@ static inline int mas_coalesce(struct ma_state *mas) d_slot = s_slot; mas_partial_copy(mas, s_slot - 1); if (mas_is_err(mas)) - return 0; + goto mas_error; dst = mas->node; } @@ -1852,10 +1852,16 @@ static inline int mas_coalesce(struct ma_state *mas) } } done: - if (dst) { - ret = s_slot - d_slot; - mt_replace(mas); - } + if (!dst) + return ret; + + ret = s_slot - d_slot; + mt_replace(mas); + +mas_error: // Regardless of allocation, update gaps. + if (mt_is_alloc(mas->tree)) + ma_update_gap(mas); + return ret; } @@ -2448,23 +2454,23 @@ int ma_erase(struct ma_state *mas) unsigned char slot_cnt = mt_slots[type]; unsigned char pivot_cnt = mt_pivots[type]; unsigned long piv_val; - int cnt = -EINVAL; + int ret = -EINVAL; int slot; _mas_walk(mas); slot = ma_get_slot(mas); if (slot == MAPLE_NODE_SLOTS) - return cnt; + return ret; ma_update_rcu_slot(mas->node, slot, NULL); - cnt = 1; + ret = 0; if ((slot >= slot_cnt - 1)) - return cnt; + return ret; if (!pivot_cnt) - return cnt; + return ret; if ((slot < pivot_cnt) && ((ma_get_pivot(mas->node, slot + 1) == 0) || @@ -2475,14 +2481,12 @@ int ma_erase(struct ma_state *mas) } /* Walk down and set all the previous pivots with NULLs to piv_val */ - while(--slot >= 0 && ma_get_rcu_slot(mas->node, slot) == NULL) { + while(--slot >= 0 && ma_get_rcu_slot(mas->node, slot) == NULL) ma_set_pivot(mas->node, slot, piv_val); - cnt++; - } mas_coalesce(mas); /* Error may be returned, but it will be passed through anyways */ - return cnt; + return ret; } void ma_destroy_walk(struct maple_enode *mn) -- 2.50.1