linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] maple tree: Use goto label to simplify code
@ 2025-06-24  8:07 Dev Jain
  2025-06-24 15:36 ` Liam R. Howlett
  2025-06-25  7:56 ` Wei Yang
  0 siblings, 2 replies; 3+ messages in thread
From: Dev Jain @ 2025-06-24  8:07 UTC (permalink / raw)
  To: akpm, Liam.Howlett
  Cc: richard.weiyang, maple-tree, linux-mm, linux-kernel, Dev Jain

Use the underflow goto label to set the status to ma_underflow and return
NULL, as is being done elsewhere.

Signed-off-by: Dev Jain <dev.jain@arm.com>
---
 lib/maple_tree.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 00524e55a21e..25cf2bc607ca 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -4565,11 +4565,8 @@ static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty)
 		return entry;
 
 	if (!empty) {
-		if (mas->index <= min) {
-			mas->status = ma_underflow;
-			return NULL;
-		}
-
+		if (mas->index <= min)
+			goto underflow;
 		goto again;
 	}
 
-- 
2.30.2



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] maple tree: Use goto label to simplify code
  2025-06-24  8:07 [PATCH] maple tree: Use goto label to simplify code Dev Jain
@ 2025-06-24 15:36 ` Liam R. Howlett
  2025-06-25  7:56 ` Wei Yang
  1 sibling, 0 replies; 3+ messages in thread
From: Liam R. Howlett @ 2025-06-24 15:36 UTC (permalink / raw)
  To: Dev Jain; +Cc: akpm, richard.weiyang, maple-tree, linux-mm, linux-kernel

* Dev Jain <dev.jain@arm.com> [250624 04:08]:
> Use the underflow goto label to set the status to ma_underflow and return
> NULL, as is being done elsewhere.

Thanks for this, but the stacking of labels is unpleasant to read.

A new line like I've added makes it a bit better.  It's more my fault
having the existing code as it is.

> 
> Signed-off-by: Dev Jain <dev.jain@arm.com>
> ---
>  lib/maple_tree.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 00524e55a21e..25cf2bc607ca 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -4565,11 +4565,8 @@ static void *mas_prev_slot(struct ma_state *mas, unsigned long min, bool empty)
>  		return entry;
>  
>  	if (!empty) {
> -		if (mas->index <= min) {
> -			mas->status = ma_underflow;
> -			return NULL;
> -		}
> -
> +		if (mas->index <= min)
> +			goto underflow;

>  		goto again;
>  	}

Andrew, can you just add a new line like I have above?

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

Thanks,
Liam


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] maple tree: Use goto label to simplify code
  2025-06-24  8:07 [PATCH] maple tree: Use goto label to simplify code Dev Jain
  2025-06-24 15:36 ` Liam R. Howlett
@ 2025-06-25  7:56 ` Wei Yang
  1 sibling, 0 replies; 3+ messages in thread
From: Wei Yang @ 2025-06-25  7:56 UTC (permalink / raw)
  To: Dev Jain
  Cc: akpm, Liam.Howlett, richard.weiyang, maple-tree, linux-mm,
	linux-kernel

On Tue, Jun 24, 2025 at 01:37:48PM +0530, Dev Jain wrote:
>Use the underflow goto label to set the status to ma_underflow and return
>NULL, as is being done elsewhere.
>
>Signed-off-by: Dev Jain <dev.jain@arm.com>

LGTM, thanks :-)

Reviewed-by: Wei Yang <richard.weiyang@gmail.com>

-- 
Wei Yang
Help you, Help me


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-25  7:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-24  8:07 [PATCH] maple tree: Use goto label to simplify code Dev Jain
2025-06-24 15:36 ` Liam R. Howlett
2025-06-25  7:56 ` Wei Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).