Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 10 Jul 2015 15:41:27 +0200
From:      Mateusz Guzik <mjguzik@gmail.com>
To:        Konstantin Belousov <kostikbel@gmail.com>
Cc:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r285356 - in head/sys: compat/cloudabi kern sys
Message-ID:  <20150710134126.GA24433@dft-labs.eu>
In-Reply-To: <20150710111050.GU2080@kib.kiev.ua>
References:  <201507101101.t6AB1VYe002159@repo.freebsd.org> <20150710111050.GU2080@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help
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>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150710134126.GA24433>