From: visa Date: Tue, 21 Aug 2018 13:50:31 +0000 (+0000) Subject: Use explicit fd indexing to access fd_ofiles, to clarify the code. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=47a41f73983275e789bcda8e72c6886415f8147f;p=openbsd Use explicit fd indexing to access fd_ofiles, to clarify the code. OK mpi@ --- diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index f8a0c09e174..a36a22f6b4b 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.180 2018/08/20 14:59:02 visa Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.181 2018/08/21 13:50:31 visa Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -1160,16 +1160,15 @@ void fdfree(struct proc *p) { struct filedesc *fdp = p->p_fd; - struct file **fpp, *fp; - int i; + struct file *fp; + int fd; if (--fdp->fd_refcnt > 0) return; - fpp = fdp->fd_ofiles; - for (i = fdp->fd_lastfile; i >= 0; i--, fpp++) { - fp = *fpp; + for (fd = 0; fd <= fdp->fd_lastfile; fd++) { + fp = fdp->fd_ofiles[fd]; if (fp != NULL) { - *fpp = NULL; + fdp->fd_ofiles[fd] = NULL; /* closef() expects a refcount of 2 */ FREF(fp); (void) closef(fp, p);