From owner-svn-src-all@FreeBSD.ORG Sun Nov 2 02:32:34 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AA622DC5; Sun, 2 Nov 2014 02:32:34 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 975A885D; Sun, 2 Nov 2014 02:32:34 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sA22WY69005950; Sun, 2 Nov 2014 02:32:34 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sA22WYV6005949; Sun, 2 Nov 2014 02:32:34 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201411020232.sA22WYV6005949@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sun, 2 Nov 2014 02:32:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273959 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 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: Sun, 02 Nov 2014 02:32:34 -0000 Author: mjg Date: Sun Nov 2 02:32:33 2014 New Revision: 273959 URL: https://svnweb.freebsd.org/changeset/base/273959 Log: filedesc: tidy up fdcheckstd No functional changes. Modified: head/sys/kern/kern_descrip.c Modified: head/sys/kern/kern_descrip.c ============================================================================== --- head/sys/kern/kern_descrip.c Sun Nov 2 02:01:55 2014 (r273958) +++ head/sys/kern/kern_descrip.c Sun Nov 2 02:32:33 2014 (r273959) @@ -2189,29 +2189,28 @@ fdcheckstd(struct thread *td) fdp = td->td_proc->p_fd; KASSERT(fdp->fd_refcnt == 1, ("the fdtable should not be shared")); + MPASS(fdp->fd_nfiles >= 3); devnull = -1; - error = 0; - for (i = 0; i < 3; i++) { + for (i = 0; i <= 2; i++) { if (fdp->fd_ofiles[i].fde_file != NULL) continue; - if (devnull < 0) { - save = td->td_retval[0]; + + save = td->td_retval[0]; + if (devnull != -1) { + error = do_dup(td, DUP_FIXED, devnull, i); + } else { error = kern_open(td, "/dev/null", UIO_SYSSPACE, O_RDWR, 0); - devnull = td->td_retval[0]; - td->td_retval[0] = save; - if (error) - break; - KASSERT(devnull == i, ("oof, we didn't get our fd")); - } else { - save = td->td_retval[0]; - error = do_dup(td, DUP_FIXED, devnull, i); - td->td_retval[0] = save; - if (error != 0) - break; + if (error == 0) { + devnull = td->td_retval[0]; + KASSERT(devnull == i, ("we didn't get our fd")); + } } + td->td_retval[0] = save; + if (error != 0) + return (error); } - return (error); + return (0); } /*