From 0d438f613460922936ca3aaf826e615cc3e82ebf Mon Sep 17 00:00:00 2001 From: Alfred Perlstein Date: Wed, 30 Jan 2002 19:53:57 +0000 Subject: [PATCH] fget_locked fixes. sort declaration. give paramters names. remove bogus check for negative fd (u_int) cast does this for us. Pointed out by: bde --- sys/sys/filedesc.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index cc0fe9b025cc..f9fa5914be9b 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -148,12 +148,12 @@ void fdfree __P((struct thread *td)); struct filedesc *fdinit __P((struct thread *td)); struct filedesc *fdshare __P((struct proc *p)); void ffree __P((struct file *fp)); +static __inline struct file * fget_locked __P((struct filedesc *fdp, int fd)); pid_t fgetown __P((struct sigio *sigio)); int fsetown __P((pid_t pgid, struct sigio **sigiop)); void funsetown __P((struct sigio *sigio)); void funsetownlst __P((struct sigiolst *sigiolst)); int getvnode __P((struct filedesc *fdp, int fd, struct file **fpp)); -static __inline struct file * fget_locked(struct filedesc *, int); void setugidsafety __P((struct thread *td)); static __inline struct file * @@ -162,9 +162,8 @@ fget_locked(fdp, fd) int fd; { - if (fd < 0 || (u_int)fd >= fdp->fd_nfiles) - return (NULL); - return (fdp->fd_ofiles[fd]); + /* u_int cast checks for negative descriptors. */ + return ((u_int)fd >= fdp->fd_nfiles ? NULL : fdp->fd_ofiles[fd]); } #endif /* _KERNEL */