svn commit: r285356 - in head/sys: compat/cloudabi kern sys

Mateusz Guzik mjguzik at gmail.com
Fri Jul 10 13:41:32 UTC 2015


On Fri, Jul 10, 2015 at 02:10:50PM +0300, Konstantin Belousov wrote:
> On Fri, Jul 10, 2015 at 11:01:31AM +0000, Mateusz Guzik wrote:
> > Author: mjg
> > Date: Fri Jul 10 11:01:30 2015
> > New Revision: 285356
> > URL: https://svnweb.freebsd.org/changeset/base/285356
> > 
> > Log:
> >   fd: split kern_dup flags argument into actual flags and a mode
> >   
> >   Tidy up the code inside to switch on the mode.
> 
> > +       MPASS(mode < FDDUP_LASTMODE);
> Since you started the FDDUP_ modes enum from 1, this assert does not fully
> validate the mode.  Am I wrong ?
> 

Oops, correct. There is no problem starting with 0, so I'll just change
the enum. Thanks.

> > +/* Operation types for kern_dup(). */
> > +enum {
> > +	FDDUP_NORMAL = 0x01,	/* dup() behavior. */
> > +	FDDUP_FCNTL,		/* fcntl()-style errors. */
> > +	FDDUP_FIXED,		/* Force fixed allocation. */
> > +	FDDUP_MUSTREPLACE,	/* Target must exist. */
> > +	FDDUP_LASTMODE,
> > +};
> > +
> >  /* Flags for kern_dup(). */
> > -#define	FDDUP_FIXED		0x1	/* Force fixed allocation. */
> > -#define	FDDUP_FCNTL		0x2	/* fcntl()-style errors. */
> > -#define	FDDUP_CLOEXEC		0x4	/* Atomically set FD_CLOEXEC. */
> > -#define	FDDUP_MUSTREPLACE	0x8	/* Target must exist. */
> > +#define	FDDUP_CLOEXEC		0x1	/* Atomically set FD_CLOEXEC. */
> 
> Consider using different prefixes for mode/flags ?

I only came up with FDDUP_FLAG_CLOEXEC which is quite verbose, but may
be acceptable. I definitely want to avoid re-using O_CLOEXEC.

-- 
Mateusz Guzik <mjguzik gmail.com>


More information about the svn-src-all mailing list