use TAILQ_FOREACH where appropriate, rather than rolling their own.

This commit is contained in:
yamt 2009-01-16 01:48:09 +00:00
parent 46b53b5f94
commit 3e54d28391
3 changed files with 10 additions and 18 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: bufq_disksort.c,v 1.9 2008/04/30 12:09:02 reinoud Exp $ */ /* $NetBSD: bufq_disksort.c,v 1.10 2009/01/16 01:48:09 yamt Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */ /* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*- /*-
@ -68,7 +68,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bufq_disksort.c,v 1.9 2008/04/30 12:09:02 reinoud Exp $"); __KERNEL_RCSID(0, "$NetBSD: bufq_disksort.c,v 1.10 2009/01/16 01:48:09 yamt Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -197,13 +197,11 @@ bufq_disksort_cancel(struct bufq_state *bufq, struct buf *buf)
struct bufq_disksort *disksort = bufq->bq_private; struct bufq_disksort *disksort = bufq->bq_private;
struct buf *bq; struct buf *bq;
bq = TAILQ_FIRST(&disksort->bq_head); TAILQ_FOREACH(bq, &disksort->bq_head, b_actq) {
while (bq) {
if (bq == buf) { if (bq == buf) {
TAILQ_REMOVE(&disksort->bq_head, bq, b_actq); TAILQ_REMOVE(&disksort->bq_head, bq, b_actq);
return buf; return buf;
} }
bq = TAILQ_NEXT(bq, b_actq);
} }
return NULL; return NULL;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: bufq_fcfs.c,v 1.8 2008/04/30 12:09:02 reinoud Exp $ */ /* $NetBSD: bufq_fcfs.c,v 1.9 2009/01/16 01:48:09 yamt Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */ /* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*- /*-
@ -68,7 +68,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.8 2008/04/30 12:09:02 reinoud Exp $"); __KERNEL_RCSID(0, "$NetBSD: bufq_fcfs.c,v 1.9 2009/01/16 01:48:09 yamt Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -121,13 +121,11 @@ bufq_fcfs_cancel(struct bufq_state *bufq, struct buf *buf)
struct bufq_fcfs *fcfs = bufq->bq_private; struct bufq_fcfs *fcfs = bufq->bq_private;
struct buf *bp; struct buf *bp;
bp = TAILQ_FIRST(&fcfs->bq_head); TAILQ_FOREACH(bp, &fcfs->bq_head, b_actq) {
while (bp) {
if (bp == buf) { if (bp == buf) {
TAILQ_REMOVE(&fcfs->bq_head, bp, b_actq); TAILQ_REMOVE(&fcfs->bq_head, bp, b_actq);
return buf; return buf;
} }
bp = TAILQ_NEXT(bp, b_actq);
} }
return NULL; return NULL;
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: bufq_readprio.c,v 1.11 2008/04/30 12:09:02 reinoud Exp $ */ /* $NetBSD: bufq_readprio.c,v 1.12 2009/01/16 01:48:09 yamt Exp $ */
/* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */ /* NetBSD: subr_disk.c,v 1.61 2004/09/25 03:30:44 thorpej Exp */
/*- /*-
@ -68,7 +68,7 @@
*/ */
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: bufq_readprio.c,v 1.11 2008/04/30 12:09:02 reinoud Exp $"); __KERNEL_RCSID(0, "$NetBSD: bufq_readprio.c,v 1.12 2009/01/16 01:48:09 yamt Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -221,20 +221,17 @@ bufq_prio_cancel(struct bufq_state *bufq, struct buf *buf)
struct buf *bq; struct buf *bq;
/* search read queue */ /* search read queue */
bq = TAILQ_FIRST(&prio->bq_read); TAILQ_FOREACH(bq, &prio->bq_read, b_actq) {
while (bq) {
if (bq == buf) { if (bq == buf) {
TAILQ_REMOVE(&prio->bq_read, bq, b_actq); TAILQ_REMOVE(&prio->bq_read, bq, b_actq);
/* force new section */ /* force new section */
prio->bq_next = NULL; prio->bq_next = NULL;
return buf; return buf;
} }
bq = TAILQ_NEXT(bq, b_actq);
} }
/* not found in read queue, search write queue */ /* not found in read queue, search write queue */
bq = TAILQ_FIRST(&prio->bq_write); TAILQ_FOREACH(bq, &prio->bq_write, b_actq) {
while (bq) {
if (bq == buf) { if (bq == buf) {
if (bq == prio->bq_write_next) { if (bq == prio->bq_write_next) {
/* /*
@ -254,7 +251,6 @@ bufq_prio_cancel(struct bufq_state *bufq, struct buf *buf)
prio->bq_next = NULL; prio->bq_next = NULL;
return buf; return buf;
} }
bq = TAILQ_NEXT(bq, b_actq);
} }
/* still not found */ /* still not found */