diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-03-05 21:48:58 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-03-05 21:48:58 +0000 |
commit | 52f635294dc2220b27898d3db1703c9464b92fb1 (patch) | |
tree | 5c2d6cca90a4bcc953c4c704201e7c2d7c08188e | |
parent | 84fa77ca902d7934ca42a7fdd806497b643a8421 (diff) |
Use more queue macros rather than doing it by hand; ok otto@ krw@
48 files changed, 291 insertions, 344 deletions
diff --git a/sys/compat/common/vfs_syscalls_25.c b/sys/compat/common/vfs_syscalls_25.c index 77f65ff4da4..333724e87e7 100644 --- a/sys/compat/common/vfs_syscalls_25.c +++ b/sys/compat/common/vfs_syscalls_25.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls_25.c,v 1.7 2005/11/30 10:35:07 pedro Exp $ */ +/* $OpenBSD: vfs_syscalls_25.c,v 1.8 2006/03/05 21:48:54 miod Exp $ */ /* * Copyright (c) 1989, 1993 @@ -195,7 +195,7 @@ compat_25_sys_getfsstat(p, v, retval) flags == 0) && (error = VFS_STATFS(mp, sp, p))) { simple_lock(&mountlist_slock); - nmp = mp->mnt_list.cqe_next; + nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp); continue; } diff --git a/sys/compat/freebsd/freebsd_file.c b/sys/compat/freebsd/freebsd_file.c index 1cbc83c40fd..f78a599f5e9 100644 --- a/sys/compat/freebsd/freebsd_file.c +++ b/sys/compat/freebsd/freebsd_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: freebsd_file.c,v 1.20 2005/11/30 10:35:07 pedro Exp $ */ +/* $OpenBSD: freebsd_file.c,v 1.21 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: freebsd_file.c,v 1.3 1996/05/03 17:03:09 christos Exp $ */ /* @@ -658,9 +658,10 @@ freebsd_sys_getfsstat(p, v, retval) sfsp = (caddr_t)SCARG(uap, buf); count = 0; simple_lock(&mountlist_slock); - for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { + for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist); + mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock)) { - nmp = mp->mnt_list.cqe_next; + nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } if (sfsp && count < maxcount) { @@ -673,7 +674,7 @@ freebsd_sys_getfsstat(p, v, retval) flags == 0) && (error = VFS_STATFS(mp, sp, p))) { simple_lock(&mountlist_slock); - nmp = mp->mnt_list.cqe_next; + nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp); continue; } @@ -689,7 +690,7 @@ freebsd_sys_getfsstat(p, v, retval) } count++; simple_lock(&mountlist_slock); - nmp = mp->mnt_list.cqe_next; + nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp); } simple_unlock(&mountlist_slock); diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 9811ff3fe93..976757a5c5c 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_socket.c,v 1.34 2005/11/21 18:16:37 millert Exp $ */ +/* $OpenBSD: linux_socket.c,v 1.35 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */ /* @@ -1418,12 +1418,10 @@ linux_ioctl_socket(p, v, retval) * Note that we don't actually respect the name in the ifreq * structure, as Linux interface names are all different. */ - for (ifp = ifnet.tqh_first; ifp != 0; - ifp = ifp->if_list.tqe_next) { + TAILQ_FOREACH(ifp, &ifnet, if_list) { if (ifp->if_type != IFT_ETHER) continue; - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if ((sdl = (struct sockaddr_dl *)ifa->ifa_addr) && (sdl->sdl_family == AF_LINK) && (sdl->sdl_type == IFT_ETHER)) { diff --git a/sys/compat/netbsd/netbsd_file.c b/sys/compat/netbsd/netbsd_file.c index 0c8c8ee252f..47e7e326f4f 100644 --- a/sys/compat/netbsd/netbsd_file.c +++ b/sys/compat/netbsd/netbsd_file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netbsd_file.c,v 1.6 2005/11/30 10:35:07 pedro Exp $ */ +/* $OpenBSD: netbsd_file.c,v 1.7 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: freebsd_file.c,v 1.3 1996/05/03 17:03:09 christos Exp $ */ /* @@ -632,9 +632,10 @@ netbsd_sys_getfsstat(p, v, retval) sfsp = (caddr_t)SCARG(uap, buf); count = 0; simple_lock(&mountlist_slock); - for (mp = mountlist.cqh_first; mp != (void *)&mountlist; mp = nmp) { + for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist); + mp = nmp) { if (vfs_busy(mp, LK_NOWAIT, &mountlist_slock)) { - nmp = mp->mnt_list.cqe_next; + nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } if (sfsp && count < maxcount) { @@ -647,7 +648,7 @@ netbsd_sys_getfsstat(p, v, retval) flags == 0) && (error = VFS_STATFS(mp, sp, p))) { simple_lock(&mountlist_slock); - nmp = mp->mnt_list.cqe_next; + nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp); continue; } @@ -663,7 +664,7 @@ netbsd_sys_getfsstat(p, v, retval) } count++; simple_lock(&mountlist_slock); - nmp = mp->mnt_list.cqe_next; + nmp = CIRCLEQ_NEXT(mp, mnt_list); vfs_unbusy(mp); } simple_unlock(&mountlist_slock); diff --git a/sys/compat/osf1/osf1_mount.c b/sys/compat/osf1/osf1_mount.c index e0d8dd1f57f..221c760d35b 100644 --- a/sys/compat/osf1/osf1_mount.c +++ b/sys/compat/osf1/osf1_mount.c @@ -1,4 +1,4 @@ -/* $OpenBSD: osf1_mount.c,v 1.10 2005/07/03 20:13:59 drahn Exp $ */ +/* $OpenBSD: osf1_mount.c,v 1.11 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: osf1_mount.c,v 1.14 1999/05/05 01:51:34 cgd Exp $ */ /* @@ -151,9 +151,10 @@ osf1_sys_getfsstat(p, v, retval) maxcount = SCARG(uap, bufsize) / sizeof(struct osf1_statfs); osf_sfsp = (caddr_t)SCARG(uap, buf); - for (count = 0, mp = mountlist.cqh_first; mp != (void *)&mountlist; + count = 0; + for (mp = CIRCLEQ_FIRST(&mountlist); mp != CIRCLEQ_END(&mountlist); mp = nmp) { - nmp = mp->mnt_list.cqe_next; + nmp = CIRCLEQ_NEXT(mp, mnt_list); if (osf_sfsp && count < maxcount) { sp = &mp->mnt_stat; /* diff --git a/sys/compat/svr4/svr4_misc.c b/sys/compat/svr4/svr4_misc.c index f02c0a925b7..4ff7d6c653f 100644 --- a/sys/compat/svr4/svr4_misc.c +++ b/sys/compat/svr4/svr4_misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_misc.c,v 1.44 2004/06/22 23:52:18 jfb Exp $ */ +/* $OpenBSD: svr4_misc.c,v 1.45 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: svr4_misc.c,v 1.42 1996/12/06 03:22:34 christos Exp $ */ /* @@ -824,7 +824,7 @@ svr4_pfind(pid) return p; /* look in the zombies */ - for (p = zombproc.lh_first; p != 0; p = p->p_list.le_next) + LIST_FOREACH(p, &zombproc, p_list) if (p->p_pid == pid) return p; @@ -1063,7 +1063,7 @@ svr4_sys_waitsys(q, v, retval) loop: nfound = 0; - for (p = q->p_children.lh_first; p != 0; p = p->p_sibling.le_next) { + LIST_FOREACH(p, &q->p_children, p_sibling) { if (SCARG(uap, id) != WAIT_ANY && p->p_pid != SCARG(uap, id) && p->p_pgid != -SCARG(uap, id)) { diff --git a/sys/compat/svr4/svr4_socket.c b/sys/compat/svr4/svr4_socket.c index 4eb3055647f..fab78137b58 100644 --- a/sys/compat/svr4/svr4_socket.c +++ b/sys/compat/svr4/svr4_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_socket.c,v 1.4 2002/04/25 21:01:41 espie Exp $ */ +/* $OpenBSD: svr4_socket.c,v 1.5 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: svr4_socket.c,v 1.4 1997/07/21 23:02:37 christos Exp $ */ /* @@ -93,7 +93,7 @@ svr4_find_socket(p, fp, dev, ino) DPRINTF(("svr4_find_socket: [%p,%d,%d]: ", p, dev, ino)); - for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next) + TAILQ_FOREACH(e, &svr4_head, entries) if (e->p == p && e->dev == dev && e->ino == ino) { #ifdef DIAGNOSTIC if (e->cookie != NULL && e->cookie != cookie) @@ -123,7 +123,7 @@ svr4_delete_socket(p, fp) return; } - for (e = svr4_head.tqh_first; e != NULL; e = e->entries.tqe_next) + TAILQ_FOREACH(e, &svr4_head, entries) if (e->p == p && e->cookie == cookie) { TAILQ_REMOVE(&svr4_head, e, entries); DPRINTF(("svr4_delete_socket: %s [%p,%d,%d]\n", diff --git a/sys/compat/svr4/svr4_sockio.c b/sys/compat/svr4/svr4_sockio.c index 57f51d512ad..f814c312d6e 100644 --- a/sys/compat/svr4/svr4_sockio.c +++ b/sys/compat/svr4/svr4_sockio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: svr4_sockio.c,v 1.9 2004/06/22 23:52:18 jfb Exp $ */ +/* $OpenBSD: svr4_sockio.c,v 1.10 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: svr4_sockio.c,v 1.10 1996/05/03 17:09:15 christos Exp $ */ /* @@ -109,13 +109,12 @@ svr4_sock_ioctl(fp, p, retval, fd, cmd, data) * entry per physical interface? */ - for (ifp = ifnet.tqh_first; - ifp != 0; ifp = ifp->if_list.tqe_next) - if ((ifa = ifp->if_addrlist.tqh_first) == NULL) + TAILQ_FOREACH(ifp, &ifnet, if_list) + if (TAILQ_EMPTY(&ifp->if_addrlist)) ifnum++; else - for (;ifa != NULL; - ifa = ifa->ifa_list.tqe_next) + TAILQ_FOREACH(ifa, &ifp->if_addrlist, + ifa_list) ifnum++; diff --git a/sys/compat/ultrix/ultrix_fs.c b/sys/compat/ultrix/ultrix_fs.c index 63a21c47fd4..6cacd7bd561 100644 --- a/sys/compat/ultrix/ultrix_fs.c +++ b/sys/compat/ultrix/ultrix_fs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ultrix_fs.c,v 1.13 2005/12/10 11:45:43 miod Exp $ */ +/* $OpenBSD: ultrix_fs.c,v 1.14 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: ultrix_fs.c,v 1.4 1996/04/07 17:23:06 jonathan Exp $ */ /* @@ -237,14 +237,14 @@ ultrix_sys_getmnt(p, v, retval) if ((error = copyin((caddr_t)SCARG(uap, start), &start, sizeof(*SCARG(uap, start)))) != 0) goto bad; - for (skip = start, mp = mountlist.cqh_first; - mp != (void *)&mountlist && skip-- > 0; mp = nmp) - nmp = mp->mnt_list.cqe_next; + for (skip = start, mp = CIRCLEQ_FIRST(&mountlist); + mp != CIRCLEQ_END(&mountlist) && skip-- > 0; mp = nmp) + nmp = CIRCLEQ_NEXT(mp, mnt_list); } - for (count = 0, mp = mountlist.cqh_first; - mp != (void *)&mountlist && count < maxcount; mp = nmp) { - nmp = mp->mnt_list.cqe_next; + for (count = 0, mp = CIRCLEQ_FIRST(&mountlist); + mp != CIRCLEQ_END(&mountlist) && count < maxcount; mp = nmp) { + nmp = CIRCLEQ_NEXT(mp, mnt_list); if (sfsp != NULL) { struct ultrix_fs_data tem; sp = &mp->mnt_stat; diff --git a/sys/dev/ic/ncr53c9x.c b/sys/dev/ic/ncr53c9x.c index 4d0d5f3d921..149ea6acbc8 100644 --- a/sys/dev/ic/ncr53c9x.c +++ b/sys/dev/ic/ncr53c9x.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ncr53c9x.c,v 1.29 2006/01/09 23:11:49 miod Exp $ */ +/* $OpenBSD: ncr53c9x.c,v 1.30 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: ncr53c9x.c,v 1.56 2000/11/30 14:41:46 thorpej Exp $ */ /* @@ -906,7 +906,7 @@ ncr53c9x_sched(sc) * Find first ecb in ready queue that is for a target/lunit * combinations that is not busy. */ - for (ecb = sc->ready_list.tqh_first; ecb; ecb = ecb->chain.tqe_next) { + TAILQ_FOREACH(ecb, &sc->ready_list, chain) { sc_link = ecb->xs->sc_link; ti = &sc->sc_tinfo[sc_link->target]; lun = sc_link->lun; @@ -2142,18 +2142,18 @@ again: /* Selection timeout -- discard all LUNs if empty */ sc_link = ecb->xs->sc_link; ti = &sc->sc_tinfo[sc_link->target]; - li = ti->luns.lh_first; - while (li) { + for (li = LIST_FIRST(&ti->luns); + li != LIST_END(&ti->luns); ) { if (!li->untagged && !li->used) { if (li->lun < NCR_NLUN) ti->lun[li->lun] = NULL; LIST_REMOVE(li, link); free(li, M_DEVBUF); /* Restart the search at the beginning */ - li = ti->luns.lh_first; + li = LIST_FIRST(&ti->luns); continue; } - li = li->link.le_next; + li = LIST_NEXT(li, link); } goto finish; } @@ -2805,18 +2805,17 @@ ncr53c9x_watch(arg) s = splbio(); for (t=0; t<NCR_NTARG; t++) { ti = &sc->sc_tinfo[t]; - li = ti->luns.lh_first; - while (li) { + for (li = LIST_FIRST(&ti->luns); li != LIST_END(&ti->luns); ) { if (li->last_used < old && !li->untagged && !li->used) { if (li->lun < NCR_NLUN) ti->lun[li->lun] = NULL; LIST_REMOVE(li, link); free(li, M_DEVBUF); /* Restart the search at the beginning */ - li = ti->luns.lh_first; + li = LIST_FIRST(&ti->luns); continue; } - li = li->link.le_next; + li = LIST_NEXT(li, link); } } splx(s); diff --git a/sys/dev/isa/if_trtcm_isa.c b/sys/dev/isa/if_trtcm_isa.c index 98bf3ea64bc..7dcd8c20f4a 100644 --- a/sys/dev/isa/if_trtcm_isa.c +++ b/sys/dev/isa/if_trtcm_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trtcm_isa.c,v 1.3 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: if_trtcm_isa.c,v 1.4 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: if_trtcm_isa.c,v 1.3 1999/04/30 15:29:24 bad Exp $ */ #undef TRTCMISADEBUG @@ -227,8 +227,7 @@ trtcm_isa_probe(parent, match, aux) /* * Probe this bus if we haven't done so already. */ - for (tcm = tcm_isa_all_probes.lh_first; tcm != NULL; - tcm = tcm->tcm_link.le_next) + LIST_FOREACH(tcm, &tcm_isa_all_probes, tcm_link) if (tcm->tcm_bus == bus) goto bus_probed; diff --git a/sys/dev/raidframe/rf_openbsdkintf.c b/sys/dev/raidframe/rf_openbsdkintf.c index b0393ca867a..30301ffc157 100644 --- a/sys/dev/raidframe/rf_openbsdkintf.c +++ b/sys/dev/raidframe/rf_openbsdkintf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rf_openbsdkintf.c,v 1.32 2006/01/21 12:20:51 miod Exp $ */ +/* $OpenBSD: rf_openbsdkintf.c,v 1.33 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: rf_netbsdkintf.c,v 1.109 2001/07/27 03:30:07 oster Exp $ */ /*- @@ -2753,7 +2753,7 @@ rf_find_raid_components(void) #ifdef RAID_AUTOCONFIG /* We begin by trolling through *all* the devices on the system. */ - for (dv = alldevs.tqh_first; dv != NULL; dv = dv->dv_list.tqe_next) { + TAILQ_FOREACH(dv, &alldevs, dv_list) { /* We are only interested in disks... */ if (dv->dv_class != DV_DISK) diff --git a/sys/dev/sbus/esp_sbus.c b/sys/dev/sbus/esp_sbus.c index 82c0e035c9b..6ba67c2cc9d 100644 --- a/sys/dev/sbus/esp_sbus.c +++ b/sys/dev/sbus/esp_sbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: esp_sbus.c,v 1.16 2004/09/29 19:17:43 miod Exp $ */ +/* $OpenBSD: esp_sbus.c,v 1.17 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: esp_sbus.c,v 1.14 2001/04/25 17:53:37 bouyer Exp $ */ /*- @@ -721,9 +721,9 @@ db_esp(db_expr_t addr, int have_addr, db_expr_t count, char *modif) sc->sc_imess[1], sc->sc_imess[2], sc->sc_imess[3], sc->sc_imess[0]); db_printf("ready: "); - for (ecb = sc->ready_list.tqh_first; ecb; ecb = ecb->chain.tqe_next) { + TAILQ_FOREACH(ecb, &sc->ready_list, chain) { db_printf("ecb %p ", ecb); - if (ecb == ecb->chain.tqe_next) { + if (ecb == TAILQ_NEXT(ecb, chain)) { db_printf("\nWARNING: tailq loop on ecb %p", ecb); break; } diff --git a/sys/kern/spec_vnops.c b/sys/kern/spec_vnops.c index 7e4a2f070f1..1f3fe5db55f 100644 --- a/sys/kern/spec_vnops.c +++ b/sys/kern/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.32 2006/02/20 19:44:58 miod Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.33 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -511,8 +511,9 @@ spec_fsync(v) */ loop: s = splbio(); - for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) { - nbp = bp->b_vnbufs.le_next; + for (bp = LIST_FIRST(&vp->v_dirtyblkhd); + bp != LIST_END(&vp->v_dirtyblkhd); bp = nbp) { + nbp = LIST_NEXT(bp, b_vnbufs); if ((bp->b_flags & B_BUSY)) continue; if ((bp->b_flags & B_DELWRI) == 0) @@ -527,7 +528,7 @@ loop: vwaitforio (vp, 0, "spec_fsync", 0); #ifdef DIAGNOSTIC - if (vp->v_dirtyblkhd.lh_first) { + if (!LIST_EMPTY(&vp->v_dirtyblkhd)) { splx(s); vprint("spec_fsync: dirty", vp); goto loop; diff --git a/sys/miscfs/procfs/procfs_subr.c b/sys/miscfs/procfs/procfs_subr.c index ac8a5769c01..7343fc7fb38 100644 --- a/sys/miscfs/procfs/procfs_subr.c +++ b/sys/miscfs/procfs/procfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_subr.c,v 1.24 2005/12/11 21:30:31 miod Exp $ */ +/* $OpenBSD: procfs_subr.c,v 1.25 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: procfs_subr.c,v 1.15 1996/02/12 15:01:42 christos Exp $ */ /* @@ -107,7 +107,7 @@ procfs_allocvp(mp, vpp, pid, pfs_type) if (error) return (error); loop: - for (pfs = pfshead.tqh_first; pfs != NULL; pfs = pfs->list.tqe_next) { + TAILQ_FOREACH(pfs, &pfshead, list) { vp = PFSTOV(pfs); if (pfs->pfs_pid == pid && pfs->pfs_type == pfs_type && diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index c235332da09..90f7f578b23 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: procfs_vnops.c,v 1.37 2005/12/11 21:30:31 miod Exp $ */ +/* $OpenBSD: procfs_vnops.c,v 1.38 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: procfs_vnops.c,v 1.40 1996/03/16 23:52:55 christos Exp $ */ /* @@ -986,7 +986,7 @@ procfs_readdir(v) int doingzomb = 0; #endif int pcnt = i; - volatile struct proc *p = allproc.lh_first; + volatile struct proc *p = LIST_FIRST(&allproc); if (pcnt > 3) pcnt = 3; @@ -1063,7 +1063,7 @@ procfs_readdir(v) #ifdef PROCFS_ZOMBIE if (p == 0 && doingzomb == 0) { doingzomb = 1; - p = zombproc.lh_first; + p = LIST_FIRST(&zombproc); goto again; } #endif diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index 7e4a2f070f1..1f3fe5db55f 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spec_vnops.c,v 1.32 2006/02/20 19:44:58 miod Exp $ */ +/* $OpenBSD: spec_vnops.c,v 1.33 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: spec_vnops.c,v 1.29 1996/04/22 01:42:38 christos Exp $ */ /* @@ -511,8 +511,9 @@ spec_fsync(v) */ loop: s = splbio(); - for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = nbp) { - nbp = bp->b_vnbufs.le_next; + for (bp = LIST_FIRST(&vp->v_dirtyblkhd); + bp != LIST_END(&vp->v_dirtyblkhd); bp = nbp) { + nbp = LIST_NEXT(bp, b_vnbufs); if ((bp->b_flags & B_BUSY)) continue; if ((bp->b_flags & B_DELWRI) == 0) @@ -527,7 +528,7 @@ loop: vwaitforio (vp, 0, "spec_fsync", 0); #ifdef DIAGNOSTIC - if (vp->v_dirtyblkhd.lh_first) { + if (!LIST_EMPTY(&vp->v_dirtyblkhd)) { splx(s); vprint("spec_fsync: dirty", vp); goto loop; diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index 321e3252e03..83e7d110312 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.h,v 1.35 2005/03/28 06:19:58 tedu Exp $ */ +/* $OpenBSD: if_ether.h,v 1.36 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */ /* @@ -243,11 +243,11 @@ struct ether_multistep { /* struct arpcom *ac; */ \ /* struct ether_multi *enm; */ \ { \ - for ((enm) = (ac)->ac_multiaddrs.lh_first; \ - (enm) != NULL && \ + for ((enm) = LIST_FIRST(&(ac)->ac_multiaddrs); \ + (enm) != LIST_END(&(ac)->ac_multiaddrs) && \ (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \ bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \ - (enm) = (enm)->enm_list.le_next); \ + (enm) = LIST_NEXT((enm), enm_list)); \ } /* @@ -262,7 +262,7 @@ struct ether_multistep { /* struct ether_multi *enm; */ \ { \ if (((enm) = (step).e_enm) != NULL) \ - (step).e_enm = (enm)->enm_list.le_next; \ + (step).e_enm = LIST_NEXT((enm), enm_list); \ } #define ETHER_FIRST_MULTI(step, ac, enm) \ @@ -270,7 +270,7 @@ struct ether_multistep { /* struct arpcom *ac; */ \ /* struct ether_multi *enm; */ \ { \ - (step).e_enm = (ac)->ac_multiaddrs.lh_first; \ + (step).e_enm = LIST_FIRST(&(ac)->ac_multiaddrs); \ ETHER_NEXT_MULTI((step), (enm)); \ } diff --git a/sys/netinet/in.c b/sys/netinet/in.c index ed48a712707..f2d13390bd9 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in.c,v 1.43 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: in.c,v 1.44 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: in.c,v 1.26 1996/02/13 23:41:39 christos Exp $ */ /* @@ -114,11 +114,11 @@ in_localaddr(in) struct in_ifaddr *ia; if (subnetsarelocal) { - for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) if ((in.s_addr & ia->ia_netmask) == ia->ia_net) return (1); } else { - for (ia = in_ifaddr.tqh_first; ia != 0; ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) if ((in.s_addr & ia->ia_subnetmask) == ia->ia_subnet) return (1); } @@ -240,7 +240,7 @@ in_control(so, cmd, data, ifp) * Find address for this interface, if it exists. */ if (ifp) - for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) if (ia->ia_ifp == ifp) break; @@ -249,12 +249,13 @@ in_control(so, cmd, data, ifp) case SIOCAIFADDR: case SIOCDIFADDR: if (ifra->ifra_addr.sin_family == AF_INET) - for (; ia != 0; ia = ia->ia_list.tqe_next) { - if (ia->ia_ifp == ifp && - ia->ia_addr.sin_addr.s_addr == - ifra->ifra_addr.sin_addr.s_addr) - break; - } + for (; ia != TAILQ_END(&in_ifaddr); + ia = TAILQ_NEXT(ia, ia_list)) { + if (ia->ia_ifp == ifp && + ia->ia_addr.sin_addr.s_addr == + ifra->ifra_addr.sin_addr.s_addr) + break; + } if (cmd == SIOCDIFADDR && ia == 0) return (EADDRNOTAVAIL); /* FALLTHROUGH */ @@ -307,7 +308,8 @@ in_control(so, cmd, data, ifp) if (ia && satosin(&ifr->ifr_addr)->sin_addr.s_addr) { struct in_ifaddr *ia2; - for (ia2 = ia; ia2; ia2 = ia2->ia_list.tqe_next) { + for (ia2 = ia; ia2 != TAILQ_END(&in_ifaddr); + ia2 = TAILQ_NEXT(ia2, ia_list)) { if (ia2->ia_ifp == ifp && ia2->ia_addr.sin_addr.s_addr == satosin(&ifr->ifr_addr)->sin_addr.s_addr) @@ -594,7 +596,7 @@ in_lifaddr_ioctl(so, cmd, data, ifp) } } - for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET) continue; if (!cmp) @@ -833,7 +835,7 @@ in_scrubprefix(target) prefix.s_addr &= mask.s_addr; } - for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) { + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { if (rtinitflags(ia)) p = ia->ia_dstaddr.sin_addr; else { @@ -886,11 +888,11 @@ in_broadcast(in, ifp) return 1; if (ifp == NULL) { - if_first = ifnet.tqh_first; + if_first = TAILQ_FIRST(&ifnet); if_target = 0; } else { if_first = ifp; - if_target = ifp->if_list.tqe_next; + if_target = TAILQ_NEXT(ifp, if_list); } #define ia (ifatoia(ifa)) @@ -899,11 +901,10 @@ in_broadcast(in, ifp) * with a broadcast address. * If ifp is NULL, check against all the interfaces. */ - for (ifn = if_first; ifn != if_target; ifn = ifn->if_list.tqe_next) { + for (ifn = if_first; ifn != if_target; ifn = TAILQ_NEXT(ifn, if_list)) { if ((ifn->if_flags & IFF_BROADCAST) == 0) continue; - for (ifa = ifn->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) + TAILQ_FOREACH(ifa, &ifn->if_addrlist, ifa_list) if (ifa->ifa_addr->sa_family == AF_INET && in.s_addr != ia->ia_addr.sin_addr.s_addr && (in.s_addr == ia->ia_broadaddr.sin_addr.s_addr || diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 974f0442e0f..1dc2af9749e 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.84 2005/06/24 07:57:24 markus Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.85 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -247,7 +247,7 @@ in_pcbbind(v, nam) return in6_pcbbind(inp, nam); #endif /* INET6 */ - if (in_ifaddr.tqh_first == 0) + if (TAILQ_EMPTY(&in_ifaddr)) return (EADDRNOTAVAIL); if (inp->inp_lport || inp->inp_laddr.s_addr != INADDR_ANY) return (EINVAL); @@ -399,7 +399,7 @@ in_pcbconnect(v, nam) return (EAFNOSUPPORT); if (sin->sin_port == 0) return (EADDRNOTAVAIL); - if (in_ifaddr.tqh_first != 0) { + if (!TAILQ_EMPTY(&in_ifaddr)) { /* * If the destination address is INADDR_ANY, * use the primary local address. @@ -408,10 +408,10 @@ in_pcbconnect(v, nam) * choose the broadcast address for that interface. */ if (sin->sin_addr.s_addr == INADDR_ANY) - sin->sin_addr = in_ifaddr.tqh_first->ia_addr.sin_addr; + sin->sin_addr = TAILQ_FIRST(&in_ifaddr)->ia_addr.sin_addr; else if (sin->sin_addr.s_addr == INADDR_BROADCAST && - (in_ifaddr.tqh_first->ia_ifp->if_flags & IFF_BROADCAST)) - sin->sin_addr = in_ifaddr.tqh_first->ia_broadaddr.sin_addr; + (TAILQ_FIRST(&in_ifaddr)->ia_ifp->if_flags & IFF_BROADCAST)) + sin->sin_addr = TAILQ_FIRST(&in_ifaddr)->ia_broadaddr.sin_addr; } if (inp->inp_laddr.s_addr == INADDR_ANY) { int error; @@ -847,7 +847,7 @@ in_selectsrc(sin, ro, soopts, mopts, errorp) ia = ifatoia(ifa_ifwithnet(sintosa(sin))); sin->sin_port = fport; if (ia == 0) - ia = in_ifaddr.tqh_first; + ia = TAILQ_FIRST(&in_ifaddr); if (ia == 0) { *errorp = EADDRNOTAVAIL; return NULL; @@ -865,8 +865,7 @@ in_selectsrc(sin, ro, soopts, mopts, errorp) imo = mopts; if (imo->imo_multicast_ifp != NULL) { ifp = imo->imo_multicast_ifp; - for (ia = in_ifaddr.tqh_first; ia != 0; - ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) if (ia->ia_ifp == ifp) break; if (ia == 0) { @@ -929,7 +928,7 @@ in_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg) u_int16_t fport = fport_arg, lport = lport_arg; head = INPCBHASH(table, &faddr, fport, &laddr, lport); - for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) { + LIST_FOREACH(inp, head, inp_hash) { #ifdef INET6 if (inp->inp_flags & INP_IPV6) continue; /*XXX*/ @@ -943,7 +942,7 @@ in_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg) * repeated accesses are quicker. This is analogous to * the historic single-entry PCB cache. */ - if (inp != head->lh_first) { + if (inp != LIST_FIRST(head)) { LIST_REMOVE(inp, inp_hash); LIST_INSERT_HEAD(head, inp, inp_hash); } @@ -972,7 +971,7 @@ in6_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg) u_int16_t fport = fport_arg, lport = lport_arg; head = IN6PCBHASH(table, faddr, fport, laddr, lport); - for (inp = head->lh_first; inp != NULL; inp = inp->inp_hash.le_next) { + LIST_FOREACH(inp, head, inp_hash) { if (!(inp->inp_flags & INP_IPV6)) continue; if (IN6_ARE_ADDR_EQUAL(&inp->inp_faddr6, faddr) && @@ -983,7 +982,7 @@ in6_pcbhashlookup(table, faddr, fport_arg, laddr, lport_arg) * repeated accesses are quicker. This is analogous to * the historic single-entry PCB cache. */ - if (inp != head->lh_first) { + if (inp != LIST_FIRST(head)) { LIST_REMOVE(inp, inp_hash); LIST_INSERT_HEAD(head, inp, inp_hash); } @@ -1063,7 +1062,7 @@ in_pcblookup_listen(table, laddr, lport_arg, reverse) * repeated accesses are quicker. This is analogous to * the historic single-entry PCB cache. */ - if (inp != NULL && inp != head->lh_first) { + if (inp != NULL && inp != LIST_FIRST(head)) { LIST_REMOVE(inp, inp_hash); LIST_INSERT_HEAD(head, inp, inp_hash); } @@ -1122,7 +1121,7 @@ in6_pcblookup_listen(table, laddr, lport_arg, reverse) * repeated accesses are quicker. This is analogous to * the historic single-entry PCB cache. */ - if (inp != NULL && inp != head->lh_first) { + if (inp != NULL && inp != LIST_FIRST(head)) { LIST_REMOVE(inp, inp_hash); LIST_INSERT_HEAD(head, inp, inp_hash); } diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index 95aa7c27f9c..083a8e946a3 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_var.h,v 1.8 2005/01/15 09:09:27 pascoe Exp $ */ +/* $OpenBSD: in_var.h,v 1.9 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $ */ /* @@ -95,9 +95,9 @@ void in_socktrim(struct sockaddr_in *); { \ struct in_ifaddr *ia; \ \ - for (ia = in_ifaddr.tqh_first; \ - ia != NULL && ia->ia_addr.sin_addr.s_addr != (addr).s_addr; \ - ia = ia->ia_list.tqe_next) \ + for (ia = TAILQ_FIRST(&in_ifaddr); ia != TAILQ_END(&in_ifaddr) && \ + ia->ia_addr.sin_addr.s_addr != (addr).s_addr; \ + ia = TAILQ_NEXT(ia, ia_list)) \ continue; \ (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \ } @@ -110,9 +110,9 @@ void in_socktrim(struct sockaddr_in *); /* struct ifnet *ifp; */ \ /* struct in_ifaddr *ia; */ \ { \ - for ((ia) = in_ifaddr.tqh_first; \ - (ia) != NULL && (ia)->ia_ifp != (ifp); \ - (ia) = (ia)->ia_list.tqe_next) \ + for ((ia) = TAILQ_FIRST(&in_ifaddr); \ + (ia) != TAILQ_END(&in_ifaddr) && (ia)->ia_ifp != (ifp); \ + (ia) = TAILQ_NEXT((ia), ia_list)) \ continue; \ } #endif @@ -169,9 +169,10 @@ struct in_multistep { if (ia == NULL) \ (inm) = NULL; \ else \ - for ((inm) = ia->ia_multiaddrs.lh_first; \ - (inm) != NULL && (inm)->inm_addr.s_addr != (addr).s_addr; \ - (inm) = inm->inm_list.le_next) \ + for ((inm) = LIST_FIRST(&ia->ia_multiaddrs); \ + (inm) != LIST_END(&ia->ia_multiaddrs) && \ + (inm)->inm_addr.s_addr != (addr).s_addr; \ + (inm) = LIST_NEXT(inm, inm_list)) \ continue; \ } @@ -187,13 +188,13 @@ struct in_multistep { /* struct in_multi *inm; */ \ { \ if (((inm) = (step).i_inm) != NULL) \ - (step).i_inm = (inm)->inm_list.le_next; \ + (step).i_inm = LIST_NEXT((inm), inm_list); \ else \ while ((step).i_ia != NULL) { \ - (inm) = (step).i_ia->ia_multiaddrs.lh_first; \ - (step).i_ia = (step).i_ia->ia_list.tqe_next; \ + (inm) = LIST_FIRST(&(step).i_ia->ia_multiaddrs); \ + (step).i_ia = TAILQ_NEXT((step).i_ia, ia_list); \ if ((inm) != NULL) { \ - (step).i_inm = (inm)->inm_list.le_next; \ + (step).i_inm = LIST_NEXT((inm), inm_list); \ break; \ } \ } \ @@ -203,7 +204,7 @@ struct in_multistep { /* struct in_multistep step; */ \ /* struct in_multi *inm; */ \ { \ - (step).i_ia = in_ifaddr.tqh_first; \ + (step).i_ia = TAILQ_FIRST(&in_ifaddr); \ (step).i_inm = NULL; \ IN_NEXT_MULTI((step), (inm)); \ } diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index 69ffef86641..b40fa9adeba 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.69 2005/10/17 08:43:34 henning Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.70 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -631,7 +631,7 @@ icmp_reflect(struct mbuf *m) * use dst as the src for the reply. For broadcast, use * the address which corresponds to the incoming interface. */ - for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) { + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) { if (t.s_addr == ia->ia_addr.sin_addr.s_addr) break; if ((ia->ia_ifp->if_flags & IFF_BROADCAST) && diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index e77bee09577..83d63334ad9 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_input.c,v 1.137 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: ip_input.c,v 1.138 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: ip_input.c,v 1.30 1996/03/16 23:53:58 christos Exp $ */ /* @@ -287,7 +287,7 @@ ipv4_input(m) * If no IP addresses have been set yet but the interfaces * are receiving, can't do anything with incoming packets yet. */ - if (in_ifaddr.tqh_first == 0) + if (TAILQ_EMPTY(&in_ifaddr)) goto bad; ipstat.ips_total++; if (m->m_len < sizeof (struct ip) && @@ -521,7 +521,7 @@ ours: * of this datagram. */ ipq_lock(); - for (fp = ipq.lh_first; fp != NULL; fp = fp->ipq_q.le_next) + LIST_FOREACH(fp, &ipq, ipq_q) if (ip->ip_id == fp->ipq_id && ip->ip_src.s_addr == fp->ipq_src.s_addr && ip->ip_dst.s_addr == fp->ipq_dst.s_addr && @@ -751,12 +751,12 @@ ip_reass(ipqe, fp) * drop if CE and not-ECT are mixed for the same packet. */ ecn = ipqe->ipqe_ip->ip_tos & IPTOS_ECN_MASK; - ecn0 = fp->ipq_fragq.lh_first->ipqe_ip->ip_tos & IPTOS_ECN_MASK; + ecn0 = LIST_FIRST(&fp->ipq_fragq)->ipqe_ip->ip_tos & IPTOS_ECN_MASK; if (ecn == IPTOS_ECN_CE) { if (ecn0 == IPTOS_ECN_NOTECT) goto dropfrag; if (ecn0 != IPTOS_ECN_CE) - fp->ipq_fragq.lh_first->ipqe_ip->ip_tos |= IPTOS_ECN_CE; + LIST_FIRST(&fp->ipq_fragq)->ipqe_ip->ip_tos |= IPTOS_ECN_CE; } if (ecn == IPTOS_ECN_NOTECT && ecn0 != IPTOS_ECN_NOTECT) goto dropfrag; @@ -764,8 +764,8 @@ ip_reass(ipqe, fp) /* * Find a segment which begins after this one does. */ - for (p = NULL, q = fp->ipq_fragq.lh_first; q != NULL; - p = q, q = q->ipqe_q.le_next) + for (p = NULL, q = LIST_FIRST(&fp->ipq_fragq); + q != LIST_END(&fp->ipq_fragq); p = q, q = LIST_NEXT(q, ipqe_q)) if (ntohs(q->ipqe_ip->ip_off) > ntohs(ipqe->ipqe_ip->ip_off)) break; @@ -805,7 +805,7 @@ ip_reass(ipqe, fp) m_adj(q->ipqe_m, i); break; } - nq = q->ipqe_q.le_next; + nq = LIST_NEXT(q, ipqe_q); m_freem(q->ipqe_m); LIST_REMOVE(q, ipqe_q); pool_put(&ipqent_pool, q); @@ -823,8 +823,8 @@ insert: LIST_INSERT_AFTER(p, ipqe, ipqe_q); } next = 0; - for (p = NULL, q = fp->ipq_fragq.lh_first; q != NULL; - p = q, q = q->ipqe_q.le_next) { + for (p = NULL, q = LIST_FIRST(&fp->ipq_fragq); + q != LIST_END(&fp->ipq_fragq); p = q, q = LIST_NEXT(q, ipqe_q)) { if (ntohs(q->ipqe_ip->ip_off) != next) return (0); next += ntohs(q->ipqe_ip->ip_len); @@ -836,7 +836,7 @@ insert: * Reassembly is complete. Check for a bogus message size and * concatenate fragments. */ - q = fp->ipq_fragq.lh_first; + q = LIST_FIRST(&fp->ipq_fragq); ip = q->ipqe_ip; if ((next + (ip->ip_hl << 2)) > IP_MAXPACKET) { ipstat.ips_toolong++; @@ -847,12 +847,12 @@ insert: t = m->m_next; m->m_next = 0; m_cat(m, t); - nq = q->ipqe_q.le_next; + nq = LIST_NEXT(q, ipqe_q); pool_put(&ipqent_pool, q); ip_frags--; for (q = nq; q != NULL; q = nq) { t = q->ipqe_m; - nq = q->ipqe_q.le_next; + nq = LIST_NEXT(q, ipqe_q); pool_put(&ipqent_pool, q); ip_frags--; m_cat(m, t); @@ -898,8 +898,9 @@ ip_freef(fp) { struct ipqent *q, *p; - for (q = fp->ipq_fragq.lh_first; q != NULL; q = p) { - p = q->ipqe_q.le_next; + for (q = LIST_FIRST(&fp->ipq_fragq); q != LIST_END(&fp->ipq_fragq); + q = p) { + p = LIST_NEXT(q, ipqe_q); m_freem(q->ipqe_m); LIST_REMOVE(q, ipqe_q); pool_put(&ipqent_pool, q); @@ -921,8 +922,8 @@ ip_slowtimo() int s = splsoftnet(); ipq_lock(); - for (fp = ipq.lh_first; fp != NULL; fp = nfp) { - nfp = fp->ipq_q.le_next; + for (fp = LIST_FIRST(&ipq); fp != LIST_END(&ipq); fp = nfp) { + nfp = LIST_NEXT(fp, ipq_q); if (--fp->ipq_ttl == 0) { ipstat.ips_fragtimeout++; ip_freef(fp); @@ -945,9 +946,9 @@ ip_drain() if (ipq_lock_try() == 0) return; - while (ipq.lh_first != NULL) { + while (!LIST_EMPTY(&ipq)) { ipstat.ips_fragdropped++; - ip_freef(ipq.lh_first); + ip_freef(LIST_FIRST(&ipq)); } ipq_unlock(); } @@ -961,9 +962,9 @@ ip_flush() int max = 50; /* ipq already locked */ - while (ipq.lh_first != NULL && ip_frags > ip_maxqueue * 3 / 4 && --max) { + while (!LIST_EMPTY(&ipq) && ip_frags > ip_maxqueue * 3 / 4 && --max) { ipstat.ips_fragdropped++; - ip_freef(ipq.lh_first); + ip_freef(LIST_FIRST(&ipq)); } } @@ -1260,9 +1261,8 @@ ip_weadvertise(addr) return 0; } - for (ifp = ifnet.tqh_first; ifp != 0; ifp = ifp->if_list.tqe_next) - for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifp, &ifnet, if_list) + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != rt->rt_gateway->sa_family) continue; diff --git a/sys/netinet/ip_ipip.c b/sys/netinet/ip_ipip.c index 9b6fd0c5615..01976eeed4c 100644 --- a/sys/netinet/ip_ipip.c +++ b/sys/netinet/ip_ipip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipip.c,v 1.34 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: ip_ipip.c,v 1.35 2006/03/05 21:48:56 miod Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr) and @@ -290,10 +290,8 @@ ipip_input(struct mbuf *m, int iphlen, struct ifnet *gifp) if ((m->m_pkthdr.rcvif == NULL || !(m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK)) && ipip_allow != 2) { - for (ifp = ifnet.tqh_first; ifp != 0; - ifp = ifp->if_list.tqe_next) { - for (ifa = ifp->if_addrlist.tqh_first; ifa != 0; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifp, &ifnet, if_list) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { #ifdef INET if (ipo) { if (ifa->ifa_addr->sa_family != diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 5582cf9a09a..a811e011339 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.175 2006/03/05 02:29:46 brad Exp $ */ +/* $OpenBSD: ip_output.c,v 1.176 2006/03/05 21:48:56 miod Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -459,9 +459,7 @@ ip_output(struct mbuf *m0, ...) if (ip->ip_src.s_addr == INADDR_ANY) { struct in_ifaddr *ia; - for (ia = in_ifaddr.tqh_first; - ia; - ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) if (ia->ia_ifp == ifp) { ip->ip_src = ia->ia_addr.sin_addr; break; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 5791bc7f7ec..a14519aa345 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.37 2005/05/27 04:55:28 mcbride Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.38 2006/03/05 21:48:57 miod Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -387,7 +387,7 @@ rip_usrreq(so, req, m, nam, control) error = EINVAL; break; } - if ((ifnet.tqh_first == 0) || + if ((TAILQ_EMPTY(&ifnet)) || ((addr->sin_family != AF_INET) && (addr->sin_family != AF_IMPLINK)) || (addr->sin_addr.s_addr && @@ -406,7 +406,7 @@ rip_usrreq(so, req, m, nam, control) error = EINVAL; break; } - if (ifnet.tqh_first == 0) { + if (TAILQ_EMPTY(&ifnet)) { error = EADDRNOTAVAIL; break; } diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 047376ede3d..a997f4ea354 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.85 2005/10/22 06:38:54 brad Exp $ */ +/* $OpenBSD: icmp6.c,v 1.86 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1672,12 +1672,9 @@ ni6_addrs(ni6, m, ifpp, subj) } } - for (ifp = TAILQ_FIRST(&ifnet); ifp; ifp = TAILQ_NEXT(ifp, if_list)) - { + TAILQ_FOREACH(ifp, &ifnet, if_list) { addrsofif = 0; - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ifa6 = (struct in6_ifaddr *)ifa; @@ -1756,11 +1753,8 @@ ni6_store_addrs(ni6, nni6, ifp0, resid) again: - for (; ifp; ifp = TAILQ_NEXT(ifp, if_list)) - { - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) - { + for (; ifp != TAILQ_END(&ifnet); ifp = TAILQ_NEXT(ifp, if_list)) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ifa6 = (struct in6_ifaddr *)ifa; diff --git a/sys/netinet6/in6.c b/sys/netinet6/in6.c index 61fb740b1f2..70700fa9a62 100644 --- a/sys/netinet6/in6.c +++ b/sys/netinet6/in6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6.c,v 1.63 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: in6.c,v 1.64 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: in6.c,v 1.372 2004/06/14 08:14:21 itojun Exp $ */ /* @@ -1252,7 +1252,8 @@ in6_purgeaddr(ifa) /* * leave from multicast groups we have joined for the interface */ - while ((imm = ia->ia6_memberships.lh_first) != NULL) { + while (!LIST_EMPTY(&ia->ia6_memberships)) { + imm = LIST_FIRST(&ia->ia6_memberships); LIST_REMOVE(imm, i6mm_chain); in6_leavegroup(imm); } @@ -1284,7 +1285,7 @@ in6_unlink_ifa(ia, ifp) } } - if (oia->ia6_multiaddrs.lh_first != NULL) { + if (!LIST_EMPTY(&oia->ia6_multiaddrs)) { in6_savemkludge(oia); } @@ -1510,10 +1511,7 @@ in6_lifaddr_ioctl(so, cmd, data, ifp, p) } } - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (!cmp) @@ -1596,9 +1594,7 @@ in6_ifinit(ifp, ia, sin6, newhost) * if this is its first address, * and to validate the address if necessary. */ - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6) @@ -1661,8 +1657,9 @@ in6_savemkludge(oia) IFP_TO_IA6(oia->ia_ifp, ia); if (ia) { /* there is another address */ - for (in6m = oia->ia6_multiaddrs.lh_first; in6m; in6m = next){ - next = in6m->in6m_entry.le_next; + for (in6m = LIST_FIRST(&oia->ia6_multiaddrs); + in6m != LIST_END(&oia->ia6_multiaddrs); in6m = next) { + next = LIST_NEXT(in6m, in6m_entry); IFAFREE(&in6m->in6m_ia->ia_ifa); ia->ia_ifa.ifa_refcnt++; in6m->in6m_ia = ia; @@ -1671,15 +1668,16 @@ in6_savemkludge(oia) } else { /* last address on this if deleted, save */ struct multi6_kludge *mk; - for (mk = in6_mk.lh_first; mk; mk = mk->mk_entry.le_next) { + LIST_FOREACH(mk, &in6_mk, mk_entry) { if (mk->mk_ifp == oia->ia_ifp) break; } if (mk == NULL) /* this should not happen! */ panic("in6_savemkludge: no kludge space"); - for (in6m = oia->ia6_multiaddrs.lh_first; in6m; in6m = next){ - next = in6m->in6m_entry.le_next; + for (in6m = LIST_FIRST(&oia->ia6_multiaddrs); + in6m != LIST_END(&oia->ia6_multiaddrs); in6m = next) { + next = LIST_NEXT(in6m, in6m_entry); IFAFREE(&in6m->in6m_ia->ia_ifa); /* release reference */ in6m->in6m_ia = NULL; LIST_INSERT_HEAD(&mk->mk_head, in6m, in6m_entry); @@ -1699,12 +1697,14 @@ in6_restoremkludge(ia, ifp) { struct multi6_kludge *mk; - for (mk = in6_mk.lh_first; mk; mk = mk->mk_entry.le_next) { + LIST_FOREACH(mk, &in6_mk, mk_entry) { if (mk->mk_ifp == ifp) { struct in6_multi *in6m, *next; - for (in6m = mk->mk_head.lh_first; in6m; in6m = next) { - next = in6m->in6m_entry.le_next; + for (in6m = LIST_FIRST(&ia->ia6_multiaddrs); + in6m != LIST_END(&ia->ia6_multiaddrs); + in6m = next) { + next = LIST_NEXT(in6m, in6m_entry); in6m->in6m_ia = ia; ia->ia_ifa.ifa_refcnt++; LIST_INSERT_HEAD(&ia->ia6_multiaddrs, @@ -1733,7 +1733,7 @@ in6_createmkludge(ifp) { struct multi6_kludge *mk; - for (mk = in6_mk.lh_first; mk; mk = mk->mk_entry.le_next) { + LIST_FOREACH(mk, &in6_mk, mk_entry) { /* If we've already had one, do not allocate. */ if (mk->mk_ifp == ifp) return; @@ -1754,7 +1754,7 @@ in6_purgemkludge(ifp) struct multi6_kludge *mk; struct in6_multi *in6m; - for (mk = in6_mk.lh_first; mk; mk = mk->mk_entry.le_next) { + LIST_FOREACH(mk, &in6_mk, mk_entry) { if (mk->mk_ifp != ifp) continue; @@ -1931,10 +1931,7 @@ in6ifa_ifpforlinklocal(ifp, ignoreflags) { struct ifaddr *ifa; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6) @@ -1961,10 +1958,7 @@ in6ifa_ifpwithaddr(ifp, addr) { struct ifaddr *ifa; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6) @@ -2243,9 +2237,7 @@ in6_ifawithscope(oifp, dst) if (in6_addr2scopeid(ifp, dst) != in6_addr2scopeid(oifp, dst)) continue; - for (ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { int tlen = -1, dscopecmp, bscopecmp, matchcmp; if (ifa->ifa_addr->sa_family != AF_INET6) @@ -2481,10 +2473,7 @@ in6_ifawithifp(ifp, dst) * If two or more, return one which matches the dst longest. * If none, return one of global addresses assigned other ifs. */ - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST) @@ -2518,10 +2507,7 @@ in6_ifawithifp(ifp, dst) if (besta) return (besta); - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; if (((struct in6_ifaddr *)ifa)->ia6_flags & IN6_IFF_ANYCAST) @@ -2565,10 +2551,7 @@ in6_if_up(ifp) in6_ifattach(ifp, NULL); dad_delay = 0; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_INET6) continue; ia = (struct in6_ifaddr *)ifa; diff --git a/sys/netinet6/in6_ifattach.c b/sys/netinet6/in6_ifattach.c index 542b35e8de2..53fea4b8566 100644 --- a/sys/netinet6/in6_ifattach.c +++ b/sys/netinet6/in6_ifattach.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_ifattach.c,v 1.39 2005/05/23 20:10:14 mpf Exp $ */ +/* $OpenBSD: in6_ifattach.c,v 1.40 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: in6_ifattach.c,v 1.124 2001/07/18 08:32:51 jinmei Exp $ */ /* @@ -134,10 +134,7 @@ get_hw_ifid(ifp, in6) static u_int8_t allone[8] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family != AF_LINK) continue; sdl = (struct sockaddr_dl *)ifa->ifa_addr; @@ -279,8 +276,7 @@ get_ifid(ifp0, altifp, in6) } /* next, try to get it from some other hardware interface */ - for (ifp = ifnet.tqh_first; ifp; ifp = ifp->if_list.tqe_next) - { + TAILQ_FOREACH(ifp, &ifnet, if_list) { if (ifp == ifp0) continue; if (get_hw_ifid(ifp, in6) != 0) @@ -663,18 +659,18 @@ in6_ifdetach(ifp) nd6_purge(ifp); /* nuke any of IPv6 addresses we have */ - for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = next) - { - next = ifa->ifa_list.tqe_next; + for (ifa = TAILQ_FIRST(&ifp->if_addrlist); + ifa != TAILQ_END(&ifp->if_addrlist); ifa = next) { + next = TAILQ_NEXT(ifa, ifa_list); if (ifa->ifa_addr->sa_family != AF_INET6) continue; in6_purgeaddr(ifa); } /* undo everything done by in6_ifattach(), just in case */ - for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = next) - { - next = ifa->ifa_list.tqe_next; + for (ifa = TAILQ_FIRST(&ifp->if_addrlist); + ifa != TAILQ_END(&ifp->if_addrlist); ifa = next) { + next = TAILQ_NEXT(ifa, ifa_list); if (ifa->ifa_addr->sa_family != AF_INET6 || !IN6_IS_ADDR_LINKLOCAL(&satosin6(&ifa->ifa_addr)->sin6_addr)) { @@ -686,7 +682,8 @@ in6_ifdetach(ifp) /* * leave from multicast groups we have joined for the interface */ - while ((imm = ia->ia6_memberships.lh_first) != NULL) { + while (!LIST_EMPTY(&ia->ia6_memberships)) { + imm = LIST_FIRST(&ia->ia6_memberships); LIST_REMOVE(imm, i6mm_chain); in6_leavegroup(imm); } diff --git a/sys/netinet6/in6_var.h b/sys/netinet6/in6_var.h index 5cfc1c60d71..b67e45dbf6f 100644 --- a/sys/netinet6/in6_var.h +++ b/sys/netinet6/in6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_var.h,v 1.26 2005/12/11 17:21:53 deraadt Exp $ */ +/* $OpenBSD: in6_var.h,v 1.27 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: in6_var.h,v 1.55 2001/02/16 12:49:45 itojun Exp $ */ /* @@ -469,7 +469,7 @@ extern unsigned long in6_maxmtu; /* struct in6_ifaddr *ia; */ \ do { \ struct ifaddr *ifa; \ - for (ifa = (ifp)->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next) { \ + TAILQ_FOREACH(ifa, &(ifp)->if_addrlist, ifa_list) { \ if (!ifa->ifa_addr) \ continue; \ if (ifa->ifa_addr->sa_family == AF_INET6) \ @@ -525,10 +525,10 @@ do { \ if (ia == NULL) \ (in6m) = NULL; \ else \ - for ((in6m) = ia->ia6_multiaddrs.lh_first; \ - (in6m) != NULL && \ + for ((in6m) = LIST_FIRST(&ia->ia6_multiaddrs); \ + (in6m) != LIST_END(&ia->ia6_multiaddrs) && \ !IN6_ARE_ADDR_EQUAL(&(in6m)->in6m_addr, &(addr)); \ - (in6m) = (in6m)->in6m_entry.le_next) \ + (in6m) = LIST_NEXT((in6m), in6m_entry)) \ continue; \ } while (0) @@ -544,13 +544,13 @@ do { \ /* struct in6_multi *in6m; */ \ do { \ if (((in6m) = (step).i_in6m) != NULL) \ - (step).i_in6m = (in6m)->in6m_entry.le_next; \ + (step).i_in6m = LIST_NEXT((in6m), in6m_entry); \ else \ while ((step).i_ia != NULL) { \ - (in6m) = (step).i_ia->ia6_multiaddrs.lh_first; \ + (in6m) = LIST_FIRST(&(step).i_ia->ia6_multiaddrs); \ (step).i_ia = (step).i_ia->ia_next; \ if ((in6m) != NULL) { \ - (step).i_in6m = (in6m)->in6m_entry.le_next; \ + (step).i_in6m = LIST_NEXT((in6m), in6m_entry); \ break; \ } \ } \ diff --git a/sys/netinet6/ip6_input.c b/sys/netinet6/ip6_input.c index d3920a83809..ab5605ff04b 100644 --- a/sys/netinet6/ip6_input.c +++ b/sys/netinet6/ip6_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_input.c,v 1.63 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: ip6_input.c,v 1.64 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $ */ /* @@ -483,9 +483,7 @@ ip6_input(m) * working right. */ struct ifaddr *ifa; - for (ifa = m->m_pkthdr.rcvif->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &m->m_pkthdr.rcvif->if_addrlist, ifa_list) { if (ifa->ifa_addr == NULL) continue; /* just for safety */ if (ifa->ifa_addr->sa_family != AF_INET6) diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index 9a55e90007d..31972159f45 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.87 2005/01/11 08:57:24 djm Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.88 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -2005,8 +2005,7 @@ ip6_setmoptions(optname, im6op, m) /* * See if the membership already exists. */ - for (imm = im6o->im6o_memberships.lh_first; - imm != NULL; imm = imm->i6mm_chain.le_next) + LIST_FOREACH(imm, &im6o->im6o_memberships, i6mm_chain) if (imm->i6mm_maddr->in6m_ifp == ifp && IN6_ARE_ADDR_EQUAL(&imm->i6mm_maddr->in6m_addr, &mreq->ipv6mr_multiaddr)) @@ -2072,8 +2071,7 @@ ip6_setmoptions(optname, im6op, m) /* * Find the membership in the membership list. */ - for (imm = im6o->im6o_memberships.lh_first; - imm != NULL; imm = imm->i6mm_chain.le_next) { + LIST_FOREACH(imm, &im6o->im6o_memberships, i6mm_chain) { if ((ifp == NULL || imm->i6mm_maddr->in6m_ifp == ifp) && IN6_ARE_ADDR_EQUAL(&imm->i6mm_maddr->in6m_addr, &mreq->ipv6mr_multiaddr)) @@ -2103,7 +2101,7 @@ ip6_setmoptions(optname, im6op, m) if (im6o->im6o_multicast_ifp == NULL && im6o->im6o_multicast_hlim == ip6_defmcasthlim && im6o->im6o_multicast_loop == IPV6_DEFAULT_MULTICAST_LOOP && - im6o->im6o_memberships.lh_first == NULL) { + LIST_EMPTY(&im6o->im6o_memberships)) { free(*im6op, M_IPMOPTS); *im6op = NULL; } @@ -2170,7 +2168,8 @@ ip6_freemoptions(im6o) if (im6o == NULL) return; - while ((imm = im6o->im6o_memberships.lh_first) != NULL) { + while (!LIST_EMPTY(&im6o->im6o_memberships)) { + imm = LIST_FIRST(&im6o->im6o_memberships); LIST_REMOVE(imm, i6mm_chain); in6_leavegroup(imm); } diff --git a/sys/netinet6/mld6.c b/sys/netinet6/mld6.c index 3806ed9c8a4..f668bb59daf 100644 --- a/sys/netinet6/mld6.c +++ b/sys/netinet6/mld6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mld6.c,v 1.19 2003/06/11 02:54:02 itojun Exp $ */ +/* $OpenBSD: mld6.c,v 1.20 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: mld6.c,v 1.26 2001/02/16 14:50:35 itojun Exp $ */ /* @@ -257,10 +257,7 @@ mld6_input(m, off) mld_all_nodes_linklocal.s6_addr16[1] = htons(ifp->if_index); /* XXX */ - for (in6m = ia->ia6_multiaddrs.lh_first; - in6m; - in6m = in6m->in6m_entry.le_next) - { + LIST_FOREACH(in6m, &ia->ia6_multiaddrs, in6m_entry) { if (IN6_ARE_ADDR_EQUAL(&in6m->in6m_addr, &mld_all_nodes_linklocal) || IPV6_ADDR_MC_SCOPE(&in6m->in6m_addr) < diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index e4cce30453f..51d7d509907 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_nbr.c,v 1.38 2006/02/06 17:37:28 jmc Exp $ */ +/* $OpenBSD: nd6_nbr.c,v 1.39 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* @@ -1028,7 +1028,7 @@ nd6_dad_find(ifa) { struct dadq *dp; - for (dp = dadq.tqh_first; dp; dp = dp->dad_list.tqe_next) { + TAILQ_FOREACH(dp, &dadq, dad_list) { if (dp->dad_ifa == ifa) return dp; } diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 30a39d7b299..2e210988ddc 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.35 2005/11/29 02:59:42 jolan Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.36 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -1101,8 +1101,7 @@ prelist_update(new, dr, m) * form an address. Note that even a manually configured address * should reject autoconfiguration of a new address. */ - for (ifa = ifp->if_addrlist.tqh_first; ifa; ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { struct in6_ifaddr *ifa6; int ifa_plen; u_int32_t storedlifetime; @@ -1460,10 +1459,7 @@ nd6_prefix_onlink(pr) IN6_IFF_NOTREADY | IN6_IFF_ANYCAST); if (ifa == NULL) { /* XXX: freebsd does not have ifa_ifwithaf */ - for (ifa = ifp->if_addrlist.tqh_first; - ifa; - ifa = ifa->ifa_list.tqe_next) - { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family == AF_INET6) break; } diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 5bbab8ca444..641cce0427b 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.28 2004/08/23 01:30:30 itojun Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.29 2006/03/05 21:48:57 miod Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -654,7 +654,7 @@ rip6_usrreq(so, req, m, nam, control, p) error = EINVAL; break; } - if ((ifnet.tqh_first == 0) || (addr->sin6_family != AF_INET6)) { + if (TAILQ_EMPTY(&ifnet) || (addr->sin6_family != AF_INET6)) { error = EADDRNOTAVAIL; break; } @@ -705,8 +705,7 @@ rip6_usrreq(so, req, m, nam, control, p) error = EINVAL; break; } - if (ifnet.tqh_first == 0) - { + if (TAILQ_EMPTY(&ifnet)) { error = EADDRNOTAVAIL; break; } diff --git a/sys/netipx/ipx.c b/sys/netipx/ipx.c index edd7dc7d378..559e45d50e5 100644 --- a/sys/netipx/ipx.c +++ b/sys/netipx/ipx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipx.c,v 1.13 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: ipx.c,v 1.14 2006/03/05 21:48:57 miod Exp $ */ /*- * @@ -71,7 +71,7 @@ ipx_control(so, cmd, data, ifp) * Find address for this interface, if it exists. */ if (ifp) - for (ia = ipx_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &ipx_ifaddr, ia_list) if (ia->ia_ifp == ifp) break; @@ -79,7 +79,8 @@ ipx_control(so, cmd, data, ifp) case SIOCAIFADDR: case SIOCDIFADDR: if (ifra->ifra_addr.sipx_family == AF_IPX) - for (; ia; ia = ia->ia_list.tqe_next) { + for (; ia != TAILQ_END(&ipx_ifaddr); + ia = TAILQ_NEXT(ia, ia_list)) { if (ia->ia_ifp == ifp && ipx_neteq(ia->ia_addr.sipx_addr, ifra->ifra_addr.sipx_addr)) @@ -294,7 +295,7 @@ ipx_iaonnetof(dst) struct ipx_ifaddr *ia_maybe = NULL; union ipx_net net = dst->ipx_net; - for (ia = ipx_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) { + TAILQ_FOREACH(ia, &ipx_ifaddr, ia_list) { if ((ifp = ia->ia_ifp)) { if (ifp->if_flags & IFF_POINTOPOINT) { compare = &satoipx_addr(ia->ia_dstaddr); diff --git a/sys/netipx/ipx_input.c b/sys/netipx/ipx_input.c index 658e8b62411..5c6d5c61371 100644 --- a/sys/netipx/ipx_input.c +++ b/sys/netipx/ipx_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipx_input.c,v 1.20 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: ipx_input.c,v 1.21 2006/03/05 21:48:57 miod Exp $ */ /*- * @@ -147,9 +147,7 @@ next: /* * Give any raw listeners a crack at the packet */ - for (ipxp = ipxrawcbtable.ipxpt_queue.cqh_first; - ipxp != (struct ipxpcb *)&ipxrawcbtable.ipxpt_queue; - ipxp = ipxp->ipxp_queue.cqe_next) { + CIRCLEQ_FOREACH(ipxp, &ipxrawcbtable.input_queue, ipxp_queue) { struct mbuf *m1 = m_copy(m, 0, (int)M_COPYALL); if (m1) ipx_input(m1, ipxp); @@ -205,8 +203,7 @@ next: * If it is a broadcast to the net where it was * received from, treat it as ours. */ - for (ia = ipx_ifaddr.tqh_first; ia; - ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &ipx->if_addr, ia_list) if((ia->ia_ifa.ifa_ifp == m->m_pkthdr.rcvif) && ipx_neteq(ia->ia_addr.sipx_addr, ipx->ipx_dna)) @@ -231,7 +228,7 @@ next: * Is this our packet? If not, forward. */ } else { - for (ia = ipx_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &ipx_ifaddr, ia_list) if (ipx_hosteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) && (ipx_neteq(ipx->ipx_dna, ia->ia_addr.sipx_addr) || ipx_neteqnn(ipx->ipx_dna.ipx_net, ipx_zeronet))) @@ -460,9 +457,7 @@ struct ifnet *ifp; /* * Give any raw listeners a crack at the packet */ - for (ipxp = ipxrawcbtable.ipxpt_queue.cqh_first; - ipxp != (struct ipxpcb *)&ipxrawcbtable.ipxpt_queue; - ipxp = ipxp->ipxp_queue.cqe_next) { + CIRCLEQ_FOREACH(ipxp, &ipxrawcbtable.ipxpt_queue, ipxp_queue) { struct mbuf *m0 = m_copy(m, 0, (int)M_COPYALL); if (m0) { struct ipx *ipx; @@ -472,8 +467,7 @@ struct ifnet *ifp; continue; ipx = mtod(m0, struct ipx *); ipx->ipx_sna.ipx_net = ipx_zeronet; - for (ia = ipx_ifaddr.tqh_first; ia; - ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &ipx_ifaddr, ia_list) if (ifp == ia->ia_ifp) break; if (ia == NULL) @@ -483,8 +477,7 @@ struct ifnet *ifp; ia->ia_addr.sipx_addr.ipx_host; if (ifp && (ifp->if_flags & IFF_POINTOPOINT)) - for(ifa = ifp->if_addrlist.tqh_first; ifa; - ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family == AF_IPX) { ipx->ipx_sna = IA_SIPX(ifa)->sipx_addr; break; diff --git a/sys/netipx/ipx_ip.c b/sys/netipx/ipx_ip.c index dc20cf5f639..1855c21134f 100644 --- a/sys/netipx/ipx_ip.c +++ b/sys/netipx/ipx_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipx_ip.c,v 1.20 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: ipx_ip.c,v 1.21 2006/03/05 21:48:57 miod Exp $ */ /*- * @@ -331,7 +331,7 @@ ipxip_route(m) /* * First, make sure we already have an IPX address. */ - if (ipx_ifaddr.tqh_first == NULL) + if (TAILQ_EMPTY(&ipx_ifaddr)) return (EADDRNOTAVAIL); /* * Now, determine if we can get to the destination @@ -351,11 +351,11 @@ ipxip_route(m) struct in_ifaddr *ia; struct ifnet *ifp = ro.ro_rt->rt_ifp; - for (ia = in_ifaddr.tqh_first; ia; ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &in_ifaddr, ia_list) if (ia->ia_ifp == ifp) break; if (ia == NULL) - ia = in_ifaddr.tqh_first; + ia = TAILQ_FIRST(&in_ifaddr); if (ia == NULL) { RTFREE(ro.ro_rt); return (EADDRNOTAVAIL); @@ -388,7 +388,7 @@ ipxip_route(m) (caddr_t)&ifr_ipxip, (struct ifnet *)ifn); satoipx_addr(ifr_ipxip.ifr_addr).ipx_host = - ipx_ifaddr.tqh_first->ia_addr.sipx_addr.ipx_host; + TAILQ_FIRST(&ipx_ifaddr)->ia_addr.sipx_addr.ipx_host; return (ipx_control((struct socket *)0, (int)SIOCSIFADDR, (caddr_t)&ifr_ipxip, (struct ifnet *)ifn)); diff --git a/sys/netipx/ipx_outputfl.c b/sys/netipx/ipx_outputfl.c index 43cd6c500a5..e6ca65ca22c 100644 --- a/sys/netipx/ipx_outputfl.c +++ b/sys/netipx/ipx_outputfl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipx_outputfl.c,v 1.7 2003/12/10 07:22:43 itojun Exp $ */ +/* $OpenBSD: ipx_outputfl.c,v 1.8 2006/03/05 21:48:57 miod Exp $ */ /*- * @@ -189,7 +189,7 @@ ipx_output_type20(m) /* * Now see if we have already seen this. */ - for (ia = ipx_ifaddr.tqh_first; ia != NULL; ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &ipx_ifaddr, ia_list) if(ia->ia_ifa.ifa_ifp == m->m_pkthdr.rcvif) { if(tia == NULL) tia = ia; @@ -229,7 +229,7 @@ ipx_output_type20(m) dst.sipx_len = sizeof(dst); dst.sipx_addr.ipx_host = ipx_broadhost; - for (ia = ipx_ifaddr.tqh_first; ia != NULL; ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &ipx_ifaddr, ia_list) if(ia->ia_ifa.ifa_ifp != m->m_pkthdr.rcvif) { nbnet = (union ipx_net *)(ipx + 1); for (i = 0; i < ipx->ipx_tc; i++, nbnet++) diff --git a/sys/netipx/ipx_pcb.c b/sys/netipx/ipx_pcb.c index 48315371754..abdc76638af 100644 --- a/sys/netipx/ipx_pcb.c +++ b/sys/netipx/ipx_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipx_pcb.c,v 1.11 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: ipx_pcb.c,v 1.12 2006/03/05 21:48:57 miod Exp $ */ /*- * @@ -215,8 +215,7 @@ ipx_pcbconnect(ipxp, nam) * corresponding to the outgoing interface */ if (ro->ro_rt && (ifp = ro->ro_rt->rt_ifp)) - for (ia = ipx_ifaddr.tqh_first; ia; - ia = ia->ia_list.tqe_next) + TAILQ_FOREACH(ia, &ipx_ifaddr, ia_list) if (ia->ia_ifp == ifp) break; if (ia == NULL) { @@ -228,7 +227,7 @@ ipx_pcbconnect(ipxp, nam) if (ia == NULL) ia = ipx_iaonnetof(&sipx->sipx_addr); if (ia == NULL) - ia = ipx_ifaddr.tqh_first; + ia = TAILQ_FIRST(&ipx_ifaddr); if (ia == 0) return (EADDRNOTAVAIL); } @@ -319,11 +318,11 @@ ipx_pcbnotify(dst, errno, notify, param) struct ipxpcb *ipxp, *oinp; int s = splnet(); - for (ipxp = ipxcbtable.ipxpt_queue.cqh_first; - ipxp != (struct ipxpcb *)&ipxcbtable.ipxpt_queue;) { + for (ipxp = CIRCLEQ_FIRST(&ipxcbtable.ipxpt_queue); + ipxp != CIRCLEQ_END(&ipxcbtable.ipxpt_queue);) { if (!ipx_hosteq(*dst,ipxp->ipxp_faddr)) { next: - ipxp = ipxp->ipxp_queue.cqe_next; + ipxp = CIRCLEQ_NEXT(ipxp, ipxp_queue); continue; } if (ipxp->ipxp_socket == 0) @@ -331,7 +330,7 @@ ipx_pcbnotify(dst, errno, notify, param) if (errno) ipxp->ipxp_socket->so_error = errno; oinp = ipxp; - ipxp = ipxp->ipxp_queue.cqe_next; + ipxp = CIRCLEQ_NEXT(ipxp, ipxp_queue); oinp->ipxp_notify_param = param; (*notify)(oinp); } @@ -369,9 +368,7 @@ ipx_pcblookup(faddr, lport, wildp) u_short fport; fport = faddr->ipx_port; - for (ipxp = ipxcbtable.ipxpt_queue.cqh_first; - ipxp != (struct ipxpcb *)&ipxcbtable.ipxpt_queue; - ipxp = ipxp->ipxp_queue.cqe_next) { + CIRCLEQ_FOREACH(ipxp, &ipxcbtable.ipxpt_queue, ipxp_queue) { if (ipxp->ipxp_lport != lport) continue; wildcard = 0; diff --git a/sys/netipx/ipx_usrreq.c b/sys/netipx/ipx_usrreq.c index 8e0db39f5af..1bfce2dc3d3 100644 --- a/sys/netipx/ipx_usrreq.c +++ b/sys/netipx/ipx_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ipx_usrreq.c,v 1.14 2004/01/03 14:08:54 espie Exp $ */ +/* $OpenBSD: ipx_usrreq.c,v 1.15 2006/03/05 21:48:57 miod Exp $ */ /*- * @@ -102,8 +102,7 @@ ipx_input(struct mbuf *m, ...) if (ipx_neteqnn(ipx->ipx_sna.ipx_net, ipx_zeronet) && ifp) { struct ifaddr *ifa; - for (ifa = ifp->if_addrlist.tqh_first; - ifa; ifa = ifa->ifa_list.tqe_next) { + TAILQ_FOREACH(ifa, &ifp->if_addrlist, ifa_list) { if (ifa->ifa_addr->sa_family == AF_IPX) { ipx_ipx.sipx_addr.ipx_net = IA_SIPX(ifa)->sipx_addr.ipx_net; diff --git a/sys/netipx/spx_usrreq.c b/sys/netipx/spx_usrreq.c index 5c87ac02978..ecf413a73e6 100644 --- a/sys/netipx/spx_usrreq.c +++ b/sys/netipx/spx_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: spx_usrreq.c,v 1.24 2005/11/26 04:33:27 marco Exp $ */ +/* $OpenBSD: spx_usrreq.c,v 1.25 2006/03/05 21:48:57 miod Exp $ */ /*- * @@ -1635,10 +1635,8 @@ spx_fasttimo() struct spxpcb *cb; int s = splnet(); - ipxp = ipxcbtable.ipxpt_queue.cqh_first; - if (ipxp) - for (; ipxp != (struct ipxpcb *)&ipxcbtable.ipxpt_queue; - ipxp = ipxp->ipxp_queue.cqe_next) + if (!CIRCLEQ_EMPTY(&ipxpcbtable.ipxpt_queue)) + CIRCLEQ_FOREACH(ipxp, &ipxpcbtable.ipxpt_queue, ipxp_queue) if ((cb = (struct spxpcb *)ipxp->ipxp_ppcb) && (cb->s_flags & SF_DELACK)) { cb->s_flags &= ~SF_DELACK; @@ -1665,14 +1663,14 @@ spx_slowtimo() /* * Search through tcb's and update active timers. */ - ipx = ipxcbtable.ipxpt_queue.cqh_first; - if (ipx == 0) { + if (CIRCLEQ_EMPTY(&ipxpcbtable.ipxpt_queue)) { splx(s); return; } - while (ipx != (struct ipxpcb *)&ipxcbtable.ipxpt_queue) { + for (ipx = CIRCLEQ_FIRST(&ipxcbtable.ipxpt_queue); + ipx != CIRCLEQ_END(&ipxcbtable.ipxpt_queue);) { cb = ipxtospxpcb(ipx); - ipxnxt = ipx->ipxp_queue.cqe_next; + ipxnxt = CIRCLEQ_NEXT(ipx, ipxp_queue); if (cb == 0) goto tpgone; for (i = 0; i < SPXT_NTIMERS; i++) { diff --git a/sys/netnatm/natm_pcb.c b/sys/netnatm/natm_pcb.c index fdb406f8bc8..45d7c391266 100644 --- a/sys/netnatm/natm_pcb.c +++ b/sys/netnatm/natm_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: natm_pcb.c,v 1.6 2006/03/04 22:40:16 brad Exp $ */ +/* $OpenBSD: natm_pcb.c,v 1.7 2006/03/05 21:48:57 miod Exp $ */ /* * @@ -124,8 +124,7 @@ u_int8_t vpi; * lookup required */ - for (cpcb = natm_pcbs.lh_first ; cpcb != NULL ; - cpcb = cpcb->pcblist.le_next) { + LIST_FOREACH(cpcb, &natm_pcbs, pcblist) { if (ifp == cpcb->npcb_ifp && vci == cpcb->npcb_vci && vpi == cpcb->npcb_vpi) break; } @@ -176,8 +175,7 @@ int npcb_dump() struct natmpcb *cpcb; printf("npcb dump:\n"); - for (cpcb = natm_pcbs.lh_first ; cpcb != NULL ; - cpcb = cpcb->pcblist.le_next) { + LIST_FOREACH(cpcb, &natm_pcbs, pcblist) { printf("if=%s, vci=%d, vpi=%d, IP=0x%x, sock=%p, flags=0x%x, inq=%d\n", cpcb->npcb_ifp->if_xname, cpcb->npcb_vci, cpcb->npcb_vpi, cpcb->ipaddr.s_addr, cpcb->npcb_socket, diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c index 3d2699ee398..f5f233ef658 100644 --- a/sys/ntfs/ntfs_subr.c +++ b/sys/ntfs/ntfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_subr.c,v 1.8 2005/11/19 02:18:01 pedro Exp $ */ +/* $OpenBSD: ntfs_subr.c,v 1.9 2006/03/05 21:48:57 miod Exp $ */ /* $NetBSD: ntfs_subr.c,v 1.4 2003/04/10 21:37:32 jdolecek Exp $ */ /*- @@ -151,7 +151,7 @@ ntfs_findvattr(ntmp, ip, lvapp, vapp, type, name, namelen, vcn) *lvapp = NULL; *vapp = NULL; - for (vap = ip->i_valist.lh_first; vap; vap = vap->va_list.le_next) { + LIST_FOREACH(vap, &ip->i_valist, va_list) { ddprintf(("ntfs_findvattr: type: 0x%x, vcn: %d - %d\n", \ vap->va_type, (u_int32_t) vap->va_vcnstart, \ (u_int32_t) vap->va_vcnend)); @@ -785,7 +785,7 @@ ntfs_fget( dprintf(("ntfs_fget: ino: %d, attrtype: 0x%x, attrname: %s\n", ip->i_number,attrtype, attrname?attrname:"")); *fpp = NULL; - for (fp = ip->i_fnlist.lh_first; fp != NULL; fp = fp->f_fnlist.le_next){ + LIST_FOREACH(fp, &ip->i_fnlist, f_fnlist) { dprintf(("ntfs_fget: fnode: attrtype: %d, attrname: %s\n", fp->f_attrtype, fp->f_attrname?fp->f_attrname:"")); diff --git a/sys/ufs/lfs/lfs_inode.c b/sys/ufs/lfs/lfs_inode.c index 38575121ce2..e6542f92ffa 100644 --- a/sys/ufs/lfs/lfs_inode.c +++ b/sys/ufs/lfs/lfs_inode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_inode.c,v 1.11 2005/12/28 20:48:18 pedro Exp $ */ +/* $OpenBSD: lfs_inode.c,v 1.12 2006/03/05 21:48:57 miod Exp $ */ /* $NetBSD: lfs_inode.c,v 1.5 1996/05/11 18:27:35 mycroft Exp $ */ /* @@ -336,7 +336,7 @@ lfs_truncate(v) */ a_released = 0; i_released = 0; - for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = bp->b_vnbufs.le_next) + LIST_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs) if (bp->b_flags & B_LOCKED) { a_released += numfrags(fs, bp->b_bcount); /* diff --git a/sys/ufs/lfs/lfs_segment.c b/sys/ufs/lfs/lfs_segment.c index b43a72eeecc..7a30bfb53c3 100644 --- a/sys/ufs/lfs/lfs_segment.c +++ b/sys/ufs/lfs/lfs_segment.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_segment.c,v 1.15 2006/01/20 23:27:26 miod Exp $ */ +/* $OpenBSD: lfs_segment.c,v 1.16 2006/03/05 21:48:57 miod Exp $ */ /* $NetBSD: lfs_segment.c,v 1.4 1996/02/09 22:28:54 christos Exp $ */ /* @@ -125,12 +125,12 @@ lfs_vflush(vp) ip = VTOI(vp); - if (vp->v_dirtyblkhd.lh_first == NULL) + if (LIST_EMPTY(&vp->v_dirtyblkhd)) lfs_writevnodes(fs, vp->v_mount, sp, VN_EMPTY); do { do { - if (vp->v_dirtyblkhd.lh_first != NULL) + if (!LIST_EMPTY(&vp->v_dirtyblkhd)) lfs_writefile(fs, sp, vp); } while (lfs_writeinode(fs, sp, ip)); @@ -163,16 +163,15 @@ lfs_writevnodes(fs, mp, sp, op) #define BEG_OF_VLIST ((struct vnode *)(((void *)&mp->mnt_vnodelist.lh_first) - VN_OFFSET)) /* Find last vnode. */ -loop: for (vp = mp->mnt_vnodelist.lh_first; - vp && vp->v_mntvnodes.le_next != NULL; - vp = vp->v_mntvnodes.le_next); +loop: for (vp = LIST_FIRST(&mp->mnt_vnodelist); + vp != LIST_END(&mp->mnt_vnodelist) && + LIST_NEXT(vp, v_mntvnodes) != LIST_END(&mp->mnt_vnodelist); + vp = LIST_NEXT(&vp->v_mntvnodes)); for (; vp && vp != BEG_OF_VLIST; vp = BACK_VP(vp)) { /* END HACK */ /* loop: - for (vp = mp->mnt_vnodelist.lh_first; - vp != NULL; - vp = vp->v_mntvnodes.le_next) { + LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) { */ /* * If the vnode that we are about to sync is no longer @@ -187,7 +186,7 @@ loop: continue; */ - if (op == VN_EMPTY && vp->v_dirtyblkhd.lh_first) + if (op == VN_EMPTY && !LIST_EMPTY(&vp->v_dirtyblkhd)) continue; if (vp->v_type == VNON) @@ -203,9 +202,9 @@ loop: ip = VTOI(vp); if ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE) || - vp->v_dirtyblkhd.lh_first != NULL) && + !LIST_EMPTY(&vp->v_dirtyblkhd)) && ip->i_number != LFS_IFILE_INUM) { - if (vp->v_dirtyblkhd.lh_first != NULL) + if (!LIST_EMPTY(&vp->v_dirtyblkhd)) lfs_writefile(fs, sp, vp); (void) lfs_writeinode(fs, sp, ip); } @@ -301,7 +300,7 @@ redo: vp = fs->lfs_ivnode; while (vget(vp, LK_EXCLUSIVE, p)); ip = VTOI(vp); - if (vp->v_dirtyblkhd.lh_first != NULL) + if (!LIST_EMPTY(&vp->v_dirtyblkhd)) lfs_writefile(fs, sp, vp); (void)lfs_writeinode(fs, sp, ip); vput(vp); @@ -545,10 +544,12 @@ lfs_gather(fs, sp, vp, match) #define BEG_OF_LIST ((struct buf *)(((void *)&vp->v_dirtyblkhd.lh_first) - BUF_OFFSET)) -/*loop: for (bp = vp->v_dirtyblkhd.lh_first; bp; bp = bp->b_vnbufs.le_next) {*/ +/*loop: LIST_FOREACH(bp, &vp->v_dirtyblkhd, b_vnbufs) {*/ /* Find last buffer. */ -loop: for (bp = vp->v_dirtyblkhd.lh_first; bp && bp->b_vnbufs.le_next != NULL; - bp = bp->b_vnbufs.le_next); +loop: for (bp = LIST_FIRST(&vp->v_dirtyblkhd); + bp != LIST_END(&vp->v_dirltyblkhd) && + LIST_NEXT(bp, b_vnbufs) != LIST_END(&vp->v_dirtyblkhd); + bp = LIST_NEXT(bp, b_vnbufs)); for (; bp && bp != BEG_OF_LIST; bp = BACK_BUF(bp)) { /* END HACK */ if (bp->b_flags & B_BUSY || !match(fs, bp) || diff --git a/sys/ufs/lfs/lfs_vfsops.c b/sys/ufs/lfs/lfs_vfsops.c index 51188a24ca2..047de959a4b 100644 --- a/sys/ufs/lfs/lfs_vfsops.c +++ b/sys/ufs/lfs/lfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lfs_vfsops.c,v 1.22 2005/12/28 20:48:18 pedro Exp $ */ +/* $OpenBSD: lfs_vfsops.c,v 1.23 2006/03/05 21:48:57 miod Exp $ */ /* $NetBSD: lfs_vfsops.c,v 1.11 1996/03/25 12:53:35 pk Exp $ */ /* @@ -378,7 +378,7 @@ lfs_unmount(mp, mntflags, p) fs->lfs_clean = 1; if ((error = VFS_SYNC(mp, 1, p->p_ucred, p)) != 0) return (error); - if (fs->lfs_ivnode->v_dirtyblkhd.lh_first) + if (!LIST_EMPTY(&fs->lfs_ivnode->v_dirtyblkhd)) panic("lfs_unmount: still dirty blocks on ifile vnode"); vrele(fs->lfs_ivnode); vgone(fs->lfs_ivnode); |