From owner-svn-src-head@FreeBSD.ORG Wed Jun 13 04:09:04 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6EA62106566B; Wed, 13 Jun 2012 04:09:04 +0000 (UTC) (envelope-from ache@vniz.net) Received: from vniz.net (vniz.net [194.87.13.69]) by mx1.freebsd.org (Postfix) with ESMTP id CAA068FC12; Wed, 13 Jun 2012 04:09:03 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vniz.net (8.14.5/8.14.5) with ESMTP id q5D491b8089102; Wed, 13 Jun 2012 08:09:01 +0400 (MSK) (envelope-from ache@vniz.net) Received: (from ache@localhost) by localhost (8.14.5/8.14.5/Submit) id q5D491Zu089101; Wed, 13 Jun 2012 08:09:01 +0400 (MSK) (envelope-from ache) Date: Wed, 13 Jun 2012 08:09:01 +0400 From: Andrey Chernov To: Bruce Evans Message-ID: <20120613040900.GA88971@vniz.net> Mail-Followup-To: Andrey Chernov , Bruce Evans , Pawel Jakub Dawidek , src-committers@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, svn-src-head@FreeBSD.ORG References: <201206112017.q5BKHKsW007722@svn.freebsd.org> <20120612114254.V1572@besplex.bde.org> <20120612115117.GB1372@garage.freebsd.pl> <20120613115111.R5323@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20120613115111.R5323@besplex.bde.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Pawel Jakub Dawidek Subject: Re: svn commit: r236917 - head/sys/kern X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jun 2012 04:09:04 -0000 On Wed, Jun 13, 2012 at 12:37:50PM +1000, Bruce Evans wrote: > >> On Mon, 11 Jun 2012, Pawel Jakub Dawidek wrote: > >>> - KASSERT(fd >= 0 && fd < fdp->fd_nfiles, > >>> + KASSERT((unsigned int)fd < fdp->fd_nfiles, > >>> ("file descriptor %d out of range (0, %d)", fd, fdp->fd_nfiles)); > >>> return ((fdp->fd_map[NDSLOT(fd)] & NDBIT(fd)) != 0); > >>> } > >> > >> This is backwards. Apart from using the worst possible (most verbose) > >> spelling of `unsigned', it uses a type hack manually optimize away the > >> test for fd being < 0. The compiler will do this "optimization" > >> automatically if it is any good (or undo it if it is not), so all the > >> hack does is obfuscate the test. With the verbose spelling of u_int, > >> it even takes more space. > > > > Well, to be honest I presonally would prefer explicit check for fd being > > less than 0, but my impression was that using cast is the most popular > > way and I wanted this check to be consistent across our source tree. > > > > Feel free to change it. > > I'm only free to ask you to back out it out. I agree that this change should backed out for better. It gains nothing for modern compilers, but makes code reading harder. -- http://ache.vniz.net/