Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Aug 2016 15:35:39 -0700
From:      Conrad Meyer <cem@freebsd.org>
To:        Mateusz Guzik <mjg@freebsd.org>
Cc:        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:  <CAG6CVpXwtKMp%2BVApeG-cTjVfGtH3DjKyKKPrmPe4fNZdAGNcEQ@mail.gmail.com>
In-Reply-To: <201608302148.u7ULmAKm073958@repo.freebsd.org>
References:  <201608302148.u7ULmAKm073958@repo.freebsd.org>

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

Best,
Conrad



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpXwtKMp%2BVApeG-cTjVfGtH3DjKyKKPrmPe4fNZdAGNcEQ>