Date: Sun, 2 Nov 2014 02:32:34 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273959 - head/sys/kern Message-ID: <201411020232.sA22WYV6005949@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201411020232.sA22WYV6005949>