From ef9e85abba5ce45c8b3fc840db320edb1abe0160 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Sun, 4 Feb 2001 12:37:48 +0000 Subject: [PATCH] Use macro API. --- sys/fs/ntfs/ntfs_ihash.c | 2 +- sys/fs/unionfs/union_subr.c | 3 +-- sys/gnu/ext2fs/ext2_ihash.c | 4 ++-- sys/miscfs/union/union_subr.c | 3 +-- sys/netinet/in_var.h | 19 ++++++++----------- sys/ntfs/ntfs_ihash.c | 2 +- sys/pci/if_wx.c | 4 ++-- sys/ufs/ffs/ffs_softdep.c | 32 ++++++++++++++++---------------- sys/ufs/ufs/ufs_ihash.c | 4 ++-- 9 files changed, 34 insertions(+), 39 deletions(-) diff --git a/sys/fs/ntfs/ntfs_ihash.c b/sys/fs/ntfs/ntfs_ihash.c index a52e87c86e46..b9c0345f4181 100644 --- a/sys/fs/ntfs/ntfs_ihash.c +++ b/sys/fs/ntfs/ntfs_ihash.c @@ -94,7 +94,7 @@ ntfs_nthashlookup(dev, inum) struct ntnode *ip; mtx_enter(&ntfs_nthash_mtx, MTX_DEF); - for (ip = NTNOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) + LIST_FOREACH(ip, NTNOHASH(dev, inum), i_hash) if (inum == ip->i_number && dev == ip->i_dev) break; mtx_exit(&ntfs_nthash_mtx, MTX_DEF); diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c index 9d342819fc4f..71eae9cade52 100644 --- a/sys/fs/unionfs/union_subr.c +++ b/sys/fs/unionfs/union_subr.c @@ -397,8 +397,7 @@ union_allocvp(vpp, mp, dvp, upperdvp, cnp, uppervp, lowervp, docache) while (union_list_lock(hash)) continue; - for (un = unhead[hash].lh_first; un != 0; - un = un->un_cache.le_next) { + LIST_FOREACH(un, &unhead[hash], un_cache) { if ((un->un_lowervp == lowervp || un->un_lowervp == NULLVP) && (un->un_uppervp == uppervp || diff --git a/sys/gnu/ext2fs/ext2_ihash.c b/sys/gnu/ext2fs/ext2_ihash.c index 984db075f76e..6866a23bab31 100644 --- a/sys/gnu/ext2fs/ext2_ihash.c +++ b/sys/gnu/ext2fs/ext2_ihash.c @@ -78,7 +78,7 @@ ufs_ihashlookup(dev, inum) struct inode *ip; mtx_enter(&ufs_ihash_mtx, MTX_DEF); - for (ip = INOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) + LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) if (inum == ip->i_number && dev == ip->i_dev) break; mtx_exit(&ufs_ihash_mtx, MTX_DEF); @@ -103,7 +103,7 @@ ufs_ihashget(dev, inum) loop: mtx_enter(&ufs_ihash_mtx, MTX_DEF); - for (ip = INOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) { + LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) { if (inum == ip->i_number && dev == ip->i_dev) { vp = ITOV(ip); mtx_enter(&vp->v_interlock, MTX_DEF); diff --git a/sys/miscfs/union/union_subr.c b/sys/miscfs/union/union_subr.c index 9d342819fc4f..71eae9cade52 100644 --- a/sys/miscfs/union/union_subr.c +++ b/sys/miscfs/union/union_subr.c @@ -397,8 +397,7 @@ union_allocvp(vpp, mp, dvp, upperdvp, cnp, uppervp, lowervp, docache) while (union_list_lock(hash)) continue; - for (un = unhead[hash].lh_first; un != 0; - un = un->un_cache.le_next) { + LIST_FOREACH(un, &unhead[hash], un_cache) { if ((un->un_lowervp == lowervp || un->un_lowervp == NULLVP) && (un->un_uppervp == uppervp || diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index de2a6a6e16fc..ca2eb0763f44 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -96,15 +96,13 @@ extern u_char inetctlerrmap[]; { \ register struct in_ifaddr *ia; \ \ - for (ia = in_ifaddrhead.tqh_first; \ + for (ia = TAILQ_FIRST(&in_ifaddrhead); \ ia != NULL && ((ia->ia_ifp->if_flags & IFF_POINTOPOINT)? \ IA_DSTSIN(ia):IA_SIN(ia))->sin_addr.s_addr != (addr).s_addr; \ - ia = ia->ia_link.tqe_next) \ + ia = TAILQ_NEXT(ia, ia_link)) \ continue; \ if (ia == NULL) \ - for (ia = in_ifaddrhead.tqh_first; \ - ia != NULL; \ - ia = ia->ia_link.tqe_next) \ + TAILQ_FOREACH(ia, &in_ifaddrhead, ia_link) \ if (ia->ia_ifp->if_flags & IFF_POINTOPOINT && \ IA_SIN(ia)->sin_addr.s_addr == (addr).s_addr) \ break; \ @@ -119,9 +117,9 @@ extern u_char inetctlerrmap[]; /* struct ifnet *ifp; */ \ /* struct in_ifaddr *ia; */ \ { \ - for ((ia) = in_ifaddrhead.tqh_first; \ + for ((ia) = TAILQ_FIRST(&in_ifaddrhead); \ (ia) != NULL && (ia)->ia_ifp != (ifp); \ - (ia) = (ia)->ia_link.tqe_next) \ + (ia) = TAILQ_NEXT((ia), ia_link)) \ continue; \ } #endif @@ -184,8 +182,7 @@ struct in_multistep { do { \ register struct ifmultiaddr *ifma; \ \ - for (ifma = (ifp)->if_multiaddrs.lh_first; ifma; \ - ifma = ifma->ifma_link.le_next) { \ + LIST_FOREACH(ifma, &((ifp)->if_multiaddrs), ifma_link) { \ if (ifma->ifma_addr->sa_family == AF_INET \ && ((struct sockaddr_in *)ifma->ifma_addr)->sin_addr.s_addr == \ (addr).s_addr) \ @@ -206,14 +203,14 @@ do { \ /* struct in_multi *inm; */ \ do { \ if (((inm) = (step).i_inm) != NULL) \ - (step).i_inm = (step).i_inm->inm_link.le_next; \ + (step).i_inm = LIST_NEXT((step).i_inm, inm_link); \ } while(0) #define IN_FIRST_MULTI(step, inm) \ /* struct in_multistep step; */ \ /* struct in_multi *inm; */ \ do { \ - (step).i_inm = in_multihead.lh_first; \ + (step).i_inm = LIST_FIRST(&in_multihead); \ IN_NEXT_MULTI((step), (inm)); \ } while(0) diff --git a/sys/ntfs/ntfs_ihash.c b/sys/ntfs/ntfs_ihash.c index a52e87c86e46..b9c0345f4181 100644 --- a/sys/ntfs/ntfs_ihash.c +++ b/sys/ntfs/ntfs_ihash.c @@ -94,7 +94,7 @@ ntfs_nthashlookup(dev, inum) struct ntnode *ip; mtx_enter(&ntfs_nthash_mtx, MTX_DEF); - for (ip = NTNOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) + LIST_FOREACH(ip, NTNOHASH(dev, inum), i_hash) if (inum == ip->i_number && dev == ip->i_dev) break; mtx_exit(&ntfs_nthash_mtx, MTX_DEF); diff --git a/sys/pci/if_wx.c b/sys/pci/if_wx.c index b1151e45de1e..13160938b5ea 100644 --- a/sys/pci/if_wx.c +++ b/sys/pci/if_wx.c @@ -517,8 +517,8 @@ wx_mc_setup(sc) return (wx_init(sc)); } - for (ifma = ifp->if_multiaddrs.lh_first, sc->wx_nmca = 0; - ifma != NULL; ifma = ifma->ifma_link.le_next) { + sc->wx_nmca = 0; + LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) { if (ifma->ifma_addr->sa_family != AF_LINK) { continue; } diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 37e3bbc166da..0dab2f1109cc 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -1608,8 +1608,8 @@ setup_allocindir_phase2(bp, ip, aip) if (aip->ai_oldblkno == 0) oldaip = NULL; else - for (oldaip=LIST_FIRST(&indirdep->ir_deplisthd); - oldaip; oldaip = LIST_NEXT(oldaip, ai_next)) + + LIST_FOREACH(oldaip, &indirdep->ir_deplisthd, ai_next) if (oldaip->ai_offset == aip->ai_offset) break; freefrag = NULL; @@ -2351,8 +2351,8 @@ softdep_change_directoryentry_offset(dp, base, oldloc, newloc, entrysize) goto done; oldoffset = offset + (oldloc - base); newoffset = offset + (newloc - base); - for (dap = LIST_FIRST(&pagedep->pd_diraddhd[DIRADDHASH(oldoffset)]); - dap; dap = LIST_NEXT(dap, da_pdlist)) { + + LIST_FOREACH(dap, &pagedep->pd_diraddhd[DIRADDHASH(oldoffset)], da_pdlist) { if (dap->da_offset != oldoffset) continue; dap->da_offset = newoffset; @@ -2364,8 +2364,8 @@ softdep_change_directoryentry_offset(dp, base, oldloc, newloc, entrysize) break; } if (dap == NULL) { - for (dap = LIST_FIRST(&pagedep->pd_pendinghd); - dap; dap = LIST_NEXT(dap, da_pdlist)) { + + LIST_FOREACH(dap, &pagedep->pd_pendinghd, da_pdlist) { if (dap->da_offset == oldoffset) { dap->da_offset = newoffset; break; @@ -2531,13 +2531,13 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp) * be de-allocated. Check for an entry on both the pd_dirraddhd * list and the pd_pendinghd list. */ - for (dap = LIST_FIRST(&pagedep->pd_diraddhd[DIRADDHASH(offset)]); - dap; dap = LIST_NEXT(dap, da_pdlist)) + + LIST_FOREACH(dap, &pagedep->pd_diraddhd[DIRADDHASH(offset)], da_pdlist) if (dap->da_offset == offset) break; if (dap == NULL) { - for (dap = LIST_FIRST(&pagedep->pd_pendinghd); - dap; dap = LIST_NEXT(dap, da_pdlist)) + + LIST_FOREACH(dap, &pagedep->pd_pendinghd, da_pdlist) if (dap->da_offset == offset) break; if (dap == NULL) @@ -4045,8 +4045,8 @@ softdep_sync_metadata(ap) case D_INDIRDEP: restart: - for (aip = LIST_FIRST(&WK_INDIRDEP(wk)->ir_deplisthd); - aip; aip = LIST_NEXT(aip, ai_next)) { + + LIST_FOREACH(aip, &WK_INDIRDEP(wk)->ir_deplisthd, ai_next) { if (aip->ai_state & DEPCOMPLETE) continue; nbp = aip->ai_buf; @@ -4686,8 +4686,8 @@ softdep_count_dependencies(bp, wantcount) case D_INDIRDEP: indirdep = WK_INDIRDEP(wk); - for (aip = LIST_FIRST(&indirdep->ir_deplisthd); - aip; aip = LIST_NEXT(aip, ai_next)) { + + LIST_FOREACH(aip, &indirdep->ir_deplisthd, ai_next) { /* indirect block pointer dependency */ retval += 1; if (!wantcount) @@ -4698,8 +4698,8 @@ softdep_count_dependencies(bp, wantcount) case D_PAGEDEP: pagedep = WK_PAGEDEP(wk); for (i = 0; i < DAHASHSZ; i++) { - for (dap = LIST_FIRST(&pagedep->pd_diraddhd[i]); - dap; dap = LIST_NEXT(dap, da_pdlist)) { + + LIST_FOREACH(dap, &pagedep->pd_diraddhd[i], da_pdlist) { /* directory entry dependency */ retval += 1; if (!wantcount) diff --git a/sys/ufs/ufs/ufs_ihash.c b/sys/ufs/ufs/ufs_ihash.c index 984db075f76e..6866a23bab31 100644 --- a/sys/ufs/ufs/ufs_ihash.c +++ b/sys/ufs/ufs/ufs_ihash.c @@ -78,7 +78,7 @@ ufs_ihashlookup(dev, inum) struct inode *ip; mtx_enter(&ufs_ihash_mtx, MTX_DEF); - for (ip = INOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) + LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) if (inum == ip->i_number && dev == ip->i_dev) break; mtx_exit(&ufs_ihash_mtx, MTX_DEF); @@ -103,7 +103,7 @@ ufs_ihashget(dev, inum) loop: mtx_enter(&ufs_ihash_mtx, MTX_DEF); - for (ip = INOHASH(dev, inum)->lh_first; ip; ip = ip->i_hash.le_next) { + LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) { if (inum == ip->i_number && dev == ip->i_dev) { vp = ITOV(ip); mtx_enter(&vp->v_interlock, MTX_DEF);