public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Taotao Chen <chentaotao@didiglobal.com>
To: <sj@kernel.org>
Cc: <akpm@linux-foundation.org>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] mm/damon/core: simplify control flow in damon_register_ops()
Date: Thu, 20 Mar 2025 18:44:00 +0800	[thread overview]
Message-ID: <Z9vxcPCw8tDsjKw1@OneApple> (raw)

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


             reply	other threads:[~2025-03-20 10:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20 10:44 Taotao Chen [this message]
2025-03-20 17:00 ` [PATCH] mm/damon/core: simplify control flow in damon_register_ops() SeongJae Park

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z9vxcPCw8tDsjKw1@OneApple \
    --to=chentaotao@didiglobal.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox