From owner-svn-src-all@FreeBSD.ORG Mon Jun 11 20:17:21 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 141221065673; Mon, 11 Jun 2012 20:17:21 +0000 (UTC) (envelope-from pjd@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id F37078FC08; Mon, 11 Jun 2012 20:17:20 +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 q5BKHKh8007724; Mon, 11 Jun 2012 20:17:20 GMT (envelope-from pjd@svn.freebsd.org) Received: (from pjd@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q5BKHKsW007722; Mon, 11 Jun 2012 20:17:20 GMT (envelope-from pjd@svn.freebsd.org) Message-Id: <201206112017.q5BKHKsW007722@svn.freebsd.org> From: Pawel Jakub Dawidek Date: Mon, 11 Jun 2012 20:17:20 +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: r236917 - 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: Mon, 11 Jun 2012 20:17:21 -0000 Author: pjd Date: Mon Jun 11 20:17:20 2012 New Revision: 236917 URL: http://svn.freebsd.org/changeset/base/236917 Log: Use consistent way of checking if descriptor number is valid. MFC after: 1 month Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Mon Jun 11 20:12:13 2012 (r236916) +++ head/sys/kern/kern_descrip.c Mon Jun 11 20:17:20 2012 (r236917) @@ -245,7 +245,7 @@ fd_last_used(struct filedesc *fdp, int l 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 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 file * 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);