From owner-svn-src-all@freebsd.org Fri Jul 10 13:41:32 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C8814334C; Fri, 10 Jul 2015 13:41:32 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wg0-x230.google.com (mail-wg0-x230.google.com [IPv6:2a00:1450:400c:c00::230]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 628B41026; Fri, 10 Jul 2015 13:41:32 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by wgjx7 with SMTP id x7so249533594wgj.2; Fri, 10 Jul 2015 06:41:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=vaq7AGmGr62Xhy5/9xM4m3hhqvR4qUMVfYeZMizTzAs=; b=DXl14Ygntmm/iOiQ2/eGo36rCZEoX7AuucBtWbZ7Vzm+fvu08pGgaQArUNOdQQ1ThZ Z9CJxSyYTQxYkmXViKQJYGMUORMiL6KTdyiM+XUJx93g8R+Fp//C6jaOQoIrg+QT6T3Y mxza9p2/FNYdYBRHIdSneHUZrm6AysMaQRvJTty7GE8NYEcHsMZgAF+aJJj/HsJqXVmM ahfEdhzDnHiFtajYAMw9cZii3cT39uAq9dOeccJtx8tvI35DqxEYA7UbpkzXAVXNDHE0 IFOyy8ZErAUJWOFoCloAq1Fmp4dBuHzElBX3T3BsJbwBN7htSllSvkE8WY6JJuGX9ZRb nNaA== X-Received: by 10.180.19.69 with SMTP id c5mr6558114wie.13.1436535690791; Fri, 10 Jul 2015 06:41:30 -0700 (PDT) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by smtp.gmail.com with ESMTPSA id az1sm8408292wib.0.2015.07.10.06.41.29 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 10 Jul 2015 06:41:29 -0700 (PDT) Date: Fri, 10 Jul 2015 15:41:27 +0200 From: Mateusz Guzik To: Konstantin Belousov 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> References: <201507101101.t6AB1VYe002159@repo.freebsd.org> <20150710111050.GU2080@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20150710111050.GU2080@kib.kiev.ua> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Jul 2015 13:41:32 -0000 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