]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: print empty for an empty tree on mt_dump()
authorWei Yang <richard.weiyang@gmail.com>
Thu, 31 Oct 2024 23:16:23 +0000 (23:16 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 1 Nov 2024 04:29:35 +0000 (21:29 -0700)
Patch series "refine storing null", v5.

When overwriting the whole range with NULL, current behavior is not
correct.

This patch (of 5):

Currently for an empty tree, it would print:

  maple_tree(0x7ffcd02c6ee0) flags 1, height 0 root (nil)
  0: (nil)

This is a little misleading.

Let's print (empty) for an empty tree.

Link: https://lkml.kernel.org/r/20241031231627.14316-1-richard.weiyang@gmail.com
Link: https://lkml.kernel.org/r/20241031231627.14316-2-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Liam R. Howlett <Liam.Howlett@Oracle.com>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/maple_tree.c

index 38aa8abf8eb81c6b537866a1219e7e3bd460f1b9..523355fb2bbe219664ab4e9e1dcb305d325928b6 100644 (file)
@@ -7273,10 +7273,12 @@ void mt_dump(const struct maple_tree *mt, enum mt_dump_format format)
 
        pr_info("maple_tree(" PTR_FMT ") flags %X, height %u root " PTR_FMT "\n",
                 mt, mt->ma_flags, mt_height(mt), entry);
-       if (!xa_is_node(entry))
-               mt_dump_entry(entry, 0, 0, 0, format);
-       else if (entry)
+       if (xa_is_node(entry))
                mt_dump_node(mt, entry, 0, mt_node_max(entry), 0, format);
+       else if (entry)
+               mt_dump_entry(entry, 0, 0, 0, format);
+       else
+               pr_info("(empty)\n");
 }
 EXPORT_SYMBOL_GPL(mt_dump);