From f7b490d28bfcd38c0a02589d91cb40c18ed67076 Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 17 Oct 2005 19:04:21 +0000 Subject: Use queue macros instead of directly accessing fields. ok pat@ "put it in" deraadt@ --- usr.bin/apropos/apropos.c | 8 ++++---- usr.bin/gencat/gencat.c | 36 +++++++++++++++++------------------- usr.bin/systat/netstat.c | 12 ++++++------ usr.bin/vmstat/dkstats.c | 8 ++++---- usr.bin/whatis/whatis.c | 6 +++--- 5 files changed, 34 insertions(+), 36 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/apropos/apropos.c b/usr.bin/apropos/apropos.c index e39d546e0d9..d680b7e44bc 100644 --- a/usr.bin/apropos/apropos.c +++ b/usr.bin/apropos/apropos.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apropos.c,v 1.10 2003/06/10 22:20:44 deraadt Exp $ */ +/* $OpenBSD: apropos.c,v 1.11 2005/10/17 19:04:19 otto Exp $ */ /* $NetBSD: apropos.c,v 1.5 1995/09/04 20:46:20 tls Exp $ */ /* @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)apropos.c 8.8 (Berkeley) 5/4/95"; #else -static char rcsid[] = "$OpenBSD: apropos.c,v 1.10 2003/06/10 22:20:44 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: apropos.c,v 1.11 2005/10/17 19:04:19 otto Exp $"; #endif #endif /* not lint */ @@ -113,8 +113,8 @@ main(int argc, char *argv[]) else { config(conffile); ep = (tp = getlist("_whatdb")) == NULL ? - NULL : tp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) + NULL : TAILQ_FIRST(&tp->list); + for (; ep != NULL; ep = TAILQ_NEXT(ep, q)) apropos(argv, ep->s, 0); } diff --git a/usr.bin/gencat/gencat.c b/usr.bin/gencat/gencat.c index 3e7851b2506..78430f226ce 100644 --- a/usr.bin/gencat/gencat.c +++ b/usr.bin/gencat/gencat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: gencat.c,v 1.9 2004/07/01 19:23:34 mickey Exp $ */ +/* $OpenBSD: gencat.c,v 1.10 2005/10/17 19:04:20 otto Exp $ */ /* $NetBSD: gencat.c,v 1.9 1998/10/09 17:00:56 itohy Exp $ */ /*- @@ -40,7 +40,7 @@ #include #ifndef lint static const char rcsid[] = - "$OpenBSD: gencat.c,v 1.9 2004/07/01 19:23:34 mickey Exp $"; + "$OpenBSD: gencat.c,v 1.10 2005/10/17 19:04:20 otto Exp $"; #endif /* not lint */ /*********************************************************** @@ -522,12 +522,10 @@ MCWriteCat(int fd) nmsgs = 0; string_size = 0; - for (set = sethead.lh_first; set != NULL; - set = set->entries.le_next) { + LIST_FOREACH(set, &sethead, entries) { nsets++; - for (msg = set->msghead.lh_first; msg != NULL; - msg = msg->entries.le_next) { + LIST_FOREACH(msg, &set->msghead, entries) { nmsgs++; string_size += strlen(msg->str) + 1; } @@ -573,12 +571,10 @@ MCWriteCat(int fd) msg_index = 0; msg_offset = 0; - for (set = sethead.lh_first; set != NULL; - set = set->entries.le_next) { + LIST_FOREACH(set, &sethead, entries) { nmsgs = 0; - for (msg = set->msghead.lh_first; msg != NULL; - msg = msg->entries.le_next) { + LIST_FOREACH(msg, &set->msghead, entries) { int msg_len = strlen(msg->str) + 1; msg_hdr->__msgno = htonl(msg->msgId); @@ -621,9 +617,9 @@ MCAddSet(int setId) } #endif - p = sethead.lh_first; + p = LIST_FIRST(&sethead); q = NULL; - for (; p != NULL && p->setId < setId; q = p, p = p->entries.le_next); + for (; p != NULL && p->setId < setId; q = p, p = LIST_NEXT(p, entries)); if (p && p->setId == setId) { ; @@ -664,9 +660,9 @@ MCAddMsg(int msgId, const char *str) } #endif - p = curSet->msghead.lh_first; + p = LIST_FIRST(&curSet->msghead); q = NULL; - for (; p != NULL && p->msgId < msgId; q = p, p = p->entries.le_next); + for (; p != NULL && p->msgId < msgId; q = p, p = LIST_NEXT(p, entries)); if (p && p->msgId == msgId) { free(p->str); @@ -691,12 +687,13 @@ MCDelSet(int setId) struct _setT *set; struct _msgT *msg; - set = sethead.lh_first; - for (; set != NULL && set->setId < setId; set = set->entries.le_next); + set = LIST_FIRST(&sethead); + for (; set != NULL && set->setId < setId; + set = LIST_NEXT(set, entries)); if (set && set->setId == setId) { - msg = set->msghead.lh_first; + msg = LIST_FIRST(&set->msghead); while (msg) { free(msg->str); LIST_REMOVE(msg, entries); @@ -716,8 +713,9 @@ MCDelMsg(int msgId) if (!curSet) error(NULL, "you can't delete a message before defining the set"); - msg = curSet->msghead.lh_first; - for (; msg != NULL && msg->msgId < msgId; msg = msg->entries.le_next); + msg = LIST_FIRST(&curSet->msghead); + for (; msg != NULL && msg->msgId < msgId; + msg = LIST_NEXT(msg, entries)); if (msg && msg->msgId == msgId) { free(msg->str); diff --git a/usr.bin/systat/netstat.c b/usr.bin/systat/netstat.c index 2756d0d9090..2d81da1c9ad 100644 --- a/usr.bin/systat/netstat.c +++ b/usr.bin/systat/netstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netstat.c,v 1.27 2005/05/10 17:12:00 deraadt Exp $ */ +/* $OpenBSD: netstat.c,v 1.28 2005/10/17 19:04:20 otto Exp $ */ /* $NetBSD: netstat.c,v 1.3 1995/06/18 23:53:07 cgd Exp $ */ /*- @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)netstat.c 8.1 (Berkeley) 6/6/93"; #endif -static char rcsid[] = "$OpenBSD: netstat.c,v 1.27 2005/05/10 17:12:00 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: netstat.c,v 1.28 2005/10/17 19:04:20 otto Exp $"; #endif /* not lint */ /* @@ -195,12 +195,12 @@ fetchnetstat(void) again: KREAD(off, &pcbtable, sizeof (struct inpcbtable)); prev = head = (struct inpcb *)&((struct inpcbtable *)off)->inpt_queue; - next = pcbtable.inpt_queue.cqh_first; + next = CIRCLEQ_FIRST(&pcbtable.inpt_queue); while (next != head) { KREAD(next, &inpcb, sizeof (inpcb)); - if (inpcb.inp_queue.cqe_prev != prev) { + if (CIRCLEQ_PREV(&inpcb, inp_queue) != prev) { printf("prev = %p, head = %p, next = %p, inpcb...prev = %p\n", - prev, head, next, inpcb.inp_queue.cqe_prev); + prev, head, next, CIRCLEQ_PREV(&inpcb, inp_queue)); p = netcb.nif_forw; for (; p != (struct netinfo *)&netcb; p = p->nif_forw) p->nif_seen = 1; @@ -208,7 +208,7 @@ again: return; } prev = next; - next = inpcb.inp_queue.cqe_next; + next = CIRCLEQ_NEXT(&inpcb, inp_queue); if (!aflag) { if (!(inpcb.inp_flags & INP_IPV6) && diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c index d27244d5f71..3ad4b138489 100644 --- a/usr.bin/vmstat/dkstats.c +++ b/usr.bin/vmstat/dkstats.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkstats.c,v 1.26 2005/07/04 01:54:10 djm Exp $ */ +/* $OpenBSD: dkstats.c,v 1.27 2005/10/17 19:04:20 otto Exp $ */ /* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */ /* @@ -382,7 +382,7 @@ dkreadstats(void) cur.dk_rbytes[i] = cur_disk.dk_rbytes; cur.dk_wbytes[i] = cur_disk.dk_wbytes; timerset(&(cur_disk.dk_time), &(cur.dk_time[i])); - p = cur_disk.dk_link.tqe_next; + p = TAILQ_NEXT(&cur_disk, dk_link); } deref_nl(X_CP_TIME, cur.cp_time, sizeof(cur.cp_time)); deref_nl(X_TK_NIN, &cur.tk_nin, sizeof(cur.tk_nin)); @@ -443,7 +443,7 @@ dkinit(int select) /* Get a pointer to the first disk. */ deref_nl(X_DISKLIST, &disk_head, sizeof(disk_head)); - dk_drivehead = disk_head.tqh_first; + dk_drivehead = TAILQ_FIRST(&disk_head); /* Get ticks per second. */ deref_nl(X_STATHZ, &hz, sizeof(hz)); @@ -528,7 +528,7 @@ dkinit(int select) errx(1, "Memory allocation failure."); cur.dk_select[i] = select; - p = cur_disk.dk_link.tqe_next; + p = TAILQ_NEXT(&cur_disk, dk_link); } #endif /* !defined(NOKVM) */ } diff --git a/usr.bin/whatis/whatis.c b/usr.bin/whatis/whatis.c index b0f18de11ec..ddd74440a6f 100644 --- a/usr.bin/whatis/whatis.c +++ b/usr.bin/whatis/whatis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: whatis.c,v 1.9 2003/06/10 22:20:54 deraadt Exp $ */ +/* $OpenBSD: whatis.c,v 1.10 2005/10/17 19:04:20 otto Exp $ */ /* * Copyright (c) 1987, 1993 @@ -108,8 +108,8 @@ main(int argc, char *argv[]) else { config(conffile); ep = (tp = getlist("_whatdb")) == NULL ? - NULL : tp->list.tqh_first; - for (; ep != NULL; ep = ep->q.tqe_next) + NULL : TAILQ_FIRST(&tp->list); + for (; ep != NULL; ep = TAILQ_NEXT(ep, q)) whatis(argv, ep->s, 0); } -- cgit v1.2.3