summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2005-10-17 19:09:37 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2005-10-17 19:09:37 +0000
commit8728eaba8fdf623ad4a0e57bddd7a3237166a42a (patch)
tree0c8b5fc3809a1a8c6c3ec8a4a41ff63b6b34f680 /usr.bin
parentf7b490d28bfcd38c0a02589d91cb40c18ed67076 (diff)
Use queue macros instead of directly accessing fields. ok pat@ "put it
in" deraadt@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/man/config.c10
-rw-r--r--usr.bin/man/man.c56
-rw-r--r--usr.bin/netstat/if.c26
-rw-r--r--usr.bin/netstat/inet.c12
-rw-r--r--usr.bin/netstat/ipx.c12
-rw-r--r--usr.bin/netstat/mroute.c4
6 files changed, 59 insertions, 61 deletions
diff --git a/usr.bin/man/config.c b/usr.bin/man/config.c
index bc944547a40..63a174f3279 100644
--- a/usr.bin/man/config.c
+++ b/usr.bin/man/config.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.c,v 1.6 2004/09/15 22:20:03 deraadt Exp $ */
+/* $OpenBSD: config.c,v 1.7 2005/10/17 19:08:46 otto Exp $ */
/* $NetBSD: config.c,v 1.7 1995/09/28 06:05:21 tls Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)config.c 8.8 (Berkeley) 1/31/95";
#else
-static char rcsid[] = "$OpenBSD: config.c,v 1.6 2004/09/15 22:20:03 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: config.c,v 1.7 2005/10/17 19:08:46 otto Exp $";
#endif
#endif /* not lint */
@@ -100,8 +100,8 @@ config(char *fname)
continue;
*t = '\0';
- for (tp = head.tqh_first; /* Find any matching tag. */
- tp != NULL && strcmp(p, tp->s); tp = tp->q.tqe_next);
+ for (tp = TAILQ_FIRST(&head); /* Find any matching tag. */
+ tp != NULL && strcmp(p, tp->s); tp = TAILQ_NEXT(tp, q));
if (tp == NULL) /* Create a new tag. */
tp = addlist(p);
@@ -156,7 +156,7 @@ getlist(char *name)
{
TAG *tp;
- for (tp = head.tqh_first; tp != NULL; tp = tp->q.tqe_next)
+ TAILQ_FOREACH(tp, &head, q)
if (!strcmp(name, tp->s))
return (tp);
return (NULL);
diff --git a/usr.bin/man/man.c b/usr.bin/man/man.c
index cc04876b357..15e766841af 100644
--- a/usr.bin/man/man.c
+++ b/usr.bin/man/man.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: man.c,v 1.28 2004/02/23 14:14:14 jmc Exp $ */
+/* $OpenBSD: man.c,v 1.29 2005/10/17 19:08:46 otto Exp $ */
/* $NetBSD: man.c,v 1.7 1995/09/28 06:05:34 tls Exp $ */
/*
@@ -40,7 +40,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)man.c 8.17 (Berkeley) 1/31/95";
#else
-static char rcsid[] = "$OpenBSD: man.c,v 1.28 2004/02/23 14:14:14 jmc Exp $";
+static char rcsid[] = "$OpenBSD: man.c,v 1.29 2005/10/17 19:08:46 otto Exp $";
#endif
#endif /* not lint */
@@ -187,7 +187,7 @@ main(int argc, char *argv[])
if (p_path == NULL)
p_path = getenv("MANPATH");
if (p_path != NULL) {
- while ((e_defp = defp->list.tqh_first) != NULL) {
+ while ((e_defp = TAILQ_FIRST(&defp->list)) != NULL) {
free(e_defp->s);
TAILQ_REMOVE(&defp->list, e_defp, q);
}
@@ -195,8 +195,8 @@ main(int argc, char *argv[])
p != NULL; p = strtok(NULL, ":")) {
slashp = p[strlen(p) - 1] == '/' ? "" : "/";
e_subp = (subp = getlist("_subdir")) == NULL ?
- NULL : subp->list.tqh_first;
- for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ NULL : TAILQ_FIRST(&subp->list);
+ for (; e_subp != NULL; e_subp = TAILQ_NEXT(e_subp, q)) {
(void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
p, slashp, e_subp->s, machine);
if ((ep = malloc(sizeof(ENTRY))) == NULL ||
@@ -221,14 +221,13 @@ main(int argc, char *argv[])
}
if (p_path == NULL && section == NULL) {
defnewp = addlist("_default_new");
- e_defp =
- defp->list.tqh_first == NULL ? NULL : defp->list.tqh_first;
- for (; e_defp != NULL; e_defp = e_defp->q.tqe_next) {
+ e_defp = TAILQ_FIRST(&defp->list);
+ for (; e_defp != NULL; e_defp = TAILQ_NEXT(e_defp, q)) {
slashp =
e_defp->s[strlen(e_defp->s) - 1] == '/' ? "" : "/";
e_subp = (subp = getlist("_subdir")) == NULL ?
- NULL : subp->list.tqh_first;
- for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ NULL : TAILQ_FIRST(&subp->list);
+ for (; e_subp != NULL; e_subp = TAILQ_NEXT(e_subp, q)) {
(void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
e_defp->s, slashp, e_subp->s, machine);
if ((ep = malloc(sizeof(ENTRY))) == NULL ||
@@ -238,7 +237,7 @@ main(int argc, char *argv[])
}
}
defp = getlist("_default");
- while ((e_defp = defp->list.tqh_first) != NULL) {
+ while ((e_defp = TAILQ_FIRST(&defp->list)) != NULL) {
free(e_defp->s);
TAILQ_REMOVE(&defp->list, e_defp, q);
}
@@ -260,8 +259,8 @@ main(int argc, char *argv[])
for (p = strtok(p_add, ":"); p != NULL; p = strtok(NULL, ":")) {
slashp = p[strlen(p) - 1] == '/' ? "" : "/";
e_subp = (subp = getlist("_subdir")) == NULL ?
- NULL : subp->list.tqh_first;
- for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ NULL : TAILQ_FIRST(&subp->list);
+ for (; e_subp != NULL; e_subp = TAILQ_NEXT(e_subp, q)) {
(void)snprintf(buf, sizeof(buf), "%s%s%s{/%s,}",
p, slashp, e_subp->s, machine);
if ((ep = malloc(sizeof(ENTRY))) == NULL ||
@@ -280,9 +279,9 @@ main(int argc, char *argv[])
}
if (e_sectp != NULL) { /* entries added, fix order */
/* save original head */
- ep->q.tqe_next = defp->list.tqh_first;
+ TAILQ_NEXT(ep, q) = TAILQ_FIRST(&defp->list);
/* first added entry, new top */
- defp->list.tqh_first = e_sectp;
+ TAILQ_FIRST(&defp->list) = e_sectp;
/* terminate list */
*e_sectp->q.tqe_prev = NULL;
}
@@ -294,8 +293,7 @@ main(int argc, char *argv[])
*/
if (p_add == NULL && section != NULL) {
sectnewp = addlist("_section_new");
- for (e_sectp = section->list.tqh_first;
- e_sectp != NULL; e_sectp = e_sectp->q.tqe_next) {
+ TAILQ_FOREACH(e_sectp, &section->list, q) {
if (e_sectp->s[strlen(e_sectp->s) - 1] != '/') {
(void)snprintf(buf, sizeof(buf),
"%s{/%s,}", e_sectp->s, machine);
@@ -306,8 +304,8 @@ main(int argc, char *argv[])
continue;
}
e_subp = (subp = getlist("_subdir")) == NULL ?
- NULL : subp->list.tqh_first;
- for (; e_subp != NULL; e_subp = e_subp->q.tqe_next) {
+ NULL : TAILQ_FIRST(&subp->list);
+ for (; e_subp != NULL; e_subp = TAILQ_NEXT(e_subp, q)) {
(void)snprintf(buf, sizeof(buf), "%s%s{/%s,}",
e_sectp->s, e_subp->s, machine);
if ((ep = malloc(sizeof(ENTRY))) == NULL ||
@@ -420,8 +418,8 @@ manual(char *page, TAG *tag, glob_t *pg)
buf[0] = '*';
/* For each element in the list... */
- e_tag = tag == NULL ? NULL : tag->list.tqh_first;
- for (; e_tag != NULL; e_tag = e_tag->q.tqe_next) {
+ e_tag = tag == NULL ? NULL : TAILQ_FIRST(&tag->list);
+ for (; e_tag != NULL; e_tag = TAILQ_NEXT(e_tag, q)) {
(void)snprintf(buf, sizeof(buf), "%s/%s.*", e_tag->s, page);
if (glob(buf,
GLOB_APPEND | GLOB_BRACE | GLOB_NOSORT | GLOB_QUOTE,
@@ -451,9 +449,9 @@ manual(char *page, TAG *tag, glob_t *pg)
goto next;
e_sufp = (sufp = getlist("_suffix")) == NULL ?
- NULL : sufp->list.tqh_first;
+ NULL : TAILQ_FIRST(&sufp->list);
for (found = 0;
- e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) {
+ e_sufp != NULL; e_sufp = TAILQ_NEXT(e_sufp, q)) {
(void)snprintf(buf,
sizeof(buf), "*/%s%s", page, e_sufp->s);
if (!fnmatch(buf, pg->gl_pathv[cnt], 0)) {
@@ -466,9 +464,9 @@ manual(char *page, TAG *tag, glob_t *pg)
/* Try the _build key words next. */
e_sufp = (sufp = getlist("_build")) == NULL ?
- NULL : sufp->list.tqh_first;
+ NULL : TAILQ_FIRST(&sufp->list);
for (found = 0;
- e_sufp != NULL; e_sufp = e_sufp->q.tqe_next) {
+ e_sufp != NULL; e_sufp = TAILQ_NEXT(e_sufp, q)) {
for (p = e_sufp->s;
*p != '\0' && !isspace(*p); ++p);
if (*p == '\0')
@@ -766,9 +764,9 @@ cleanup(void)
rval = 0;
ep = (missp = getlist("_missing")) == NULL ?
- NULL : missp->list.tqh_first;
+ NULL : TAILQ_FIRST(&missp->list);
if (ep != NULL)
- for (; ep != NULL; ep = ep->q.tqe_next) {
+ for (; ep != NULL; ep = TAILQ_NEXT(ep, q)) {
if (section)
warnx("no entry for %s in section %s of the manual.",
ep->s, section->s);
@@ -778,8 +776,8 @@ cleanup(void)
}
ep = (intmpp = getlist("_intmp")) == NULL ?
- NULL : intmpp->list.tqh_first;
- for (; ep != NULL; ep = ep->q.tqe_next)
+ NULL : TAILQ_FIRST(&intmpp->list);
+ for (; ep != NULL; ep = TAILQ_NEXT(ep, q))
(void)unlink(ep->s);
return (rval);
}
diff --git a/usr.bin/netstat/if.c b/usr.bin/netstat/if.c
index 7e140e6f2a7..448241b4e1b 100644
--- a/usr.bin/netstat/if.c
+++ b/usr.bin/netstat/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.44 2005/06/08 04:47:04 henning Exp $ */
+/* $OpenBSD: if.c,v 1.45 2005/10/17 19:09:36 otto Exp $ */
/* $NetBSD: if.c,v 1.16.4.2 1996/06/07 21:46:46 thorpej Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)if.c 8.2 (Berkeley) 2/21/94";
#else
-static char *rcsid = "$OpenBSD: if.c,v 1.44 2005/06/08 04:47:04 henning Exp $";
+static char *rcsid = "$OpenBSD: if.c,v 1.45 2005/10/17 19:09:36 otto Exp $";
#endif
#endif /* not lint */
@@ -105,7 +105,7 @@ intpr(int interval, u_long ifnetaddr)
*/
if (kread(ifnetaddr, &ifhead, sizeof ifhead))
return;
- ifnetaddr = (u_long)ifhead.tqh_first;
+ ifnetaddr = (u_long)TAILQ_FIRST(&ifhead);
printf("%-7.7s %-5.5s %-11.11s %-17.17s ",
"Name", "Mtu", "Network", "Address");
@@ -133,14 +133,14 @@ intpr(int interval, u_long ifnetaddr)
return;
bcopy(ifnet.if_xname, name, IFNAMSIZ);
name[IFNAMSIZ - 1] = '\0'; /* sanity */
- ifnetaddr = (u_long)ifnet.if_list.tqe_next;
+ ifnetaddr = (u_long)TAILQ_NEXT(&ifnet, if_list);
if (interface != 0 && strcmp(name, interface) != 0)
continue;
cp = strchr(name, '\0');
if ((ifnet.if_flags & IFF_UP) == 0)
*cp++ = '*';
*cp = '\0';
- ifaddraddr = (u_long)ifnet.if_addrlist.tqh_first;
+ ifaddraddr = (u_long)TAILQ_FIRST(&ifnet.if_addrlist);
}
if (qflag) {
@@ -205,12 +205,12 @@ intpr(int interval, u_long ifnetaddr)
u_long multiaddr;
struct in_multi inm;
- multiaddr = (u_long)ifaddr.in.ia_multiaddrs.lh_first;
+ multiaddr = (u_long)LIST_FIRST(&ifaddr.in.ia_multiaddrs);
while (multiaddr != 0) {
kread(multiaddr, &inm, sizeof inm);
printf("\n%25s %-17.17s ", "",
routename(inm.inm_addr.s_addr));
- multiaddr = (u_long)inm.inm_list.le_next;
+ multiaddr = (u_long)LIST_NEXT(&inm, inm_list);
}
}
break;
@@ -244,7 +244,7 @@ intpr(int interval, u_long ifnetaddr)
struct in6_multi inm;
struct sockaddr_in6 m6;
- multiaddr = (u_long)ifaddr.in6.ia6_multiaddrs.lh_first;
+ multiaddr = (u_long)LIST_FIRST(&ifaddr.in6.ia6_multiaddrs);
while (multiaddr != 0) {
kread(multiaddr, &inm, sizeof inm);
memset(&m6, 0, sizeof(m6));
@@ -267,7 +267,7 @@ intpr(int interval, u_long ifnetaddr)
n = 17;
printf("\n%25s %-*.*s ", "",
n, n, cp);
- multiaddr = (u_long)inm.in6m_entry.le_next;
+ multiaddr = (u_long)LIST_NEXT(&inm, in6m_entry);
}
}
break;
@@ -325,7 +325,7 @@ intpr(int interval, u_long ifnetaddr)
putchar(' ');
break;
}
- ifaddraddr = (u_long)ifaddr.ifa.ifa_list.tqe_next;
+ ifaddraddr = (u_long)TAILQ_NEXT(&ifaddr.ifa, ifa_list);
}
if (bflag)
printf("%10lu %10lu",
@@ -382,7 +382,7 @@ sidewaysintpr(unsigned int interval, u_long off)
*/
if (kread(off, &ifhead, sizeof ifhead))
return;
- firstifnet = (u_long)ifhead.tqh_first;
+ firstifnet = (u_long)TAILQ_FIRST(&ifhead);
lastif = iftot;
sum = iftot + MAXIF - 1;
@@ -398,7 +398,7 @@ sidewaysintpr(unsigned int interval, u_long off)
ip++;
if (ip >= iftot + MAXIF - 2)
break;
- off = (u_long)ifnet.if_list.tqe_next;
+ off = (u_long)TAILQ_NEXT(&ifnet, if_list);
}
if (interesting == NULL) {
fprintf(stderr, "%s: %s: unknown interface\n",
@@ -509,7 +509,7 @@ loop:
sum->ift_oe += ip->ift_oe;
sum->ift_co += ip->ift_co;
sum->ift_dr += ip->ift_dr;
- off = (u_long)ifnet.if_list.tqe_next;
+ off = (u_long)TAILQ_NEXT(&ifnet, if_list);
}
if (lastif - iftot > 0) {
if (bflag)
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index f504c368c93..2740e11ad79 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: inet.c,v 1.98 2005/08/11 15:52:14 markus Exp $ */
+/* $OpenBSD: inet.c,v 1.99 2005/10/17 19:09:36 otto Exp $ */
/* $NetBSD: inet.c,v 1.14 1995/10/03 21:42:37 thorpej Exp $ */
/*
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)inet.c 8.4 (Berkeley) 4/20/94";
#else
-static const char *rcsid = "$OpenBSD: inet.c,v 1.98 2005/08/11 15:52:14 markus Exp $";
+static const char *rcsid = "$OpenBSD: inet.c,v 1.99 2005/10/17 19:09:36 otto Exp $";
#endif
#endif /* not lint */
@@ -140,17 +140,17 @@ protopr0(u_long off, char *name, int af)
israw = strncmp(name, "ip", 2) == 0;
kread(off, &table, sizeof table);
prev = head =
- (struct inpcb *)&((struct inpcbtable *)off)->inpt_queue.cqh_first;
- next = table.inpt_queue.cqh_first;
+ (struct inpcb *)&CIRCLEQ_FIRST(&((struct inpcbtable *)off)->inpt_queue);
+ next = CIRCLEQ_FIRST(&table.inpt_queue);
while (next != head) {
kread((u_long)next, &inpcb, sizeof inpcb);
- if (inpcb.inp_queue.cqe_prev != prev) {
+ if (CIRCLEQ_PREV(&inpcb, inp_queue) != prev) {
printf("???\n");
break;
}
prev = next;
- next = inpcb.inp_queue.cqe_next;
+ next = CIRCLEQ_NEXT(&inpcb, inp_queue);
switch (af) {
case AF_INET:
diff --git a/usr.bin/netstat/ipx.c b/usr.bin/netstat/ipx.c
index ba581825278..6c5e1b57d06 100644
--- a/usr.bin/netstat/ipx.c
+++ b/usr.bin/netstat/ipx.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipx.c,v 1.17 2005/03/30 06:45:34 deraadt Exp $ */
+/* $OpenBSD: ipx.c,v 1.18 2005/10/17 19:09:36 otto Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "from: @(#)ns.c 8.1 (Berkeley) 6/6/93";
#else
-static char *rcsid = "$OpenBSD: ipx.c,v 1.17 2005/03/30 06:45:34 deraadt Exp $";
+static char *rcsid = "$OpenBSD: ipx.c,v 1.18 2005/10/17 19:09:36 otto Exp $";
#endif
#endif /* not lint */
@@ -98,17 +98,17 @@ ipxprotopr(u_long off, char *name)
isspx = strcmp(name, "spx") == 0;
kread(off, &table, sizeof (table));
prev = head = (struct ipxpcb *)
- &((struct ipxpcbtable *)off)->ipxpt_queue.cqh_first;
- next = table.ipxpt_queue.cqh_first;
+ &CIRCLEQ_FIRST(&((struct ipxpcbtable *)off)->ipxpt_queue);
+ next = CIRCLEQ_FIRST(&table.ipxpt_queue);
while (next != head) {
kread((u_long)next, &ipxpcb, sizeof (ipxpcb));
- if (ipxpcb.ipxp_queue.cqe_prev != prev) {
+ if (CIRCLEQ_PREV(&ipxpcb, ipxp_queue) != prev) {
printf("???\n");
break;
}
prev = next;
- next = ipxpcb.ipxp_queue.cqe_next;
+ next = CIRCLEQ_NEXT(&ipxpcb, ipxp_queue);
if (!aflag && ipx_nullhost(ipxpcb.ipxp_faddr) )
continue;
diff --git a/usr.bin/netstat/mroute.c b/usr.bin/netstat/mroute.c
index 5393b11b463..bd60dd9bc32 100644
--- a/usr.bin/netstat/mroute.c
+++ b/usr.bin/netstat/mroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mroute.c,v 1.14 2005/03/30 07:50:11 deraadt Exp $ */
+/* $OpenBSD: mroute.c,v 1.15 2005/10/17 19:09:36 otto Exp $ */
/* $NetBSD: mroute.c,v 1.10 1996/05/11 13:51:27 mycroft Exp $ */
/*
@@ -168,7 +168,7 @@ mroutepr(u_long mrpaddr, u_long mfchashtbladdr, u_long mfchashaddr, u_long vifad
for (i = 0; i <= mfchash; ++i) {
kread((u_long)&mfchashtbl[i], &mfcp, sizeof(mfcp));
- for (; mfcp != 0; mfcp = mfc.mfc_hash.le_next) {
+ for (; mfcp != 0; mfcp = LIST_NEXT(&mfc, mfc_hash)) {
if (!banner_printed) {
printf("\nMulticast Forwarding Cache\n %s%s",
"Hash Origin Mcastgroup ",