Date: Wed, 31 Aug 2016 00:41:05 +0200 From: Mateusz Guzik <mjguzik@gmail.com> To: Conrad Meyer <cem@freebsd.org> Cc: Mateusz Guzik <mjg@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r305091 - head/sys/sys Message-ID: <20160830224104.GA16151@dft-labs.eu> In-Reply-To: <CAG6CVpXwtKMp%2BVApeG-cTjVfGtH3DjKyKKPrmPe4fNZdAGNcEQ@mail.gmail.com> References: <201608302148.u7ULmAKm073958@repo.freebsd.org> <CAG6CVpXwtKMp%2BVApeG-cTjVfGtH3DjKyKKPrmPe4fNZdAGNcEQ@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 30, 2016 at 03:35:39PM -0700, Conrad Meyer wrote: > On Tue, Aug 30, 2016 at 2:48 PM, Mateusz Guzik <mjg@freebsd.org> wrote: > > Author: mjg > > Date: Tue Aug 30 21:48:10 2016 > > New Revision: 305091 > > URL: https://svnweb.freebsd.org/changeset/base/305091 > > > > Log: > > fd: simplify fd testing in fget_locked by casting to u_int > > > > Modified: > > head/sys/sys/filedesc.h > > > > Modified: head/sys/sys/filedesc.h > > ============================================================================== > > --- head/sys/sys/filedesc.h Tue Aug 30 21:43:57 2016 (r305090) > > +++ head/sys/sys/filedesc.h Tue Aug 30 21:48:10 2016 (r305091) > > @@ -201,7 +201,7 @@ fget_locked(struct filedesc *fdp, int fd > > > > FILEDESC_LOCK_ASSERT(fdp); > > > > - if (fd < 0 || fd > fdp->fd_lastfile) > > + if ((u_int)fd > fdp->fd_lastfile) > > return (NULL); > > > > return (fdp->fd_ofiles[fd].fde_file); > > > > > I notice that fd_lastfile is an 'int'. Won't this trigger warnings > about the differing signedness of the two sides of the comparison? > Should fd_lastfile just be u_int as well? (If not (there is some > valid negative value), this change may be invalid.) > It is -1 just after inception and is supposed to grow immediately after. That is, the table with -1 should never be accessible. But now that you mention it I agree this is bad style. This unnecessarily differs from the check in fget_unlocked so I'll just unify it. -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160830224104.GA16151>