From owner-svn-src-all@FreeBSD.ORG Thu Jun 14 15:37:15 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id D2EC2106566C; Thu, 14 Jun 2012 15:37:15 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [69.147.83.44]) by mx1.freebsd.org (Postfix) with ESMTP id BEB848FC17; Thu, 14 Jun 2012 15:37:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q5EFbFZs003159; Thu, 14 Jun 2012 15:37:15 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5EFbFHl003157; Thu, 14 Jun 2012 15:37:15 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206141537.q5EFbFHl003157@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Thu, 14 Jun 2012 15:37:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r237077 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Jun 2012 15:37:15 -0000 Author: pjd Date: Thu Jun 14 15:37:15 2012 New Revision: 237077 URL: http://svn.freebsd.org/changeset/base/237077 Log: Simplify the code by making more use of the fdtofp() function. MFC after: 1 month Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Thu Jun 14 15:35:14 2012 (r237076) +++ head/sys/kern/kern_descrip.c Thu Jun 14 15:37:15 2012 (r237077) @@ -679,8 +679,7 @@ kern_fcntl(struct thread *td, int fd, in vfslocked = 0; /* Check for race with close */ FILEDESC_SLOCK(fdp); - if (fd < 0 || fd >= fdp->fd_nfiles || - fp != fdp->fd_ofiles[fd]) { + if (fdtofp(fd, fdp) != fp) { FILEDESC_SUNLOCK(fdp); flp->l_whence = SEEK_SET; flp->l_start = 0; @@ -822,7 +821,7 @@ do_dup(struct thread *td, int flags, int return (flags & DUP_FCNTL ? EINVAL : EBADF); FILEDESC_XLOCK(fdp); - if (old >= fdp->fd_nfiles || fdp->fd_ofiles[old] == NULL) { + if (fdtofp(old, fdp) == NULL) { FILEDESC_XUNLOCK(fdp); return (EBADF); } @@ -1201,8 +1200,7 @@ kern_close(td, fd) AUDIT_SYSCLOSE(td, fd); FILEDESC_XLOCK(fdp); - if (fd < 0 || fd >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[fd]) == NULL) { + if ((fp = fdtofp(fd, fdp)) == NULL) { FILEDESC_XUNLOCK(fdp); return (EBADF); } @@ -2596,8 +2594,7 @@ dupfdopen(struct thread *td, struct file * closed, then reject. */ FILEDESC_XLOCK(fdp); - if (dfd < 0 || dfd >= fdp->fd_nfiles || - (fp = fdp->fd_ofiles[dfd]) == NULL) { + if ((fp = fdtofp(dfd, fdp)) == NULL) { FILEDESC_XUNLOCK(fdp); return (EBADF); }