diff mbox series

[v4,1/5] maple_tree: print empty for an empty tree on mt_dump()

Message ID 20241019023716.4516-2-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series refine storing NULL | expand

Commit Message

Wei Yang Oct. 19, 2024, 2:37 a.m. UTC
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.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
 lib/maple_tree.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Liam R. Howlett Oct. 29, 2024, 3:23 p.m. UTC | #1
* Wei Yang <richard.weiyang@gmail.com> [241018 22:37]:
> 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.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Liam R. Howlett <Liam.Howlett@Oracle.com>
> CC: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> CC: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>

Reviewed-by: Liam R. Howlett <Liam.Howlett@Oracle.com>

> ---
>  lib/maple_tree.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 3619301dda2e..21e6895b7aef 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -7287,10 +7287,12 @@ void mt_dump(const struct maple_tree *mt, enum mt_dump_format format)
>  
>  	pr_info("maple_tree(%p) flags %X, height %u root %p\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);
>  
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 3619301dda2e..21e6895b7aef 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -7287,10 +7287,12 @@  void mt_dump(const struct maple_tree *mt, enum mt_dump_format format)
 
 	pr_info("maple_tree(%p) flags %X, height %u root %p\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);