-/* $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 $ */
/*
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);