From owner-svn-src-all@FreeBSD.ORG Tue Jun 12 11:53:13 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 74B5D1065670; Tue, 12 Jun 2012 11:53:13 +0000 (UTC) (envelope-from pawel@dawidek.net) Received: from mail.dawidek.net (60.wheelsystems.com [83.12.187.60]) by mx1.freebsd.org (Postfix) with ESMTP id EAE648FC0A; Tue, 12 Jun 2012 11:53:12 +0000 (UTC) Received: from localhost (58.wheelsystems.com [83.12.187.58]) by mail.dawidek.net (Postfix) with ESMTPSA id 6AFA1145; Tue, 12 Jun 2012 13:53:11 +0200 (CEST) Date: Tue, 12 Jun 2012 13:51:17 +0200 From: Pawel Jakub Dawidek To: Bruce Evans Message-ID: <20120612115117.GB1372@garage.freebsd.pl> References: <201206112017.q5BKHKsW007722@svn.freebsd.org> <20120612114254.V1572@besplex.bde.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="tjCHc7DPkfUGtrlw" Content-Disposition: inline In-Reply-To: <20120612114254.V1572@besplex.bde.org> X-OS: FreeBSD 10.0-CURRENT amd64 User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r236917 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Tue, 12 Jun 2012 11:53:13 -0000 --tjCHc7DPkfUGtrlw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Jun 12, 2012 at 12:53:47PM +1000, Bruce Evans wrote: > On Mon, 11 Jun 2012, Pawel Jakub Dawidek wrote: > > - KASSERT(fd >=3D 0 && fd < fdp->fd_nfiles, > > + KASSERT((unsigned int)fd < fdp->fd_nfiles, > > ("file descriptor %d out of range (0, %d)", fd, fdp->fd_nfi= les)); > > return ((fdp->fd_map[NDSLOT(fd)] & NDBIT(fd)) !=3D 0); > > } >=20 > 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. BTW. I really dislike using 'unsigned' with omitted 'int'. u_int is fine. --=20 Pawel Jakub Dawidek http://www.wheelsystems.com FreeBSD committer http://www.FreeBSD.org Am I Evil? Yes, I Am! http://tupytaj.pl --tjCHc7DPkfUGtrlw Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAk/XLTUACgkQForvXbEpPzQdtwCeL7L3KaM0pzUYkeBh5sQlMwLF 1R8AoNuKc1sL06wQmXFQ6BqoqKunbk7c =9mtg -----END PGP SIGNATURE----- --tjCHc7DPkfUGtrlw--