]> 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>
Mon, 24 Apr 2023 20:20:42 +0000 (16:20 -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 20f0a10dc560861aa6fceba88d8efadfff61ee7f..31cbfd7b447283656f71e53be8468a5e3aede644 100644 (file)
@@ -5099,24 +5099,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;