Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Jun 2012 08:09:01 +0400
From:      Andrey Chernov <ache@FreeBSD.ORG>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        svn-src-head@FreeBSD.ORG, svn-src-all@FreeBSD.ORG, src-committers@FreeBSD.ORG, Pawel Jakub Dawidek <pjd@FreeBSD.ORG>
Subject:   Re: svn commit: r236917 - head/sys/kern
Message-ID:  <20120613040900.GA88971@vniz.net>
In-Reply-To: <20120613115111.R5323@besplex.bde.org>
References:  <201206112017.q5BKHKsW007722@svn.freebsd.org> <20120612114254.V1572@besplex.bde.org> <20120612115117.GB1372@garage.freebsd.pl> <20120613115111.R5323@besplex.bde.org>

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



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