From: Andrew Morton <akpm@linux-foundation.org>
To: Ye Liu <ye.liu@linux.dev>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Ye Liu <liuye@kylinos.cn>
Subject: Re: [PATCH] mm/memfd: Rename error labels for clarity
Date: Mon, 9 Jun 2025 17:26:54 -0700 [thread overview]
Message-ID: <20250609172654.a99c06d8ad90a6a994545e5f@linux-foundation.org> (raw)
In-Reply-To: <20250609031858.73415-1-ye.liu@linux.dev>
On Mon, 9 Jun 2025 11:18:58 +0800 Ye Liu <ye.liu@linux.dev> wrote:
> From: Ye Liu <liuye@kylinos.cn>
>
> err_name --> err_fd (fd failure case)
> err_fd --> err_file (file failure case)
>
> ...
>
> --- a/mm/memfd.c
> +++ b/mm/memfd.c
> @@ -475,22 +475,22 @@ SYSCALL_DEFINE2(memfd_create,
> fd = get_unused_fd_flags((flags & MFD_CLOEXEC) ? O_CLOEXEC : 0);
> if (fd < 0) {
> error = fd;
> - goto err_name;
> + goto err_fd;
> }
>
> file = alloc_file(name, flags);
> if (IS_ERR(file)) {
> error = PTR_ERR(file);
> - goto err_fd;
> + goto err_file;
> }
>
> fd_install(fd, file);
> kfree(name);
> return fd;
>
> -err_fd:
> +err_file:
> put_unused_fd(fd);
> -err_name:
> +err_fd:
> kfree(name);
> return error;
> }
Not really, but I see what you mean.
"err_name" means "there was an error, so free the name".
"err_fd" means "there was a problem with the fd".
We tend to use the former convention. See
grep err_free mm/*.c
The memfd_create() code would be better if it used "err_free_name" and
"err_free_fd" to remove this ambiguity.
Someone who was feeling bored could go through
grep "goto err_" mm/*.c
and check that we use this convention uniformly ;)
next prev parent reply other threads:[~2025-06-10 0:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-09 3:18 Ye Liu
2025-06-10 0:26 ` Andrew Morton [this message]
2025-06-10 1:51 ` Ye Liu
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=20250609172654.a99c06d8ad90a6a994545e5f@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liuye@kylinos.cn \
--cc=ye.liu@linux.dev \
/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