From: David Laight <David.Laight@ACULAB.COM>
To: 'aloktiagi' <aloktiagi@gmail.com>,
"viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
"linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "keescook@chromium.org" <keescook@chromium.org>,
"hch@infradead.org" <hch@infradead.org>,
Tycho Andersen <tycho@tycho.pizza>
Subject: RE: [RFC 2/3] file: allow callers to free the old file descriptor after dup2
Date: Thu, 2 Mar 2023 22:21:11 +0000 [thread overview]
Message-ID: <bef11c18fa234948bcab0316418f04aa@AcuMS.aculab.com> (raw)
In-Reply-To: <20230302182207.456311-2-aloktiagi@gmail.com>
From: aloktiagi
> Sent: 02 March 2023 18:22
>
> Allow callers of do_dup2 to free the old file descriptor in case they need to
> make additional operations on it.
That doesn't read right at all.
Whether or not this is a good idea (or can be done differently)
the interface is horrid.
> if (tofree)
> - filp_close(tofree, files);
> + *fdfile = tofree;
Why not:
if (fdfile) [
*fdfile = tofree;
} else {
if (tofree)
filp_close(tofree, files);
}
Then existing code just passes NULL and the caller can't 'forget'
to intitalise fdfile.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2023-03-02 22:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-02 18:22 [RFC 1/3] file: Introduce iterate_fd_locked aloktiagi
2023-03-02 18:22 ` [RFC 2/3] file: allow callers to free the old file descriptor after dup2 aloktiagi
2023-03-02 22:21 ` David Laight [this message]
2023-03-07 18:23 ` Alok Tiagi
2023-03-02 18:22 ` [RFC 3/3] file, epoll: Implement do_replace() and eventpoll_replace() aloktiagi
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=bef11c18fa234948bcab0316418f04aa@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=aloktiagi@gmail.com \
--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
Powered by JetHome