svn commit: r305091 - head/sys/sys

Conrad Meyer cem at freebsd.org
Tue Aug 30 22:35:47 UTC 2016


On Tue, Aug 30, 2016 at 2:48 PM, Mateusz Guzik <mjg at 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.)

Best,
Conrad


More information about the svn-src-head mailing list