git: b1a00c2b1368 - main - Quiet compiler warnings for fget_noref and fdget_noref
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 16 Apr 2023 03:51:22 UTC
The branch main has been updated by stevek: URL: https://cgit.FreeBSD.org/src/commit/?id=b1a00c2b136841b84b8ffdc703a1afeee5d0e268 commit b1a00c2b136841b84b8ffdc703a1afeee5d0e268 Author: Stephen J. Kiernan <stevek@FreeBSD.org> AuthorDate: 2023-04-16 03:50:54 +0000 Commit: Stephen J. Kiernan <stevek@FreeBSD.org> CommitDate: 2023-04-16 03:50:54 +0000 Quiet compiler warnings for fget_noref and fdget_noref Summary: Typecasting both parts of the comparison to u_int quiets compiler warnings about signed/unsigned comparison and takes care of positive and negative numbers for the file descriptor in a single comparison. Obtained from: Juniper Netwowrks, Inc. Reviewers: mjg Subscribers: imp Differential Revision: https://reviews.freebsd.org/D39593 --- sys/sys/filedesc.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index ffea8d7e0195..578b84696663 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -303,7 +303,7 @@ fget_noref(struct filedesc *fdp, int fd) FILEDESC_LOCK_ASSERT(fdp); - if (__predict_false((u_int)fd >= fdp->fd_nfiles)) + if (__predict_false((u_int)fd >= (u_int)fdp->fd_nfiles)) return (NULL); return (fdp->fd_ofiles[fd].fde_file); @@ -316,7 +316,7 @@ fdeget_noref(struct filedesc *fdp, int fd) FILEDESC_LOCK_ASSERT(fdp); - if (__predict_false((u_int)fd >= fdp->fd_nfiles)) + if (__predict_false((u_int)fd >= (u_int)fdp->fd_nfiles)) return (NULL); fde = &fdp->fd_ofiles[fd];