Re: [RFC v3 2/3] file: allow callers to free the old file descriptor after dup2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Mar 24, 2023 at 05:28:06AM +0000, Matthew Wilcox wrote:
> 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.
> 

Agreed. Thank you for suggesting that. I'll fix this in v4.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux