lkml.org 
[lkml]   [2023]   [Mar]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [RFC 2/3] file: allow callers to free the old file descriptor after dup2
Date
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)

\
 
 \ /
  Last update: 2023-03-27 00:42    [W:0.077 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site