On Tue, Aug 30, 2016 at 03:35:39PM -0700, Conrad Meyer wrote: > On Tue, Aug 30, 2016 at 2:48 PM, Mateusz Guzik <m...@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> _______________________________________________ svn-src-head@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"