mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Li kunyu <kunyu@nfschina.com>
To: linux-kernel@vger.kernel.org
Cc: Li kunyu <kunyu@nfschina.com>
Subject: [PATCH] utsname: Optimize clone_uts_ns()
Date: Mon, 15 Jan 2024 14:11:27 +0800	[thread overview]
Message-ID: <20240115061127.30836-1-kunyu@nfschina.com> (raw)

Optimize the err variable assignment location so that the err variable
is manually modified when an error occurs.

Signed-off-by: Li kunyu <kunyu@nfschina.com>
---
 kernel/utsname.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/kernel/utsname.c b/kernel/utsname.c
index b1ac3ca870f24..f55568e00927c 100644
--- a/kernel/utsname.c
+++ b/kernel/utsname.c
@@ -49,15 +49,17 @@ static struct uts_namespace *clone_uts_ns(struct user_namespace *user_ns,
 	struct ucounts *ucounts;
 	int err;
 
-	err = -ENOSPC;
 	ucounts = inc_uts_namespaces(user_ns);
-	if (!ucounts)
+	if (!ucounts) {
+		err = -ENOSPC;
 		goto fail;
+	}
 
-	err = -ENOMEM;
 	ns = create_uts_ns();
-	if (!ns)
+	if (!ns) {
+		err = -ENOMEM;
 		goto fail_dec;
+	}
 
 	err = ns_alloc_inum(&ns->ns);
 	if (err)
-- 
2.18.2


             reply	other threads:[~2024-01-15  6:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-15  6:11 Li kunyu [this message]
2024-01-15  6:54 ` Al Viro

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=20240115061127.30836-1-kunyu@nfschina.com \
    --to=kunyu@nfschina.com \
    --cc=linux-kernel@vger.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

all inboxes | Powered by JetHome®