Use explicit fd indexing to access fd_ofiles, to clarify the code.
authorvisa <visa@openbsd.org>
Tue, 21 Aug 2018 13:50:31 +0000 (13:50 +0000)
committervisa <visa@openbsd.org>
Tue, 21 Aug 2018 13:50:31 +0000 (13:50 +0000)
OK mpi@

sys/kern/kern_descrip.c

index f8a0c09..a36a22f 100644 (file)
@@ -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);