diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-12-26 21:22:15 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-12-26 21:22:15 +0000 |
commit | c5af0812e5d7d60d182addc4594c42baf2e8b591 (patch) | |
tree | f3b7e8064fa2dac88f6df9c7c5bda683a4ee96fe | |
parent | fa70810cdbb843b66175fff83a47dc871a8c2780 (diff) |
Use list and queue macros where applicable to make the code easier to read;
no change in compiler assembly output.
44 files changed, 245 insertions, 270 deletions
diff --git a/sys/dev/eisa/aha1742.c b/sys/dev/eisa/aha1742.c index 8b221900e5e..62befdb058f 100644 --- a/sys/dev/eisa/aha1742.c +++ b/sys/dev/eisa/aha1742.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aha1742.c,v 1.18 2003/10/21 10:27:12 jmc Exp $ */ +/* $OpenBSD: aha1742.c,v 1.19 2004/12/26 21:22:11 miod Exp $ */ /* $NetBSD: aha1742.c,v 1.61 1996/05/12 23:40:01 mycroft Exp $ */ /* @@ -707,7 +707,7 @@ ahb_free_ecb(sc, ecb, flags) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (ecb->chain.tqe_next == 0) + if (TAILQ_NEXT(ecb, chain) == NULL) wakeup(&sc->free_ecb); splx(s); @@ -764,7 +764,7 @@ ahb_get_ecb(sc, flags) * but only if we can't allocate a new one. */ for (;;) { - ecb = sc->free_ecb.tqh_first; + ecb = TAILQ_FIRST(&sc->free_ecb); if (ecb) { TAILQ_REMOVE(&sc->free_ecb, ecb, chain); break; diff --git a/sys/dev/ic/adv.c b/sys/dev/ic/adv.c index 92d104093df..94ac96ca98d 100644 --- a/sys/dev/ic/adv.c +++ b/sys/dev/ic/adv.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adv.c,v 1.13 2004/01/09 21:32:23 brad Exp $ */ +/* $OpenBSD: adv.c,v 1.14 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: adv.c,v 1.6 1998/10/28 20:39:45 dante Exp $ */ /* @@ -140,8 +140,8 @@ adv_enqueue(sc, xs, infront) int infront; { - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) + if (infront || LIST_EMPTY(&sc->sc_queue)) { + if (LIST_EMPTY(&sc->sc_queue)) sc->sc_queuelast = xs; LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); return; @@ -160,10 +160,10 @@ adv_dequeue(sc) { struct scsi_xfer *xs; - xs = sc->sc_queue.lh_first; + xs = LIST_FIRST(&sc->sc_queue); LIST_REMOVE(xs, free_list); - if (sc->sc_queue.lh_first == NULL) + if (LIST_EMPTY(&sc->sc_queue)) sc->sc_queuelast = NULL; return (xs); @@ -266,7 +266,7 @@ adv_free_ccb(sc, ccb) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (ccb->chain.tqe_next == 0) + if (TAILQ_NEXT(ccb, chain) == NULL) wakeup(&sc->sc_free_ccb); splx(s); @@ -326,7 +326,7 @@ adv_get_ccb(sc, flags) * but only if we can't allocate a new one. */ for (;;) { - ccb = sc->sc_free_ccb.tqh_first; + ccb = TAILQ_FIRST(&sc->sc_free_ccb); if (ccb) { TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain); break; @@ -368,7 +368,7 @@ adv_start_ccbs(sc) ADV_CCB *ccb; struct scsi_xfer *xs; - while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) { + while ((ccb = TAILQ_FIRST(&sc->sc_waiting_ccb)) != NULL) { xs = ccb->xs; if (ccb->flags & CCB_WATCHDOG) @@ -651,7 +651,7 @@ adv_scsi_cmd(xs) * If we're running the queue from adv_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { + if (xs == LIST_FIRST(&sc->sc_queue)) { xs = adv_dequeue(sc); fromqueue = 1; } else { @@ -662,7 +662,7 @@ adv_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (!LIST_EMPTY(&sc->sc_queue)) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -865,7 +865,7 @@ adv_intr(arg) * NOTE: adv_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = LIST_FIRST(&sc->sc_queue)) != NULL) (void) adv_scsi_cmd(xs); return (1); diff --git a/sys/dev/ic/adw.c b/sys/dev/ic/adw.c index 40f178e45cb..f2350181f95 100644 --- a/sys/dev/ic/adw.c +++ b/sys/dev/ic/adw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: adw.c,v 1.28 2004/01/09 21:32:23 brad Exp $ */ +/* $OpenBSD: adw.c,v 1.29 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: adw.c,v 1.23 2000/05/27 18:24:50 dante Exp $ */ /* @@ -127,8 +127,8 @@ adw_enqueue(sc, xs, infront) int infront; { - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) + if (infront || LIST_EMPTY(&sc->sc_queue)) { + if (LIST_EMPTY(&sc->sc_queue)) sc->sc_queuelast = xs; LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); return; @@ -147,10 +147,10 @@ adw_dequeue(sc) { struct scsi_xfer *xs; - xs = sc->sc_queue.lh_first; + xs = LIST_FIRST(&sc->sc_queue); LIST_REMOVE(xs, free_list); - if (sc->sc_queue.lh_first == NULL) + if (LIST_EMPTY(&sc->sc_queue)) sc->sc_queuelast = NULL; return (xs); @@ -315,7 +315,7 @@ adw_free_ccb(sc, ccb) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (ccb->chain.tqe_next == 0) + if (TAILQ_NEXT(ccb, chain) == NULL) wakeup(&sc->sc_free_ccb); splx(s); @@ -385,7 +385,7 @@ adw_get_ccb(sc, flags) * but only if we can't allocate a new one. */ for (;;) { - ccb = sc->sc_free_ccb.tqh_first; + ccb = TAILQ_FIRST(&sc->sc_free_ccb); if (ccb) { TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain); break; @@ -439,7 +439,7 @@ adw_queue_ccb(sc, ccb, retry) TAILQ_INSERT_TAIL(&sc->sc_waiting_ccb, ccb, chain); } - while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) { + while ((ccb = TAILQ_FIRST(&sc->sc_waiting_ccb)) != NULL) { errcode = AdwExeScsiQueue(sc, &ccb->scsiq); switch(errcode) { @@ -663,7 +663,7 @@ adw_scsi_cmd(xs) * If we're running the queue from adw_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { + if (xs == LIST_FIRST(&sc->sc_queue)) { if(sc->sc_freeze_dev[xs->sc_link->target]) { splx(s); return (TRY_AGAIN_LATER); @@ -684,7 +684,7 @@ adw_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (!LIST_EMPTY(&sc->sc_queue)) { /* * If we can't queue, we have to abort, since * we have to preserve order. @@ -949,7 +949,7 @@ adw_intr(arg) * NOTE: adw_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = LIST_FIRST(&sc->sc_queue)) != NULL) (void) adw_scsi_cmd(xs); return (1); diff --git a/sys/dev/ic/aic6360.c b/sys/dev/ic/aic6360.c index 6e86510e761..b169cf2f62f 100644 --- a/sys/dev/ic/aic6360.c +++ b/sys/dev/ic/aic6360.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aic6360.c,v 1.7 2004/07/26 16:36:30 miod Exp $ */ +/* $OpenBSD: aic6360.c,v 1.8 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: aic6360.c,v 1.52 1996/12/10 21:27:51 thorpej Exp $ */ #ifdef DDB @@ -392,7 +392,7 @@ aic_init(sc) timeout_del(&acb->xs->stimeout); aic_done(sc, acb); } - while ((acb = sc->nexus_list.tqh_first) != NULL) { + while ((acb = TAILQ_FIRST(&sc->nexus_list)) != NULL) { acb->xs->error = XS_DRIVER_STUFFUP; timeout_del(&acb->xs->stimeout); aic_done(sc, acb); @@ -440,7 +440,7 @@ aic_free_acb(sc, acb, flags) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (acb->chain.tqe_next == 0) + if (TAILQ_NEXT(acb, chain) == NULL) wakeup(&sc->free_list); splx(s); @@ -456,7 +456,7 @@ aic_get_acb(sc, flags) s = splbio(); - while ((acb = sc->free_list.tqh_first) == NULL && + while ((acb = TAILQ_FIRST(&sc->free_list)) == NULL && (flags & SCSI_NOSLEEP) == 0) tsleep(&sc->free_list, PRIBIO, "aicacb", 0); if (acb) { @@ -688,8 +688,7 @@ aic_reselect(sc, message) */ target = ffs(selid) - 1; lun = message & 0x07; - for (acb = sc->nexus_list.tqh_first; acb != NULL; - acb = acb->chain.tqe_next) { + TAILQ_FOREACH(acb, &sc->nexus_list, chain) { sc_link = acb->xs->sc_link; if (sc_link->target == target && sc_link->lun == lun) break; @@ -754,8 +753,7 @@ aic_sched(sc) */ bus_space_write_1(iot, ioh, CLRSINT1, CLRSELTIMO | CLRBUSFREE | CLRSCSIPERR); - for (acb = sc->ready_list.tqh_first; acb != NULL; - acb = acb->chain.tqe_next) { + TAILQ_FOREACH(acb, &sc->ready_list, chain) { sc_link = acb->xs->sc_link; ti = &sc->sc_tinfo[sc_link->target]; if ((ti->lubusy & (1 << sc_link->lun)) == 0) { @@ -2112,15 +2110,13 @@ aic_print_active_acb() struct aic_softc *sc = aic_cd.cd_devs[0]; printf("ready list:\n"); - for (acb = sc->ready_list.tqh_first; acb != NULL; - acb = acb->chain.tqe_next) + TAILQ_FOREACH(acb, &sc->ready_list, chain) aic_print_acb(acb); printf("nexus:\n"); if (sc->sc_nexus != NULL) aic_print_acb(sc->sc_nexus); printf("nexus list:\n"); - for (acb = sc->nexus_list.tqh_first; acb != NULL; - acb = acb->chain.tqe_next) + TAILQ_FOREACH(acb, &sc->nexus_list, chain) aic_print_acb(acb); } diff --git a/sys/dev/ic/bha.c b/sys/dev/ic/bha.c index 877a0ac5505..473397ae24f 100644 --- a/sys/dev/ic/bha.c +++ b/sys/dev/ic/bha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bha.c,v 1.6 2003/10/21 18:58:49 jmc Exp $ */ +/* $OpenBSD: bha.c,v 1.7 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: bha.c,v 1.27 1998/11/19 21:53:00 thorpej Exp $ */ #undef BHADEBUG @@ -138,8 +138,8 @@ bha_enqueue(sc, xs, infront) int infront; { - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) + if (infront || LIST_EMPTY(&sc->sc_queue)) { + if (LIST_EMPTY(&sc->sc_queue)) sc->sc_queuelast = xs; LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); return; @@ -158,10 +158,10 @@ bha_dequeue(sc) { struct scsi_xfer *xs; - xs = sc->sc_queue.lh_first; + xs = LIST_FIRST(&sc->sc_queue); LIST_REMOVE(xs, free_list); - if (sc->sc_queue.lh_first == NULL) + if (LIST_EMPTY(&sc->sc_queue)) sc->sc_queuelast = NULL; return (xs); @@ -535,7 +535,7 @@ bha_free_ccb(sc, ccb) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (ccb->chain.tqe_next == 0) + if (TAILQ_NEXT(ccb, chain) == NULL) wakeup(&sc->sc_free_ccb); splx(s); @@ -622,7 +622,7 @@ bha_get_ccb(sc, flags) * but only if we can't allocate a new one. */ for (;;) { - ccb = sc->sc_free_ccb.tqh_first; + ccb = TAILQ_FIRST(&sc->sc_free_ccb); if (ccb) { TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain); break; @@ -720,7 +720,7 @@ bha_start_ccbs(sc) wmbo = wmbx->tmbo; - while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) { + while ((ccb = TAILQ_FIRST(&sc->sc_waiting_ccb)) != NULL) { xs = ccb->xs; if (sc->sc_mbofull >= BHA_MBX_SIZE) { @@ -857,7 +857,7 @@ bha_done(sc, ccb) * NOTE: bha_scsi_cmd() relies on our calling it with * the first entry in the queue. */ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = LIST_FIRST(&sc->sc_queue)) != NULL) (void) bha_scsi_cmd(xs); } @@ -1355,7 +1355,7 @@ bha_scsi_cmd(xs) * If we're running the queue from bha_done(), we've been * called with the first queue entry as our argument. */ - if (xs == sc->sc_queue.lh_first) { + if (xs == LIST_FIRST(&sc->sc_queue)) { xs = bha_dequeue(sc); fromqueue = 1; goto get_ccb; @@ -1367,7 +1367,7 @@ bha_scsi_cmd(xs) /* * If there are jobs in the queue, run them first. */ - if (sc->sc_queue.lh_first != NULL) { + if (!LIST_EMPTY(&sc->sc_queue)) { /* * If we can't queue, we have to abort, since * we have to preserve order. diff --git a/sys/dev/ic/dpt.c b/sys/dev/ic/dpt.c index 7de7ffd8d6d..e63c407bade 100644 --- a/sys/dev/ic/dpt.c +++ b/sys/dev/ic/dpt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dpt.c,v 1.9 2003/10/21 18:58:49 jmc Exp $ */ +/* $OpenBSD: dpt.c,v 1.10 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: dpt.c,v 1.12 1999/10/23 16:26:33 ad Exp $ */ /*- @@ -679,7 +679,7 @@ dpt_free_ccb(sc, ccb) TAILQ_INSERT_HEAD(&sc->sc_free_ccb, ccb, ccb_chain); /* Wake anybody waiting for a free ccb */ - if (ccb->ccb_chain.tqe_next == 0) + if (TAILQ_NEXT(ccb, ccb_chain) == NULL) wakeup(&sc->sc_free_ccb); splx(s); } @@ -886,7 +886,7 @@ dpt_done_ccb(sc, ccb) if ((xs = TAILQ_FIRST(&sc->sc_queue)) != NULL) #endif /* __NetBSD__ */ #ifdef __OpenBSD__ - if ((xs = sc->sc_queue.lh_first) != NULL) + if ((xs = LIST_FIRST(&sc->sc_queue)) != NULL) #endif /* __OpenBSD__ */ dpt_scsi_cmd(xs); } @@ -904,8 +904,8 @@ dpt_enqueue(sc, xs, infront) int infront; { - if (infront || sc->sc_queue.lh_first == NULL) { - if (sc->sc_queue.lh_first == NULL) + if (infront || LIST_EMPTY(&sc->sc_queue)) { + if (LIST_EMPTY(&sc->sc_queue)) sc->sc_queuelast = xs; LIST_INSERT_HEAD(&sc->sc_queue, xs, free_list); return; @@ -923,10 +923,10 @@ dpt_dequeue(sc) { struct scsi_xfer *xs; - xs = sc->sc_queue.lh_first; + xs = LIST_FIRST(&sc->sc_queue); LIST_REMOVE(xs, free_list); - if (sc->sc_queue.lh_first == NULL) + if (LIST_EMPTY(&sc->sc_queue)) sc->sc_queuelast = NULL; return (xs); @@ -985,7 +985,7 @@ dpt_scsi_cmd(xs) TAILQ_REMOVE(&sc->sc_queue, xs, adapter_q); #endif /* __NetBSD__ */ #ifdef __OpenBSD__ - if (xs == sc->sc_queue.lh_first) { + if (xs == LIST_FIRST(&sc->sc_queue)) { xs = dpt_dequeue(sc); #endif /* __OpenBSD__ */ fromqueue = 1; @@ -1022,7 +1022,7 @@ dpt_scsi_cmd(xs) if (TAILQ_FIRST(&sc->sc_queue) != NULL) { #endif /* __NetBSD__ */ #ifdef __OpenBSD__ - if (sc->sc_queue.lh_first != NULL) { + if (!LIST_EMPTY(&sc->sc_queue)) { #endif /* __OpenBSD__ */ /* * If we can't queue we abort, since we must diff --git a/sys/dev/ic/osiop.c b/sys/dev/ic/osiop.c index b35e6a04935..953b948a82d 100644 --- a/sys/dev/ic/osiop.c +++ b/sys/dev/ic/osiop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: osiop.c,v 1.21 2004/03/31 20:37:52 mickey Exp $ */ +/* $OpenBSD: osiop.c,v 1.22 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: osiop.c,v 1.9 2002/04/05 18:27:54 bouyer Exp $ */ /* @@ -549,8 +549,8 @@ osiop_sched(sc) printf("%s: osiop_sched- nexus %p/%d ready %p/%d\n", sc->sc_dev.dv_xname, sc->sc_nexus, sc->sc_nexus->xs->sc_link->target, - sc->ready_list.tqh_first, - sc->ready_list.tqh_first->xs->sc_link->target); + TAILQ_FIRST(&sc->ready_list), + TAILQ_FIRST(&sc->ready_list)->xs->sc_link->target); #endif return; } @@ -678,7 +678,7 @@ osiop_scsidone(acb, status) ~(1 << periph->lun); sc->sc_active--; OSIOP_TRACE('d', 'a', status, 0); - } else if (sc->ready_list.tqh_last == &acb->chain.tqe_next) { + } else if (sc->ready_list.tqh_last == TAILQ_NEXT(acb, chain)) { TAILQ_REMOVE(&sc->ready_list, acb, chain); OSIOP_TRACE('d', 'r', status, 0); } else { @@ -693,7 +693,7 @@ osiop_scsidone(acb, status) } } if (acb2 == NULL) { - if (acb->chain.tqe_next != NULL) { + if (TAILQ_NEXT(acb, chain) != NULL) { TAILQ_REMOVE(&sc->ready_list, acb, chain); sc->sc_active--; } else { diff --git a/sys/dev/ic/uha.c b/sys/dev/ic/uha.c index 74e10d68963..15190263336 100644 --- a/sys/dev/ic/uha.c +++ b/sys/dev/ic/uha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uha.c,v 1.4 2002/03/14 01:26:55 millert Exp $ */ +/* $OpenBSD: uha.c,v 1.5 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: uha.c,v 1.3 1996/10/13 01:37:29 christos Exp $ */ #undef UHADEBUG @@ -190,7 +190,7 @@ uha_free_mscp(sc, mscp) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (mscp->chain.tqe_next == 0) + if (TAILQ_NEXT(mscp, chain) == NULL) wakeup(&sc->sc_free_mscp); splx(s); @@ -236,7 +236,7 @@ uha_get_mscp(sc, flags) * but only if we can't allocate a new one */ for (;;) { - mscp = sc->sc_free_mscp.tqh_first; + mscp = TAILQ_FIRST(&sc->sc_free_mscp); if (mscp) { TAILQ_REMOVE(&sc->sc_free_mscp, mscp, chain); break; diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c index 35d8bb8083c..05d5d7b1ff6 100644 --- a/sys/dev/ic/vga.c +++ b/sys/dev/ic/vga.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vga.c,v 1.35 2004/12/25 23:58:14 miod Exp $ */ +/* $OpenBSD: vga.c,v 1.36 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: vga.c,v 1.28.2.1 2000/06/30 16:27:47 simonb Exp $ */ /* @@ -649,7 +649,7 @@ vga_alloc_screen(v, type, cookiep, curxp, curyp, defattrp) * for the first one too. * XXX We could be more clever and use video RAM. */ - vc->screens.lh_first->pcs.mem = + LIST_FIRST(&vc->screens)->pcs.mem = malloc(type->ncols * type->nrows * 2, M_DEVBUF, M_WAITOK); } @@ -689,7 +689,7 @@ vga_free_screen(v, cookie) * removes backing store for the last one */ if (vc->nscreens == 1) - free(vc->screens.lh_first->pcs.mem, M_DEVBUF); + free(LIST_FIRST(&vc->screens)->pcs.mem, M_DEVBUF); /* Last screen has no backing store */ if (vc->nscreens != 0) diff --git a/sys/dev/isa/aha.c b/sys/dev/isa/aha.c index 15b15b25905..7ab516489c6 100644 --- a/sys/dev/isa/aha.c +++ b/sys/dev/isa/aha.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aha.c,v 1.52 2004/11/29 06:20:02 jsg Exp $ */ +/* $OpenBSD: aha.c,v 1.53 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: aha.c,v 1.11 1996/05/12 23:51:23 mycroft Exp $ */ #undef AHADIAG @@ -599,7 +599,7 @@ aha_free_ccb(sc, ccb) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (ccb->chain.tqe_next == 0) + if (TAILQ_NEXT(ccb, chain) == NULL) wakeup(&sc->sc_free_ccb); splx(s); @@ -659,7 +659,7 @@ aha_get_ccb(sc, flags) * but only if we can't allocate a new one. */ for (;;) { - ccb = sc->sc_free_ccb.tqh_first; + ccb = TAILQ_FIRST(&sc->sc_free_ccb); if (ccb) { TAILQ_REMOVE(&sc->sc_free_ccb, ccb, chain); break; @@ -779,7 +779,7 @@ aha_start_ccbs(sc) wmbo = wmbx->tmbo; - while ((ccb = sc->sc_waiting_ccb.tqh_first) != NULL) { + while ((ccb = TAILQ_FIRST(&sc->sc_waiting_ccb)) != NULL) { if (sc->sc_mbofull >= AHA_MBX_SIZE) { aha_collect_mbo(sc); if (sc->sc_mbofull >= AHA_MBX_SIZE) { diff --git a/sys/dev/isa/ega.c b/sys/dev/isa/ega.c index bd0abd15a51..fbfc9e92075 100644 --- a/sys/dev/isa/ega.c +++ b/sys/dev/isa/ega.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ega.c,v 1.6 2004/12/26 00:01:16 miod Exp $ */ +/* $OpenBSD: ega.c,v 1.7 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: ega.c,v 1.4.4.1 2000/06/30 16:27:47 simonb Exp $ */ /* @@ -607,7 +607,7 @@ ega_alloc_screen(v, type, cookiep, curxp, curyp, defattrp) * for the first one too. * XXX We could be more clever and use video RAM. */ - vc->screens.lh_first->pcs.mem = + LIST_FIRST(&vc->screens)->pcs.mem = malloc(type->ncols * type->nrows * 2, M_DEVBUF, M_WAITOK); } @@ -645,7 +645,7 @@ ega_free_screen(v, cookie) * removes backing store for the last one */ if (vc->nscreens == 1) - free(vc->screens.lh_first->pcs.mem, M_DEVBUF); + free(LIST_FIRST(&vc->screens)->pcs.mem, M_DEVBUF); /* Last screen has no backing store */ if (vc->nscreens != 0) diff --git a/sys/dev/isa/elink.c b/sys/dev/isa/elink.c index 2ae326fba4a..d51418ff26c 100644 --- a/sys/dev/isa/elink.c +++ b/sys/dev/isa/elink.c @@ -1,4 +1,4 @@ -/* $OpenBSD: elink.c,v 1.5 1997/11/07 08:06:45 niklas Exp $ */ +/* $OpenBSD: elink.c,v 1.6 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: elink.c,v 1.9 1996/05/03 19:06:27 christos Exp $ */ /* @@ -80,8 +80,7 @@ elink_reset(iot, ioh, bus) /* * Reset these cards if we haven't done so already. */ - for (er = elink_all_resets.lh_first; er != NULL; - er = er->er_link.le_next) + LIST_FOREACH(er, &elink_all_resets, er_link) if (er->er_bus == bus) goto out; diff --git a/sys/dev/isa/fd.c b/sys/dev/isa/fd.c index 1f0d6ce9572..ea47928d7dd 100644 --- a/sys/dev/isa/fd.c +++ b/sys/dev/isa/fd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fd.c,v 1.48 2004/02/15 02:45:47 tedu Exp $ */ +/* $OpenBSD: fd.c,v 1.49 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: fd.c,v 1.90 1996/05/12 23:12:03 mycroft Exp $ */ /*- @@ -421,7 +421,7 @@ fdstart(fd) struct fd_softc *fd; { struct fdc_softc *fdc = (void *)fd->sc_dev.dv_parent; - int active = (fdc->sc_link.fdlink.sc_drives.tqh_first != NULL); + int active = !TAILQ_EMPTY(&fdc->sc_link.fdlink.sc_drives); /* Link into controller queue. */ fd->sc_q.b_active = 1; @@ -447,7 +447,7 @@ fdfinish(fd, bp) * another drive is waiting to be serviced, since there is a long motor * startup delay whenever we switch. */ - if (fd->sc_drivechain.tqe_next && ++fd->sc_ops >= 8) { + if (TAILQ_NEXT(fd, sc_drivechain) != NULL && ++fd->sc_ops >= 8) { fd->sc_ops = 0; TAILQ_REMOVE(&fdc->sc_link.fdlink.sc_drives, fd, sc_drivechain); if (bp->b_actf) { @@ -495,7 +495,7 @@ fd_set_motor(fdc, reset) u_char status; int n; - if ((fd = fdc->sc_link.fdlink.sc_drives.tqh_first) != NULL) + if ((fd = TAILQ_FIRST(&fdc->sc_link.fdlink.sc_drives)) != NULL) status = fd->sc_drive; else status = 0; @@ -531,7 +531,7 @@ fd_motor_on(arg) s = splbio(); fd->sc_flags &= ~FD_MOTOR_WAIT; - if ((fdc->sc_link.fdlink.sc_drives.tqh_first == fd) + if ((TAILQ_FIRST(&fdc->sc_link.fdlink.sc_drives) == fd) && (fdc->sc_state == MOTORWAIT)) (void) fdintr(fdc); splx(s); @@ -625,7 +625,7 @@ fdintr(fdc) loop: /* Is there a transfer to this drive? If not, deactivate drive. */ - fd = fdc->sc_link.fdlink.sc_drives.tqh_first; + fd = TAILQ_FIRST(&fdc->sc_link.fdlink.sc_drives); if (fd == NULL) { fdc->sc_state = DEVIDLE; return 1; diff --git a/sys/dev/isa/if_ep_isa.c b/sys/dev/isa/if_ep_isa.c index 1c9bc034a3f..0917638af9f 100644 --- a/sys/dev/isa/if_ep_isa.c +++ b/sys/dev/isa/if_ep_isa.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ep_isa.c,v 1.21 2004/05/12 06:35:11 tedu Exp $ */ +/* $OpenBSD: if_ep_isa.c,v 1.22 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: if_ep_isa.c,v 1.5 1996/05/12 23:52:36 mycroft Exp $ */ /* @@ -159,8 +159,7 @@ ep_isa_probe(parent, match, aux) /* * Probe this bus if we haven't done so already. */ - for (er = ep_isa_all_probes.lh_first; er != NULL; - er = er->er_link.le_next) + LIST_FOREACH(er, &ep_isa_all_probes, er_link) if (er->er_bus == parent->dv_unit) goto bus_probed; diff --git a/sys/dev/isa/if_ex.c b/sys/dev/isa/if_ex.c index a1dde5d8d90..e0dd38e58ff 100644 --- a/sys/dev/isa/if_ex.c +++ b/sys/dev/isa/if_ex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ex.c,v 1.9 2004/09/23 17:45:16 brad Exp $ */ +/* $OpenBSD: if_ex.c,v 1.10 2004/12/26 21:22:13 miod Exp $ */ /* * Copyright (c) 1997, Donald A. Schmidt * Copyright (c) 1996, Javier Martín Rueda (jmrueda@diatel.upm.es) @@ -326,7 +326,7 @@ ex_init(sc) DODEBUG(Start_End, printf("ex_init: start\n");); - if (ifp->if_addrlist.tqh_first == NULL) + if (TAILQ_EMPTY(&ifp->if_addrlist)) return; s = splimp(); sc->arpcom.ac_if.if_timer = 0; diff --git a/sys/dev/isa/seagate.c b/sys/dev/isa/seagate.c index 7a7c8143671..79b2d307ab0 100644 --- a/sys/dev/isa/seagate.c +++ b/sys/dev/isa/seagate.c @@ -1,4 +1,4 @@ -/* $OpenBSD: seagate.c,v 1.17 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: seagate.c,v 1.18 2004/12/26 21:22:13 miod Exp $ */ /* * ST01/02, Future Domain TMC-885, TMC-950 SCSI driver @@ -325,10 +325,12 @@ sea_queue_length(sea) int connected, issued, disconnected; connected = sea->nexus ? 1 : 0; - for (scb = sea->ready_list.tqh_first, issued = 0; scb; - scb = scb->chain.tqe_next, issued++); - for (scb = sea->nexus_list.tqh_first, disconnected = 0; scb; - scb = scb->chain.tqe_next, disconnected++); + issued = 0; + TAILQ_FOREACH(scb, &sea->ready_list, chain) + issued++; + disconnected = 0; + TAILQ_FOREACH(scb, &sea->nexus_list, chain) + disconnected++; printf("%s: length: %d/%d/%d\n", sea->sc_dev.dv_xname, connected, issued, disconnected); } @@ -625,7 +627,7 @@ sea_get_scb(sea, flags) * but only if we can't allocate a new one. */ for (;;) { - scb = sea->free_list.tqh_first; + scb = TAILQ_FIRST(&sea->free_list); if (scb) { TAILQ_REMOVE(&sea->free_list, scb, chain); break; @@ -702,8 +704,7 @@ loop: * Search through the ready_list for a command * destined for a target that's not busy. */ - for (scb = sea->ready_list.tqh_first; scb; - scb = scb->chain.tqe_next) { + TAILQ_FOREACH(scb, &sea->ready_list, chain) { if (!(sea->busy[scb->xs->sc_link->target] & (1 << scb->xs->sc_link->lun))) { TAILQ_REMOVE(&sea->ready_list, scb, @@ -789,7 +790,7 @@ sea_free_scb(sea, scb, flags) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (!scb->chain.tqe_next) + if (TAILQ_NEXT(scb, chain) == NULL) wakeup((caddr_t)&sea->free_list); splx(s); @@ -898,8 +899,7 @@ sea_reselect(sea) * we just reestablished, and remove it from the disconnected * queue. */ - for (scb = sea->nexus_list.tqh_first; scb; - scb = scb->chain.tqe_next) + TAILQ_FOREACH(scb, &sea->nexus_list, chain) if (target_mask == (1 << scb->xs->sc_link->target) && lun == scb->xs->sc_link->lun) { TAILQ_REMOVE(&sea->nexus_list, scb, @@ -1129,7 +1129,7 @@ sea_abort(sea, scb) * issue queue * XXX Could avoid this loop. */ - for (tmp = sea->ready_list.tqh_first; tmp; tmp = tmp->chain.tqe_next) + TAILQ_FOREACH(tmp, &sea->ready_list, chain) if (scb == tmp) { TAILQ_REMOVE(&sea->ready_list, scb, chain); /* XXX Set some type of error result for operation. */ @@ -1148,8 +1148,7 @@ sea_abort(sea, scb) * no connected commands, we reconnect the I_T_L or I_T_L_Q nexus * associated with it, go into message out, and send an abort message. */ - for (tmp = sea->nexus_list.tqh_first; tmp; - tmp = tmp->chain.tqe_next) + TAILQ_FOREACH(tmp, &sea->nexus_list, chain) if (scb == tmp) { if (sea_select(sea, scb)) return 0; @@ -1161,8 +1160,7 @@ sea_abort(sea, scb) CONTROL = BASE_CMD | CMD_ATTN; sea_transfer_pio(sea, &phase, &len, &msgptr); - for (tmp = sea->nexus_list.tqh_first; tmp; - tmp = tmp->chain.tqe_next) + TAILQ_FOREACH(tmp, &sea->nexus_list, chain) if (scb == tmp) { TAILQ_REMOVE(&sea->nexus_list, scb, chain); diff --git a/sys/dev/isa/wds.c b/sys/dev/isa/wds.c index 5ee674d3fd8..69a4ac48efa 100644 --- a/sys/dev/isa/wds.c +++ b/sys/dev/isa/wds.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wds.c,v 1.18 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: wds.c,v 1.19 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: wds.c,v 1.13 1996/11/03 16:20:31 mycroft Exp $ */ #undef WDSDIAG @@ -469,7 +469,7 @@ wds_free_scb(sc, scb) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (scb->chain.tqe_next == 0) + if (TAILQ_NEXT(scb, chain) == NULL) wakeup(&sc->sc_free_scb); splx(s); @@ -491,7 +491,7 @@ wds_free_buf(sc, buf) * If there were none, wake anybody waiting for one to come free, * starting with queued entries. */ - if (buf->chain.tqe_next == 0) + if (TAILQ_NEXT(buf, chain) == NULL) wakeup(&wds_free_buffer); splx(s); @@ -548,7 +548,7 @@ wds_get_scb(sc, flags, needbuffer) * but only if we can't allocate a new one. */ for (;;) { - scb = sc->sc_free_scb.tqh_first; + scb = TAILQ_FIRST(&sc->sc_free_scb); if (scb) { TAILQ_REMOVE(&sc->sc_free_scb, scb, chain); break; @@ -610,7 +610,7 @@ wds_get_buf(sc, flags) s = splbio(); for (;;) { - buf = wds_free_buffer.tqh_first; + buf = TAILQ_FIRST(&wds_free_buffer); if (buf) { TAILQ_REMOVE(&wds_free_buffer, buf, chain); break; @@ -702,7 +702,7 @@ wds_start_scbs(sc) wmbo = wmbx->tmbo; - while ((scb = sc->sc_waiting_scb.tqh_first) != NULL) { + while ((scb = TAILQ_FIRST(&sc->sc_waiting_scb)) != NULL) { if (sc->sc_mbofull >= WDS_MBX_SIZE) { wds_collect_mbo(sc); if (sc->sc_mbofull >= WDS_MBX_SIZE) { diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 7b13c6c32c0..3d2f5de24a1 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.121 2004/11/28 02:11:33 deraadt Exp $ */ +/* $OpenBSD: init_main.c,v 1.122 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -439,7 +439,7 @@ main(framep) CIRCLEQ_FIRST(&mountlist)->mnt_flag |= MNT_ROOTFS; /* Get the vnode for '/'. Set p->p_fd->fd_cdir to reference it. */ - if (VFS_ROOT(mountlist.cqh_first, &rootvnode)) + if (VFS_ROOT(CIRCLEQ_FIRST(&mountlist), &rootvnode)) panic("cannot find root vnode"); p->p_fd->fd_cdir = rootvnode; VREF(p->p_fd->fd_cdir); diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c index a57f4c3db60..8664f92be3e 100644 --- a/sys/kern/kern_exit.c +++ b/sys/kern/kern_exit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_exit.c,v 1.53 2004/08/04 21:49:19 art Exp $ */ +/* $OpenBSD: kern_exit.c,v 1.54 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: kern_exit.c,v 1.39 1996/04/22 01:38:25 christos Exp $ */ /* @@ -207,11 +207,11 @@ exit1(p, rv) /* * Give orphaned children to init(8). */ - q = p->p_children.lh_first; + q = LIST_FIRST(&p->p_children); if (q) /* only need this if any child is S_ZOMB */ wakeup(initproc); for (; q != 0; q = nq) { - nq = q->p_sibling.le_next; + nq = LIST_NEXT(q, p_sibling); proc_reparent(q, initproc); /* * Traced processes are killed @@ -255,7 +255,7 @@ exit1(p, rv) * parent, so in case he was wait(2)ing, he will * continue. */ - if (pp->p_children.lh_first == NULL) + if (LIST_EMPTY(&pp->p_children)) wakeup(pp); } @@ -426,7 +426,7 @@ sys_wait4(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 ((p->p_flag & P_NOZOMBIE) || (SCARG(uap, pid) != WAIT_ANY && p->p_pid != SCARG(uap, pid) && diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c index efb904c589a..defedd7de90 100644 --- a/sys/kern/kern_ktrace.c +++ b/sys/kern/kern_ktrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_ktrace.c,v 1.33 2004/06/13 21:49:26 niklas Exp $ */ +/* $OpenBSD: kern_ktrace.c,v 1.34 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: kern_ktrace.c,v 1.23 1996/02/09 18:59:36 christos Exp $ */ /* @@ -370,7 +370,7 @@ sys_ktrace(curp, v, retval) error = ESRCH; goto done; } - for (p = pg->pg_members.lh_first; p != 0; p = p->p_pglist.le_next) + LIST_FOREACH(p, &pg->pg_members, p_pglist) if (descend) ret |= ktrsetchildren(curp, p, ops, facs, vp); else @@ -449,13 +449,13 @@ ktrsetchildren(curp, top, ops, facs, vp) * otherwise do any siblings, and if done with this level, * follow back up the tree (but not past top). */ - if (p->p_children.lh_first) - p = p->p_children.lh_first; + if (!LIST_EMPTY(&p->p_children)) + p = LIST_FIRST(&p->p_children); else for (;;) { if (p == top) return (ret); - if (p->p_sibling.le_next) { - p = p->p_sibling.le_next; + if (LIST_NEXT(p, p_sibling) != NULL) { + p = LIST_NEXT(p, p_sibling); break; } p = p->p_pptr; diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index cccc4f6170b..962fe11dea4 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_proc.c,v 1.23 2004/11/18 15:10:24 markus Exp $ */ +/* $OpenBSD: kern_proc.c,v 1.24 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */ /* @@ -124,7 +124,7 @@ chgproccnt(uid, diff) register struct uihashhead *uipp; uipp = UIHASH(uid); - for (uip = uipp->lh_first; uip != 0; uip = uip->ui_hash.le_next) + LIST_FOREACH(uip, uipp, ui_hash) if (uip->ui_uid == uid) break; if (uip) { @@ -172,7 +172,7 @@ pfind(pid) { register struct proc *p; - for (p = PIDHASH(pid)->lh_first; p != 0; p = p->p_hash.le_next) + LIST_FOREACH(p, PIDHASH(pid), p_hash) if (p->p_pid == pid) return (p); return (NULL); @@ -187,7 +187,7 @@ pgfind(pgid) { register struct pgrp *pgrp; - for (pgrp = PGRPHASH(pgid)->lh_first; pgrp != 0; pgrp = pgrp->pg_hash.le_next) + LIST_FOREACH(pgrp, PGRPHASH(pgid), pg_hash) if (pgrp->pg_id == pgid) return (pgrp); return (NULL); @@ -262,7 +262,7 @@ enterpgrp(p, pgid, mksess) fixjobc(p, p->p_pgrp, 0); LIST_REMOVE(p, p_pglist); - if (p->p_pgrp->pg_members.lh_first == 0) + if (LIST_EMPTY(&p->p_pgrp->pg_members)) pgdelete(p->p_pgrp); p->p_pgrp = pgrp; LIST_INSERT_HEAD(&pgrp->pg_members, p, p_pglist); @@ -278,7 +278,7 @@ leavepgrp(p) { LIST_REMOVE(p, p_pglist); - if (p->p_pgrp->pg_members.lh_first == 0) + if (LIST_EMPTY(&p->p_pgrp->pg_members)) pgdelete(p->p_pgrp); p->p_pgrp = 0; return (0); @@ -336,7 +336,7 @@ fixjobc(p, pgrp, entering) * their process groups; if so, adjust counts for children's * process groups. */ - for (p = p->p_children.lh_first; p != 0; p = p->p_sibling.le_next) + LIST_FOREACH(p, &p->p_children, p_sibling) if ((hispgrp = p->p_pgrp) != pgrp && hispgrp->pg_session == mysession && P_ZOMBIE(p) == 0) { @@ -358,10 +358,9 @@ orphanpg(pg) { register struct proc *p; - for (p = pg->pg_members.lh_first; p != 0; p = p->p_pglist.le_next) { + LIST_FOREACH(p, &pg->pg_members, p_pglist) { if (p->p_stat == SSTOP) { - for (p = pg->pg_members.lh_first; p != 0; - p = p->p_pglist.le_next) { + LIST_FOREACH(p, &pg->pg_members, p_pglist) { psignal(p, SIGHUP); psignal(p, SIGCONT); } @@ -497,15 +496,14 @@ pgrpdump() register int i; for (i = 0; i <= pgrphash; i++) { - if ((pgrp = pgrphashtbl[i].lh_first) != NULL) { + if (!LIST_EMPTY(&pgrphashtbl[i])) { printf("\tindx %d\n", i); - for (; pgrp != 0; pgrp = pgrp->pg_hash.le_next) { + LIST_FOREACH(pgrp, &pgrphashtbl[i], pg_hash) { printf("\tpgrp %p, pgid %d, sess %p, sesscnt %d, mem %p\n", pgrp, pgrp->pg_id, pgrp->pg_session, pgrp->pg_session->s_count, - pgrp->pg_members.lh_first); - for (p = pgrp->pg_members.lh_first; p != 0; - p = p->p_pglist.le_next) { + LIST_FIRST(&pgrp->pg_members)); + LIST_FOREACH(p, &pgrp->pg_members, p_pglist) { printf("\t\tpid %d addr %p pgrp %p\n", p->p_pid, p, p->p_pgrp); } diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c index 6d7af1fd136..3d5759bad59 100644 --- a/sys/kern/kern_resource.c +++ b/sys/kern/kern_resource.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_resource.c,v 1.27 2004/06/13 21:49:26 niklas Exp $ */ +/* $OpenBSD: kern_resource.c,v 1.28 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: kern_resource.c,v 1.38 1996/10/23 07:19:38 matthias Exp $ */ /*- @@ -93,7 +93,7 @@ sys_getpriority(curp, v, retval) pg = curp->p_pgrp; else if ((pg = pgfind(SCARG(uap, who))) == NULL) break; - for (p = pg->pg_members.lh_first; p != 0; p = p->p_pglist.le_next) { + LIST_FOREACH(p, &pg->pg_members, p_pglist) { if (p->p_nice < low) low = p->p_nice; } @@ -153,8 +153,7 @@ sys_setpriority(curp, v, retval) pg = curp->p_pgrp; else if ((pg = pgfind(SCARG(uap, who))) == NULL) break; - for (p = pg->pg_members.lh_first; p != 0; - p = p->p_pglist.le_next) { + LIST_FOREACH(p, &pg->pg_members, p_pglist) { error = donice(curp, p, SCARG(uap, prio)); found++; } diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 7ca9269bd1d..7a0142d92dc 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sig.c,v 1.72 2004/07/04 13:35:01 niklas Exp $ */ +/* $OpenBSD: kern_sig.c,v 1.73 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */ /* @@ -665,7 +665,7 @@ killpg1(cp, signum, pgid, all) if (pgrp == NULL) return (ESRCH); } - for (p = pgrp->pg_members.lh_first; p != 0; p = p->p_pglist.le_next) { + LIST_FOREACH(p, &pgrp->pg_members, p_pglist) { if (p->p_pid <= 1 || p->p_flag & P_SYSTEM || !cansignal(cp, pc, p, signum)) continue; @@ -705,8 +705,7 @@ csignal(pgid, signum, uid, euid) pgid = -pgid; if ((pgrp = pgfind(pgid)) == NULL) return; - for (p = pgrp->pg_members.lh_first; p; - p = p->p_pglist.le_next) + LIST_FOREACH(p, &pgrp->pg_members, p_pglist) if (CANDELIVER(uid, euid, p)) psignal(p, signum); } else { @@ -742,7 +741,7 @@ pgsignal(pgrp, signum, checkctty) register struct proc *p; if (pgrp) - for (p = pgrp->pg_members.lh_first; p != 0; p = p->p_pglist.le_next) + LIST_FOREACH(p, &pgrp->pg_members, p_pglist) if (checkctty == 0 || p->p_flag & P_CONTROLT) psignal(p, signum); } diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c index 9cb03dbf82d..337530d00a5 100644 --- a/sys/kern/subr_autoconf.c +++ b/sys/kern/subr_autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_autoconf.c,v 1.39 2004/11/23 19:08:55 miod Exp $ */ +/* $OpenBSD: subr_autoconf.c,v 1.40 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */ /* @@ -195,7 +195,7 @@ config_search(fn, parent, aux) m.aux = aux; m.indirect = parent && parent->dv_cfdata->cf_driver->cd_indirect; m.pri = 0; - for(t = allcftables.tqh_first; t; t = t->list.tqe_next) { + TAILQ_FOREACH(t, &allcftables, list) { for (cf = t->tab; cf->cf_driver; cf++) { /* * Skip cf if no longer eligible, otherwise scan @@ -246,7 +246,7 @@ config_scan(fn, parent) struct cftable *t; indirect = parent && parent->dv_cfdata->cf_driver->cd_indirect; - for (t = allcftables.tqh_first; t; t = t->list.tqe_next) { + TAILQ_FOREACH(t, &allcftables, list) { for (cf = t->tab; cf->cf_driver; cf++) { /* * Skip cf if no longer eligible, otherwise scan @@ -399,7 +399,7 @@ config_attach(parent, match, aux, print) * otherwise identical, or bump the unit number on all starred * cfdata for this device. */ - for (t = allcftables.tqh_first; t; t = t->list.tqe_next) { + TAILQ_FOREACH(t, &allcftables, list) { for (cf = t->tab; cf->cf_driver; cf++) if (cf->cf_driver == cd && cf->cf_unit == dev->dv_unit) { diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index c406946a460..985f430beb3 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_disk.c,v 1.28 2004/11/01 03:43:24 pedro Exp $ */ +/* $OpenBSD: subr_disk.c,v 1.29 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */ /* @@ -257,8 +257,7 @@ disk_find(name) if ((name == NULL) || (disk_count <= 0)) return (NULL); - for (diskp = disklist.tqh_first; diskp != NULL; - diskp = diskp->dk_link.tqe_next) + TAILQ_FOREACH(diskp, &disklist, dk_link) if (strcmp(diskp->dk_name, name) == 0) return (diskp); diff --git a/sys/kern/subr_extent.c b/sys/kern/subr_extent.c index 7d4d48b4da8..78fc592919e 100644 --- a/sys/kern/subr_extent.c +++ b/sys/kern/subr_extent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_extent.c,v 1.25 2002/12/08 08:18:37 deraadt Exp $ */ +/* $OpenBSD: subr_extent.c,v 1.26 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: subr_extent.c,v 1.7 1996/11/21 18:46:34 cgd Exp $ */ /*- @@ -266,9 +266,10 @@ extent_destroy(ex) #endif /* Free all region descriptors in extent. */ - for (rp = ex->ex_regions.lh_first; rp != NULL; ) { + for (rp = LIST_FIRST(&ex->ex_regions); + rp != LIST_END(&ex->ex_regions); ) { orp = rp; - rp = rp->er_link.le_next; + rp = LIST_NEXT(rp, er_link); LIST_REMOVE(orp, er_link); extent_free_region_descriptor(ex, orp); } @@ -305,12 +306,12 @@ extent_insert_and_optimize(ex, start, size, flags, after, rp) * descriptor overhead. */ if (((ex->ex_flags & EXF_NOCOALESCE) == 0) && - (ex->ex_regions.lh_first != NULL) && - ((start + size) == ex->ex_regions.lh_first->er_start)) { + !LIST_EMPTY(&ex->ex_regions) && + ((start + size) == LIST_FIRST(&ex->ex_regions)->er_start)) { /* * We can coalesce. Prepend us to the first region. */ - ex->ex_regions.lh_first->er_start = start; + LIST_FIRST(&ex->ex_regions)->er_start = start; extent_free_region_descriptor(ex, rp); return; } @@ -346,8 +347,8 @@ extent_insert_and_optimize(ex, start, size, flags, after, rp) /* * Attempt to coalesce with the region after us. */ - if ((after->er_link.le_next != NULL) && - ((start + size) == after->er_link.le_next->er_start)) { + if (LIST_NEXT(after, er_link) != NULL && + ((start + size) == LIST_NEXT(after, er_link)->er_start)) { /* * We can coalesce. Note that if we appended ourselves * to the previous region, we exactly fit the gap, and @@ -357,15 +358,15 @@ extent_insert_and_optimize(ex, start, size, flags, after, rp) /* * Yup, we can free it up. */ - after->er_end = after->er_link.le_next->er_end; - nextr = after->er_link.le_next; + after->er_end = LIST_NEXT(after, er_link)->er_end; + nextr = LIST_NEXT(after, er_link); LIST_REMOVE(nextr, er_link); extent_free_region_descriptor(ex, nextr); } else { /* * Nope, just prepend us to the next region. */ - after->er_link.le_next->er_start = start; + LIST_NEXT(after, er_link)->er_start = start; } extent_free_region_descriptor(ex, rp); @@ -469,8 +470,7 @@ extent_alloc_region(ex, start, size, flags) */ last = NULL; - for (rp = ex->ex_regions.lh_first; rp != NULL; - rp = rp->er_link.le_next) { + LIST_FOREACH(rp, &ex->ex_regions, er_link) { if (rp->er_start > end) { /* * We lie before this region and don't @@ -643,8 +643,7 @@ extent_alloc_subregion(ex, substart, subend, size, alignment, skew, boundary, * the subregion start, advancing the "last" pointer along * the way. */ - for (rp = ex->ex_regions.lh_first; rp != NULL; - rp = rp->er_link.le_next) { + LIST_FOREACH(rp, &ex->ex_regions, er_link) { if (rp->er_start >= newstart) break; last = rp; @@ -658,7 +657,7 @@ extent_alloc_subregion(ex, substart, subend, size, alignment, skew, boundary, if (last != NULL && last->er_end >= newstart) newstart = EXTENT_ALIGN((last->er_end + 1), alignment, skew); - for (; rp != NULL; rp = rp->er_link.le_next) { + for (; rp != LIST_END(&ex->ex_regions); rp = LIST_NEXT(rp, er_link)) { /* * If the region pasts the subend, bail out and see * if we fit against the subend. @@ -950,8 +949,7 @@ extent_free(ex, start, size, flags) * Cases 2, 3, and 4 require that the EXF_NOCOALESCE flag * is not set. */ - for (rp = ex->ex_regions.lh_first; rp != NULL; - rp = rp->er_link.le_next) { + LIST_FOREACH(rp, &ex->ex_regions, er_link) { /* * Save ourselves some comparisons; does the current * region end before chunk to be freed begins? If so, @@ -1041,7 +1039,7 @@ extent_alloc_region_descriptor(ex, flags) if (ex->ex_flags & EXF_FIXED) { struct extent_fixed *fex = (struct extent_fixed *)ex; - while (fex->fex_freelist.lh_first == NULL) { + while (LIST_EMPTY(&fex->fex_freelist)) { if (flags & EX_MALLOCOK) goto alloc; @@ -1053,7 +1051,7 @@ extent_alloc_region_descriptor(ex, flags) "extnt", 0)) return (NULL); } - rp = fex->fex_freelist.lh_first; + rp = LIST_FIRST(&fex->fex_freelist); LIST_REMOVE(rp, er_link); /* @@ -1142,8 +1140,7 @@ extent_print(ex) db_printf("extent `%s' (0x%lx - 0x%lx), flags=%b\n", ex->ex_name, ex->ex_start, ex->ex_end, ex->ex_flags, EXF_BITS); - for (rp = ex->ex_regions.lh_first; rp != NULL; - rp = rp->er_link.le_next) + LIST_FOREACH(rp, &ex->ex_regions, er_link) db_printf(" 0x%lx - 0x%lx\n", rp->er_start, rp->er_end); } #endif diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 4af17dea526..7542b035602 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.67 2004/11/18 15:10:24 markus Exp $ */ +/* $OpenBSD: tty.c,v 1.68 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -2089,11 +2089,11 @@ ttyinfo(tp) ttyprintf(tp, "not a controlling terminal\n"); else if (tp->t_pgrp == NULL) ttyprintf(tp, "no foreground process group\n"); - else if ((p = tp->t_pgrp->pg_members.lh_first) == 0) + else if ((p = LIST_FIRST(&tp->t_pgrp->pg_members)) == NULL) ttyprintf(tp, "empty foreground process group\n"); else { /* Pick interesting process. */ - for (pick = NULL; p != 0; p = p->p_pglist.le_next) + for (pick = NULL; p != 0; p = LIST_NEXT(p, p_pglist)) if (proc_compare(pick, p)) pick = p; diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 63ccd7eab52..ae1c7300bb5 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_bio.c,v 1.74 2004/12/11 14:26:31 pedro Exp $ */ +/* $OpenBSD: vfs_bio.c,v 1.75 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: vfs_bio.c,v 1.44 1996/06/11 11:15:36 pk Exp $ */ /*- @@ -143,9 +143,9 @@ bremfree(struct buf *bp) * * NB: This makes an assumption about how tailq's are implemented. */ - if (bp->b_freelist.tqe_next == NULL) { + if (TAILQ_NEXT(bp, b_freelist) == NULL) { for (dp = bufqueues; dp < &bufqueues[BQUEUES]; dp++) - if (dp->tqh_last == &bp->b_freelist.tqe_next) + if (dp->tqh_last == &TAILQ_NEXT(bp, b_freelist)) break; if (dp == &bufqueues[BQUEUES]) panic("bremfree: lost tail"); @@ -739,7 +739,7 @@ allocbuf(struct buf *bp, int size) */ if (bp->b_bufsize > desired_size) { s = splbio(); - if ((nbp = bufqueues[BQ_EMPTY].tqh_first) == NULL) { + if ((nbp = TAILQ_FIRST(&bufqueues[BQ_EMPTY])) == NULL) { /* No free buffer head */ splx(s); goto out; @@ -1009,7 +1009,7 @@ vfs_bufstats() pages = 0; for (j = 0; j <= MAXBSIZE/PAGE_SIZE; j++) counts[j] = 0; - for (bp = dp->tqh_first; bp; bp = bp->b_freelist.tqe_next) { + TAILQ_FOREACH(bp, dp, b_freelist) { counts[bp->b_bufsize/PAGE_SIZE]++; count++; pages += btoc(bp->b_bufsize); diff --git a/sys/kern/vfs_cache.c b/sys/kern/vfs_cache.c index 1e5fb1924ee..68c979d5a53 100644 --- a/sys/kern/vfs_cache.c +++ b/sys/kern/vfs_cache.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_cache.c,v 1.12 2004/10/04 12:03:45 pedro Exp $ */ +/* $OpenBSD: vfs_cache.c,v 1.13 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: vfs_cache.c,v 1.13 1996/02/04 02:18:09 christos Exp $ */ /* @@ -270,7 +270,7 @@ cache_enter(dvp, vp, cnp) ncp = pool_get(&nch_pool, PR_WAITOK); bzero((char *)ncp, sizeof *ncp); numcache++; - } else if ((ncp = nclruhead.tqh_first) != NULL) { + } else if ((ncp = TAILQ_FIRST(&nclruhead)) != NULL) { TAILQ_REMOVE(&nclruhead, ncp, nc_lru); if (ncp->nc_hash.le_prev != 0) { LIST_REMOVE(ncp, nc_hash); @@ -328,7 +328,7 @@ cache_purge(vp) if (nextvnodeid != 0) return; for (ncpp = &nchashtbl[nchash]; ncpp >= nchashtbl; ncpp--) { - for (ncp = ncpp->lh_first; ncp != 0; ncp = ncp->nc_hash.le_next) { + LIST_FOREACH(ncp, ncpp, nc_hash) { ncp->nc_vpid = 0; ncp->nc_dvpid = 0; } @@ -350,9 +350,10 @@ cache_purgevfs(mp) { register struct namecache *ncp, *nxtcp; - for (ncp = nclruhead.tqh_first; ncp != 0; ncp = nxtcp) { + for (ncp = TAILQ_FIRST(&nclruhead); ncp != TAILQ_END(&nclruhead); + ncp = nxtcp) { if (ncp->nc_dvp == NULL || ncp->nc_dvp->v_mount != mp) { - nxtcp = ncp->nc_lru.tqe_next; + nxtcp = TAILQ_NEXT(ncp, nc_lru); continue; } /* free the resources we had */ @@ -364,7 +365,7 @@ cache_purgevfs(mp) ncp->nc_hash.le_prev = 0; } /* cause rescan of list, it may have altered */ - nxtcp = nclruhead.tqh_first; + nxtcp = TAILQ_FIRST(&nclruhead); TAILQ_INSERT_HEAD(&nclruhead, ncp, nc_lru); } } diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index c7673241ea5..6c3a726ad5a 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_subr.c,v 1.104 2004/12/09 22:36:40 pedro Exp $ */ +/* $OpenBSD: vfs_subr.c,v 1.105 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */ /* @@ -889,10 +889,10 @@ vfs_mount_foreach_vnode(struct mount *mp, simple_lock(&mntvnode_slock); loop: - for (vp = mp->mnt_vnodelist.lh_first; vp; vp = nvp) { + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) { if (vp->v_mount != mp) goto loop; - nvp = vp->v_mntvnodes.le_next; + nvp = LIST_NEXT(vp, v_mntvnodes); simple_lock(&vp->v_interlock); simple_unlock(&mntvnode_slock); @@ -1361,8 +1361,7 @@ printlockedvnodes() nmp = CIRCLEQ_NEXT(mp, mnt_list); continue; } - for (vp = mp->mnt_vnodelist.lh_first; vp; - vp = vp->v_mntvnodes.le_next) { + LIST_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes) { if (VOP_ISLOCKED(vp)) vprint((char *)0, vp); } @@ -1454,7 +1453,7 @@ sysctl_vnode(where, sizep, p) } savebp = bp; again: - for (vp = mp->mnt_vnodelist.lh_first; vp != NULL; + for (vp = LIST_FIRST(&mp->mnt_vnodelist); vp != NULL; vp = nvp) { /* * Check that the vp is still associated with @@ -1468,7 +1467,7 @@ again: bp = savebp; goto again; } - nvp = vp->v_mntvnodes.le_next; + nvp = LIST_NEXT(vp, v_mntvnodes); if (bp + sizeof(struct e_vnode) > ewhere) { simple_unlock(&mntvnode_slock); *sizep = bp - where; @@ -1993,13 +1992,13 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) if (flags & V_SAVE) { s = splbio(); vwaitforio(vp, 0, "vinvalbuf", 0); - if (vp->v_dirtyblkhd.lh_first != NULL) { + if (!LIST_EMPTY(&vp->v_dirtyblkhd)) { splx(s); if ((error = VOP_FSYNC(vp, cred, MNT_WAIT, p)) != 0) return (error); s = splbio(); if (vp->v_numoutput > 0 || - vp->v_dirtyblkhd.lh_first != NULL) + !LIST_EMPTY(&vp->v_dirtyblkhd)) panic("vinvalbuf: dirty bufs"); } splx(s); @@ -2007,14 +2006,15 @@ vinvalbuf(vp, flags, cred, p, slpflag, slptimeo) loop: s = splbio(); for (;;) { - if ((blist = vp->v_cleanblkhd.lh_first) && + if ((blist = LIST_FIRST(&vp->v_cleanblkhd)) && (flags & V_SAVEMETA)) while (blist && blist->b_lblkno < 0) - blist = blist->b_vnbufs.le_next; - if (!blist && (blist = vp->v_dirtyblkhd.lh_first) && + blist = LIST_NEXT(blist, b_vnbufs); + if (blist == NULL && + (blist = LIST_FIRST(&vp->v_cleanblkhd)) && (flags & V_SAVEMETA)) while (blist && blist->b_lblkno < 0) - blist = blist->b_vnbufs.le_next; + blist = LIST_NEXT(blist, b_vnbufs); if (!blist) break; @@ -2049,7 +2049,7 @@ loop: } } if (!(flags & V_SAVEMETA) && - (vp->v_dirtyblkhd.lh_first || vp->v_cleanblkhd.lh_first)) + (!LIST_EMPTY(&vp->v_dirtyblkhd) || !LIST_EMPTY(&vp->v_cleanblkhd))) panic("vinvalbuf: flush failed"); splx(s); return (0); @@ -2065,8 +2065,9 @@ vflushbuf(vp, sync) 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) @@ -2089,7 +2090,7 @@ loop: return; } vwaitforio(vp, 0, "vflushbuf", 0); - if (vp->v_dirtyblkhd.lh_first != NULL) { + if (!LIST_EMPTY(&vp->v_dirtyblkhd)) { splx(s); vprint("vflushbuf: dirty", vp); goto loop; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index e142295b8ec..893e22d1393 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.118 2004/09/16 10:37:41 pedro Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.119 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -467,7 +467,7 @@ dounmount(struct mount *mp, int flags, struct proc *p, struct vnode *olddp) vrele(coveredvp); } mp->mnt_vfc->vfc_refcount--; - if (mp->mnt_vnodelist.lh_first != NULL) + if (!LIST_EMPTY(&mp->mnt_vnodelist)) panic("unmount: dangling vnode"); lockmgr(&mp->mnt_lock, LK_RELEASE | LK_INTERLOCK, &mountlist_slock, p); free(mp, M_MOUNT); diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c index 07f3e753607..89a89c03c79 100644 --- a/sys/msdosfs/msdosfs_vfsops.c +++ b/sys/msdosfs/msdosfs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: msdosfs_vfsops.c,v 1.34 2004/05/14 04:05:05 tedu Exp $ */ +/* $OpenBSD: msdosfs_vfsops.c,v 1.35 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: msdosfs_vfsops.c,v 1.48 1997/10/18 02:54:57 briggs Exp $ */ /*- @@ -723,7 +723,7 @@ msdosfs_sync_vnode(struct vnode *vp, void *arg) dep = VTODE(vp); if (vp->v_type == VNON || ((dep->de_flag & (DE_ACCESS | DE_CREATE | DE_UPDATE | DE_MODIFIED)) == 0 - && vp->v_dirtyblkhd.lh_first == NULL) || + && LIST_EMPTY(&vp->v_dirtyblkhd)) || msa->waitfor == MNT_LAZY) { simple_unlock(&vp->v_interlock); return (0); diff --git a/sys/nfs/nfs_node.c b/sys/nfs/nfs_node.c index 026ec6149c1..4378ad6aa2e 100644 --- a/sys/nfs/nfs_node.c +++ b/sys/nfs/nfs_node.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_node.c,v 1.27 2004/08/03 17:11:48 marius Exp $ */ +/* $OpenBSD: nfs_node.c,v 1.28 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: nfs_node.c,v 1.16 1996/02/18 11:53:42 fvdl Exp $ */ /* @@ -221,7 +221,7 @@ nfs_reclaim(v) dp = LIST_FIRST(&np->n_cookies); while (dp) { dp2 = dp; - dp = dp->ndm_list.le_next; + dp = LIST_NEXT(dp, ndm_list); FREE((caddr_t)dp2, M_NFSDIROFF); } } diff --git a/sys/nfs/nfs_socket.c b/sys/nfs/nfs_socket.c index 059d82f748e..794a37c07c8 100644 --- a/sys/nfs/nfs_socket.c +++ b/sys/nfs/nfs_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_socket.c,v 1.40 2004/12/10 19:55:21 millert Exp $ */ +/* $OpenBSD: nfs_socket.c,v 1.41 2004/12/26 21:22:13 miod Exp $ */ /* $NetBSD: nfs_socket.c,v 1.27 1996/04/15 20:20:00 thorpej Exp $ */ /* @@ -1140,8 +1140,8 @@ nfs_rephead(siz, nd, slp, err, frev, mrq, mbp, bposp) struct nfsuid *nuidp; struct timeval ktvin, ktvout; - for (nuidp = NUIDHASH(slp, nd->nd_cr.cr_uid)->lh_first; - nuidp != NULL; nuidp = LIST_NEXT(nuidp, nu_hash)) { + LIST_FOREACH(nuidp, NUIDHASH(slp, nd->nd_cr.cr_uid), + nu_hash) { if (nuidp->nu_cr.cr_uid == nd->nd_cr.cr_uid && (!nd->nd_nam2 || netaddr_match(NU_NETFAM(nuidp), &nuidp->nu_haddr, nd->nd_nam2))) @@ -1664,8 +1664,8 @@ nfs_getreq(nd, nfsd, has_header) tvin.tv_sec = *tl++; tvin.tv_usec = *tl; - for (nuidp = NUIDHASH(nfsd->nfsd_slp,nickuid)->lh_first; - nuidp != NULL; nuidp = LIST_NEXT(nuidp, nu_hash)) { + LIST_FOREACH(nuidp, NUIDHASH(nfsd->nfsd_slp, nickuid), + nu_hash) { if (nuidp->nu_cr.cr_uid == nickuid && (!nd->nd_nam2 || netaddr_match(NU_NETFAM(nuidp), diff --git a/sys/nfs/nfs_srvcache.c b/sys/nfs/nfs_srvcache.c index 7ee149aa29b..1685554c399 100644 --- a/sys/nfs/nfs_srvcache.c +++ b/sys/nfs/nfs_srvcache.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_srvcache.c,v 1.11 2004/07/16 15:01:51 henning Exp $ */ +/* $OpenBSD: nfs_srvcache.c,v 1.12 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: nfs_srvcache.c,v 1.12 1996/02/18 11:53:49 fvdl Exp $ */ /* @@ -173,8 +173,7 @@ nfsrv_getcache(nd, slp, repp) if (!nd->nd_nam2) return (RC_DOIT); loop: - for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != NULL; - rp = LIST_NEXT(rp, rc_hash)) { + LIST_FOREACH(rp, NFSRCHASH(nd->nd_retxid), rc_hash) { if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc && netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) { if ((rp->rc_flag & RC_LOCKED) != 0) { @@ -277,8 +276,7 @@ nfsrv_updatecache(nd, repvalid, repmbuf) if (!nd->nd_nam2) return; loop: - for (rp = NFSRCHASH(nd->nd_retxid)->lh_first; rp != NULL; - rp = LIST_NEXT(rp, rc_hash)) { + LIST_FOREACH(rp, NFSRCHASH(nd->nd_retxid), rc_hash) { if (nd->nd_retxid == rp->rc_xid && nd->nd_procnum == rp->rc_proc && netaddr_match(NETFAMILY(rp), &rp->rc_haddr, nd->nd_nam)) { if ((rp->rc_flag & RC_LOCKED) != 0) { diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index a103a3d3528..db3d69bc958 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nfs_syscalls.c,v 1.42 2004/07/16 15:01:51 henning Exp $ */ +/* $OpenBSD: nfs_syscalls.c,v 1.43 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: nfs_syscalls.c,v 1.19 1996/02/18 11:53:52 fvdl Exp $ */ /* @@ -317,8 +317,8 @@ sys_nfssvc(p, v, retval) * First check to see if another nfsd has already * added this credential. */ - for (nuidp = NUIDHASH(slp,nsd->nsd_cr.cr_uid)->lh_first; - nuidp != NULL; nuidp = LIST_NEXT(nuidp, nu_hash)) { + LIST_FOREACH(nuidp, NUIDHASH(slp,nsd->nsd_cr.cr_uid), + nu_hash) { if (nuidp->nu_cr.cr_uid == nsd->nsd_cr.cr_uid && (!nfsd->nfsd_nd->nd_nam2 || netaddr_match(NU_NETFAM(nuidp), @@ -1114,8 +1114,7 @@ nfs_getnickauth(nmp, cred, auth_str, auth_len, verf_str, verf_len) if (verf_len < (4 * NFSX_UNSIGNED)) panic("nfs_getnickauth verf too small"); #endif - for (nuidp = NMUIDHASH(nmp, cred->cr_uid)->lh_first; - nuidp != NULL; nuidp = LIST_NEXT(nuidp, nu_hash)) { + LIST_FOREACH(nuidp, NMUIDHASH(nmp, cred->cr_uid), nu_hash) { if (nuidp->nu_cr.cr_uid == cred->cr_uid) break; } diff --git a/sys/scsi/scsi_ioctl.c b/sys/scsi/scsi_ioctl.c index 34d1bafe37f..686b84b6d37 100644 --- a/sys/scsi/scsi_ioctl.c +++ b/sys/scsi/scsi_ioctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_ioctl.c,v 1.18 2004/11/30 19:28:36 krw Exp $ */ +/* $OpenBSD: scsi_ioctl.c,v 1.19 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: scsi_ioctl.c,v 1.23 1996/10/12 23:23:17 christos Exp $ */ /* @@ -141,7 +141,7 @@ si_find(struct buf *bp) int s; s = splbio(); - for (si = si_head.lh_first; si != 0; si = si->si_list.le_next) + LIST_FOREACH(si, &si_head, si_list) if (bp == &si->si_bp) break; splx(s); diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index fbb13d1458f..be2943cbf10 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vfsops.c,v 1.34 2004/06/21 23:50:38 tholo Exp $ */ +/* $OpenBSD: ext2fs_vfsops.c,v 1.35 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */ /* @@ -747,7 +747,7 @@ ext2fs_sync_vnode(struct vnode *vp, void *args) ip = VTOI(vp); if (vp->v_type == VNON || ((ip->i_flag & (IN_ACCESS | IN_CHANGE | IN_MODIFIED | IN_UPDATE)) == 0 && - vp->v_dirtyblkhd.lh_first == NULL) || + LIST_EMPTY(&vp->v_dirtyblkhd)) || esa->waitfor == MNT_LAZY) { simple_unlock(&vp->v_interlock); return (0); diff --git a/sys/ufs/ufs/ufs_ihash.c b/sys/ufs/ufs/ufs_ihash.c index 03473a9db32..d2af1808f18 100644 --- a/sys/ufs/ufs/ufs_ihash.c +++ b/sys/ufs/ufs/ufs_ihash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_ihash.c,v 1.9 2003/06/02 23:28:23 millert Exp $ */ +/* $OpenBSD: ufs_ihash.c,v 1.10 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: ufs_ihash.c,v 1.3 1996/02/09 22:36:04 christos Exp $ */ /* @@ -73,7 +73,7 @@ ufs_ihashlookup(dev, inum) struct inode *ip; simple_lock(&ufs_ihash_slock); - 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; simple_unlock(&ufs_ihash_slock); @@ -97,7 +97,7 @@ ufs_ihashget(dev, inum) struct vnode *vp; loop: simple_lock(&ufs_ihash_slock); - 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); simple_lock(&vp->v_interlock); @@ -106,7 +106,6 @@ loop: goto loop; return (vp); } - } simple_unlock(&ufs_ihash_slock); return (NULL); @@ -130,8 +129,7 @@ ufs_ihashins(ip) simple_lock(&ufs_ihash_slock); - for (curip = INOHASH(dev, inum)->lh_first; curip; - curip = curip->i_hash.le_next) { + LIST_FOREACH(curip, INOHASH(dev, inum), i_hash) { if (inum == curip->i_number && dev == curip->i_dev) { simple_unlock(&ufs_ihash_slock); lockmgr(&ip->i_lock, LK_RELEASE, (struct simplelock *)0, p); diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index 1659cfd306e..cc5b8324324 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_quota.c,v 1.17 2004/06/21 23:50:38 tholo Exp $ */ +/* $OpenBSD: ufs_quota.c,v 1.18 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: ufs_quota.c,v 1.8 1996/02/09 22:36:09 christos Exp $ */ /* @@ -852,7 +852,7 @@ dqget(vp, id, ump, type, dqp) * Check the cache first. */ dqh = DQHASH(dqvp, id); - for (dq = dqh->lh_first; dq; dq = dq->dq_hash.le_next) { + LIST_FOREACH(dq, dqh, dq_hash) { if (dq->dq_id != id || dq->dq_vp != dqvp) continue; @@ -869,7 +869,7 @@ dqget(vp, id, ump, type, dqp) /* * Not in cache, allocate a new one. */ - if (dqfreelist.tqh_first == NODQUOT && + if (TAILQ_FIRST(&dqfreelist) == NODQUOT && numdquot < MAXQUOTAS * desiredvnodes) desireddquot += DQUOTINC; if (numdquot < desireddquot) { @@ -877,7 +877,7 @@ dqget(vp, id, ump, type, dqp) bzero((char *)dq, sizeof *dq); numdquot++; } else { - if ((dq = dqfreelist.tqh_first) == NULL) { + if ((dq = TAILQ_FIRST(&dqfreelist)) == NULL) { tablefull("dquot"); *dqp = NODQUOT; return (EUSERS); diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c index 56e50f7f577..b0ec463b8e3 100644 --- a/sys/uvm/uvm_aobj.c +++ b/sys/uvm/uvm_aobj.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_aobj.c,v 1.26 2002/03/14 01:27:18 millert Exp $ */ +/* $OpenBSD: uvm_aobj.c,v 1.27 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */ /* @@ -833,7 +833,7 @@ uao_flush(uobj, start, stop, flags) */ if (by_list) { - pp = uobj->memq.tqh_first; + pp = TAILQ_FIRST(&uobj->memq); } else { curoff = start; pp = uvm_pagelookup(uobj, curoff); diff --git a/sys/uvm/uvm_page.c b/sys/uvm/uvm_page.c index 3e949be6409..f7716dcfe9e 100644 --- a/sys/uvm/uvm_page.c +++ b/sys/uvm/uvm_page.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_page.c,v 1.49 2004/02/23 06:19:32 drahn Exp $ */ +/* $OpenBSD: uvm_page.c,v 1.50 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: uvm_page.c,v 1.44 2000/11/27 08:40:04 chs Exp $ */ /* @@ -812,7 +812,7 @@ uvm_page_rehash() /* ... and rehash */ for (lcv = 0 ; lcv < oldcount ; lcv++) { - while ((pg = oldbuckets[lcv].tqh_first) != NULL) { + while ((pg = TAILQ_FIRST(&oldbuckets[lcv])) != NULL) { TAILQ_REMOVE(&oldbuckets[lcv], pg, hashq); TAILQ_INSERT_TAIL( &uvm.page_hash[uvm_pagehash(pg->uobject, pg->offset)], diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c index ecbb9f6086a..a0c0d55f1c6 100644 --- a/sys/uvm/uvm_swap.c +++ b/sys/uvm/uvm_swap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_swap.c,v 1.59 2004/09/23 06:31:35 tedu Exp $ */ +/* $OpenBSD: uvm_swap.c,v 1.60 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */ /* @@ -327,11 +327,8 @@ uvm_swap_initcrypt_all(void) simple_lock(&uvm.swap_data_lock); - for (spp = swap_priority.lh_first; spp != NULL; - spp = spp->spi_swappri.le_next) { - for (sdp = spp->spi_swapdev.cqh_first; - sdp != (void *)&spp->spi_swapdev; - sdp = sdp->swd_next.cqe_next) + LIST_FOREACH(spp, &swap_priority, spi_swappri) { + CIRCLEQ_FOREACH(sdp, &spp->spi_swapdev, swd_next) if (sdp->swd_decrypt == NULL) uvm_swap_initcrypt(sdp, sdp->swd_npages); } diff --git a/sys/uvm/uvm_vnode.c b/sys/uvm/uvm_vnode.c index c1c2286cdde..83f7c85f544 100644 --- a/sys/uvm/uvm_vnode.c +++ b/sys/uvm/uvm_vnode.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_vnode.c,v 1.38 2004/06/06 13:44:07 grange Exp $ */ +/* $OpenBSD: uvm_vnode.c,v 1.39 2004/12/26 21:22:14 miod Exp $ */ /* $NetBSD: uvm_vnode.c,v 1.36 2000/11/24 20:34:01 chs Exp $ */ /* @@ -467,7 +467,7 @@ uvn_detach(uobj) simple_unlock(&uvn_wl_lock); } #ifdef DIAGNOSTIC - if (uobj->memq.tqh_first != NULL) + if (!TAILQ_EMPTY(&uobj->memq)) panic("uvn_deref: vnode VM object still has pages afer " "syncio/free flush"); #endif @@ -590,8 +590,7 @@ uvm_vnp_terminate(vp) while (uvn->u_obj.uo_npages) { #ifdef DEBUG struct vm_page *pp; - for (pp = uvn->u_obj.memq.tqh_first ; pp != NULL ; - pp = pp->listq.tqe_next) { + TAILQ_FOREACH(pp, &uvn->u_obj.memq, listq) { if ((pp->flags & PG_BUSY) == 0) panic("uvm_vnp_terminate: detected unbusy pg"); } @@ -686,7 +685,7 @@ uvn_releasepg(pg, nextpgp) pmap_page_protect(pg, VM_PROT_NONE); uvm_lock_pageq(); if (nextpgp) - *nextpgp = pg->pageq.tqe_next; /* next page for daemon */ + *nextpgp = TAILQ_NEXT(pg, pageq); /* next page for daemon */ uvm_pagefree(pg); if (!nextpgp) uvm_unlock_pageq(); @@ -705,7 +704,7 @@ uvn_releasepg(pg, nextpgp) simple_unlock(&uvn_wl_lock); } #ifdef DIAGNOSTIC - if (uvn->u_obj.memq.tqh_first) + if (!TAILQ_EMPTY(&uvn->u_obj.memq)) panic("uvn_releasepg: pages in object with npages == 0"); #endif if (uvn->u_flags & UVM_VNODE_WANTED) @@ -870,8 +869,7 @@ uvn_flush(uobj, start, stop, flags) if ((flags & PGO_CLEANIT) != 0 && uobj->pgops->pgo_mk_pcluster != NULL) { if (by_list) { - for (pp = uobj->memq.tqh_first ; pp != NULL ; - pp = pp->listq.tqe_next) { + TAILQ_FOREACH(pp, &uobj->memq, listq) { if (!all && (pp->offset < start || pp->offset >= stop)) continue; @@ -895,7 +893,7 @@ uvn_flush(uobj, start, stop, flags) */ if (by_list) { - pp = uobj->memq.tqh_first; + pp = TAILQ_FIRST(&uobj->memq); } else { curoff = start; pp = uvm_pagelookup(uobj, curoff); @@ -917,7 +915,7 @@ uvn_flush(uobj, start, stop, flags) if (!all && (pp->offset < start || pp->offset >= stop)) { - ppnext = pp->listq.tqe_next; + ppnext = TAILQ_NEXT(pp, listq); continue; } @@ -976,7 +974,7 @@ uvn_flush(uobj, start, stop, flags) if (!needs_clean) { /* load ppnext */ if (by_list) - ppnext = pp->listq.tqe_next; + ppnext = TAILQ_NEXT(pp, listq); else { if (curoff < stop) ppnext = uvm_pagelookup(uobj, curoff); @@ -1081,10 +1079,10 @@ ReTry: */ if (by_list) { if (pp->version == pp_version) - ppnext = pp->listq.tqe_next; + ppnext = TAILQ_NEXT(pp, listq); else /* reset */ - ppnext = uobj->memq.tqh_first; + ppnext = TAILQ_FIRST(&uobj->memq); } else { if (curoff < stop) ppnext = uvm_pagelookup(uobj, @@ -1120,10 +1118,10 @@ ReTry: /* set up next page for outer loop */ if (by_list) { if (pp->version == pp_version) - ppnext = pp->listq.tqe_next; + ppnext = TAILQ_NEXT(pp, listq); else /* reset */ - ppnext = uobj->memq.tqh_first; + ppnext = TAILQ_FIRST(&uobj->memq); } else { if (curoff < stop) ppnext = uvm_pagelookup(uobj, curoff); @@ -1942,8 +1940,7 @@ uvm_vnp_sync(mp) */ SIMPLEQ_INIT(&uvn_sync_q); simple_lock(&uvn_wl_lock); - for (uvn = uvn_wlist.lh_first ; uvn != NULL ; - uvn = uvn->u_wlist.le_next) { + LIST_FOREACH(uvn, &uvn_wlist, u_wlist) { vp = (struct vnode *) uvn; if (mp && vp->v_mount != mp) |