]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Change erase return to 0 on success.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 22 May 2019 16:40:26 +0000 (12:40 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Wed, 31 Jul 2019 14:52:43 +0000 (10:52 -0400)
Count isn't used, so return 0 for success.

Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 954de53284395279962eec648ae16caff3107669..7df531d542b1f710cc142ad0ff4dbc0ea1ce9346 100644 (file)
@@ -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)