]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Clear up index and last setting in single entry tree
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Mon, 3 Apr 2023 15:59:40 +0000 (11:59 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 2 May 2023 17:51:57 +0000 (13:51 -0400)
When there is a single entry tree (range of 0-0 pointing to an entry),
then ensure the limit is either 0-0 or 1-oo, depending on where the user
walks.  Ensure the correct node setting as well; either MAS_ROOT or
MAS_NONE.

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

index dcd41966b3b5ba10e54fd8daea2ff28b38721f21..b317bc105f3936ad701f7022518a88267b49e01d 100644 (file)
@@ -5049,24 +5049,25 @@ void *mas_walk(struct ma_state *mas)
 {
        void *entry;
 
+       if (mas_is_none(mas) || mas_is_paused(mas))
+               mas->node = MAS_START;
 retry:
        entry = mas_state_walk(mas);
-       if (mas_is_start(mas))
+       if (mas_is_start(mas)) {
                goto retry;
-
-       if (mas_is_ptr(mas)) {
+       } else if (mas_is_none(mas)) {
+               mas->index = 0;
+               mas->last = ULONG_MAX;
+       } else if (mas_is_ptr(mas)) {
                if (!mas->index) {
                        mas->last = 0;
-               } else {
-                       mas->index = 1;
-                       mas->last = ULONG_MAX;
+                       return mas_root(mas);
                }
-               return entry;
-       }
 
-       if (mas_is_none(mas)) {
-               mas->index = 0;
+               mas->index = 1;
                mas->last = ULONG_MAX;
+               mas->node = MAS_NONE;
+               return NULL;
        }
 
        return entry;