public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/damon/core: simplify control flow in damon_register_ops()
@ 2025-03-20 10:44 Taotao Chen
  2025-03-20 17:00 ` SeongJae Park
  0 siblings, 1 reply; 2+ messages in thread
From: Taotao Chen @ 2025-03-20 10:44 UTC (permalink / raw)
  To: sj; +Cc: akpm, linux-kernel

The function logic is not complex, so using goto is unnecessary.
Replace it with a straightforward if-else to simplify control flow
and improve readability.

Signed-off-by: Taotao Chen <chentaotao@didiglobal.com>
---
 mm/damon/core.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/mm/damon/core.c b/mm/damon/core.c
index 384935ef4e65..a3bdc09d38fe 100644
--- a/mm/damon/core.c
+++ b/mm/damon/core.c
@@ -76,14 +76,13 @@ int damon_register_ops(struct damon_operations *ops)
 
 	if (ops->id >= NR_DAMON_OPS)
 		return -EINVAL;
+
 	mutex_lock(&damon_ops_lock);
 	/* Fail for already registered ops */
-	if (__damon_is_registered_ops(ops->id)) {
+	if (__damon_is_registered_ops(ops->id))
 		err = -EINVAL;
-		goto out;
-	}
-	damon_registered_ops[ops->id] = *ops;
-out:
+	else
+		damon_registered_ops[ops->id] = *ops;
 	mutex_unlock(&damon_ops_lock);
 	return err;
 }
-- 
2.34.1


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

* Re: [PATCH] mm/damon/core: simplify control flow in damon_register_ops()
  2025-03-20 10:44 [PATCH] mm/damon/core: simplify control flow in damon_register_ops() Taotao Chen
@ 2025-03-20 17:00 ` SeongJae Park
  0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2025-03-20 17:00 UTC (permalink / raw)
  To: Taotao Chen; +Cc: SeongJae Park, akpm, linux-kernel, damon, linux-mm

+ damon@ and linux-mm@ mailing lists.

Hello Taotao,

On Thu, 20 Mar 2025 18:44:00 +0800 Taotao Chen <chentaotao@didiglobal.com> wrote:

> The function logic is not complex, so using goto is unnecessary.
> Replace it with a straightforward if-else to simplify control flow
> and improve readability.

Good catch and nice cleanup, thank you!
> 
> Signed-off-by: Taotao Chen <chentaotao@didiglobal.com>

Reviewed-by: SeongJae Park <sj@kernel.org>


Thanks,
SJ

[...]

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

end of thread, other threads:[~2025-03-20 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-20 10:44 [PATCH] mm/damon/core: simplify control flow in damon_register_ops() Taotao Chen
2025-03-20 17:00 ` SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox