Re: [PATCH] Rename get_unused_fd_flags to get_unused_fd

From: Carlos Llamas
Date: Sun May 18 2025 - 16:43:52 EST


On Thu, May 15, 2025 at 05:09:45PM +0000, Anish Moorthy wrote:
> The current name can be misread as having something to do with unused
> *flags*. And without a get_unused_fd() function already floating around,
> it's easy to resolve this by dropping the suffix.

I don't understand the "unused flags" argument. Did you interpret the
current naming as "get the flags not used by a certain fd"?

Note there _used_ to be a get_unused_fd() that would take no arguments
and thus the naming behind this _flags() version (just FYI).

> I'm not sure if there's any appetite for refactors like this: they're tedious
> for sure. I couldn't find any discouragement in the docs though, so I figured
> I'd just post the patch and let it find me.

If it helps, this kind of patches are usually tagged as "treewide:" and
are often implemented using coccinelle scripts.

Also, for this patch in particular I would:
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Christian Brauner <brauner@xxxxxxxxxx>

> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index 76052006bd87..e162d92e8c1d 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -4618,7 +4618,7 @@ static int binder_apply_fd_fixups(struct binder_proc *proc,
> int ret = 0;
>
> list_for_each_entry(fixup, &t->fd_fixups, fixup_entry) {
> - int fd = get_unused_fd_flags(O_CLOEXEC);
> + int fd = get_unused_fd(O_CLOEXEC);
>
> if (fd < 0) {
> binder_debug(BINDER_DEBUG_TRANSACTION,

This is the only reason I found this patch (binder), and fwiw the
renaming looks OK to me.

Cheers,
Carlos Llamas