mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: aloktiagi <aloktiagi@gmail.com>
Cc: viro@zeniv.linux.org.uk, brauner@kernel.org,
	David.Laight@aculab.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, keescook@chromium.org,
	hch@infradead.org, Tycho Andersen <tycho@tycho.pizza>
Subject: Re: [RFC v3 2/3] file: allow callers to free the old file descriptor after dup2
Date: Fri, 24 Mar 2023 05:28:06 +0000	[thread overview]
Message-ID: <ZB005rys4ZTeaQfU@casper.infradead.org> (raw)
In-Reply-To: <20230324051526.963702-2-aloktiagi@gmail.com>

On Fri, Mar 24, 2023 at 05:15:25AM +0000, aloktiagi wrote:
> @@ -1119,8 +1119,12 @@ __releases(&files->file_lock)
>  		__clear_close_on_exec(fd, fdt);
>  	spin_unlock(&files->file_lock);
>  
> -	if (tofree)
> -		filp_close(tofree, files);
> +	if (fdfile) {
> +		*fdfile = tofree;
> +	} else {
> +		if (tofree)
> +			filp_close(tofree, files);
> +	}

Why not:

	if (fdfile)
		 *fdfile = tofree;
	else if (tofree)
		filp_close(tofree, files);

Shorter and makes the parallel structure more obvious.


  reply	other threads:[~2023-03-24  5:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-24  5:15 [RFC v3 1/3] file: Introduce iterate_fd_locked aloktiagi
2023-03-24  5:15 ` [RFC v3 2/3] file: allow callers to free the old file descriptor after dup2 aloktiagi
2023-03-24  5:28   ` Matthew Wilcox [this message]
2023-03-24  5:58     ` Alok Tiagi
2023-03-24  5:15 ` [RFC v3 3/3] file, epoll: Implement do_replace() and eventpoll_replace() aloktiagi
2023-03-24  5:24   ` Matthew Wilcox
2023-03-24  5:56     ` Alok Tiagi
2023-03-24  5:20 ` [RFC v3 1/3] file: Introduce iterate_fd_locked Matthew Wilcox
2023-03-24  5:52   ` Alok Tiagi

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=ZB005rys4ZTeaQfU@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=David.Laight@aculab.com \
    --cc=aloktiagi@gmail.com \
    --cc=brauner@kernel.org \
    --cc=hch@infradead.org \
    --cc=keescook@chromium.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tycho@tycho.pizza \
    --cc=viro@zeniv.linux.org.uk \
    /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®