diff options
author | pjd <pjd@FreeBSD.org> | 2012-06-11 20:17:20 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2012-06-11 20:17:20 +0000 |
commit | b7902b949c74ec688d4db4bea24c77f6057c9ba3 (patch) | |
tree | 9130d5e3a2d4111d9f43f2ab05b70ad7193cb8f5 /sys/kern/kern_descrip.c | |
parent | 8c0678ab023aaf27af89e59985696d8297b62649 (diff) | |
download | FreeBSD-src-b7902b949c74ec688d4db4bea24c77f6057c9ba3.zip FreeBSD-src-b7902b949c74ec688d4db4bea24c77f6057c9ba3.tar.gz |
Use consistent way of checking if descriptor number is valid.
MFC after: 1 month
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r-- | sys/kern/kern_descrip.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 6ddc2fa..8126206 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -245,7 +245,7 @@ fd_last_used(struct filedesc *fdp, int low, int size) static int fdisused(struct filedesc *fdp, int fd) { - KASSERT(fd >= 0 && fd < fdp->fd_nfiles, + KASSERT((unsigned int)fd < fdp->fd_nfiles, ("file descriptor %d out of range (0, %d)", fd, fdp->fd_nfiles)); return ((fdp->fd_map[NDSLOT(fd)] & NDBIT(fd)) != 0); } @@ -2212,7 +2212,7 @@ fget_unlocked(struct filedesc *fdp, int fd) struct file *fp; u_int count; - if (fd < 0 || fd >= fdp->fd_nfiles) + if ((unsigned int)fd >= fdp->fd_nfiles) return (NULL); /* * Fetch the descriptor locklessly. We avoid fdrop() races by @@ -2598,7 +2598,7 @@ dupfdopen(struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode, * closed, then reject. */ FILEDESC_XLOCK(fdp); - if (dfd < 0 || dfd >= fdp->fd_nfiles || + if ((unsigned int)dfd >= fdp->fd_nfiles || (wfp = fdp->fd_ofiles[dfd]) == NULL) { FILEDESC_XUNLOCK(fdp); return (EBADF); |