Maybe I'm just easily confused, but when I see LIST_END() I tend to
think it's going to be the last element in the list. I think NULL is
clearer. As per the man page, "The SLIST_END(), LIST_END(),
SIMPLEQ_END() and TAILQ_END() macros are provided for symmetry
with CIRCLEQ_END(). They expand to NULL and don't serve any
useful purpose."
There are very few CIRCLEQs in the kernel, and I consider it unlikely
that we'd ever convert some of the existing lists to them, so I'd like
to zap some of the LIST_END macros. As so:
Strong opinions?
Index: if.c
===================================================================
RCS file: /cvs/src/sys/net/if.c,v
retrieving revision 1.250
diff -u -p -r1.250 if.c
--- if.c 7 Mar 2013 09:40:19 -0000 1.250
+++ if.c 7 Mar 2013 21:12:11 -0000
@@ -1693,7 +1693,7 @@ ifconf(u_long cmd, caddr_t data)
ifrp = ifc->ifc_req;
for (ifp = TAILQ_FIRST(&ifnet); space >= sizeof(ifr) &&
- ifp != TAILQ_END(&ifnet); ifp = TAILQ_NEXT(ifp, if_list)) {
+ ifp != NULL; ifp = TAILQ_NEXT(ifp, if_list)) {
bcopy(ifp->if_xname, ifr.ifr_name, IFNAMSIZ);
if (TAILQ_EMPTY(&ifp->if_addrlist)) {
bzero((caddr_t)&ifr.ifr_addr, sizeof(ifr.ifr_addr));
@@ -1705,7 +1705,7 @@ ifconf(u_long cmd, caddr_t data)
} else
for (ifa = TAILQ_FIRST(&ifp->if_addrlist);
space >= sizeof (ifr) &&
- ifa != TAILQ_END(&ifp->if_addrlist);
+ ifa != NULL;
ifa = TAILQ_NEXT(ifa, ifa_list)) {
struct sockaddr *sa = ifa->ifa_addr;
#if defined(COMPAT_43) || defined(COMPAT_LINUX)
Index: if_bridge.c
===================================================================
RCS file: /cvs/src/sys/net/if_bridge.c,v
retrieving revision 1.205
diff -u -p -r1.205 if_bridge.c
--- if_bridge.c 23 Jan 2013 13:28:36 -0000 1.205
+++ if_bridge.c 7 Mar 2013 21:12:22 -0000
@@ -322,7 +322,7 @@ bridge_ioctl(struct ifnet *ifp, u_long c
TAILQ_FOREACH(p, &sc->sc_spanlist, next)
if (p->ifp == ifs)
break;
- if (p != TAILQ_END(&sc->sc_spanlist)) {
+ if (p != NULL) {
error = EBUSY;
break;
}
@@ -424,7 +424,7 @@ bridge_ioctl(struct ifnet *ifp, u_long c
if (p->ifp == ifs)
break;
}
- if (p != TAILQ_END(&sc->sc_spanlist)) {
+ if (p != NULL) {
error = EEXIST;
break;
}
@@ -450,7 +450,7 @@ bridge_ioctl(struct ifnet *ifp, u_long c
break;
}
}
- if (p == TAILQ_END(&sc->sc_spanlist)) {
+ if (p == NULL) {
error = ENOENT;
break;
}
@@ -1053,7 +1053,7 @@ bridge_output(struct ifnet *ifp, struct
sc->sc_if.if_oerrors++;
continue;
}
- if (TAILQ_NEXT(p, next) == TAILQ_END(&sc->sc_iflist)) {
+ if (TAILQ_NEXT(p, next) == NULL) {
used = 1;
mc = m;
} else {
@@ -1397,7 +1397,7 @@ bridge_input(struct ifnet *ifp, struct e
if (ifl->ifp->if_type == IFT_ETHER)
break;
}
- if (ifl != TAILQ_END(&sc->sc_iflist)) {
+ if (ifl != NULL) {
m->m_pkthdr.rcvif = ifl->ifp;
m->m_pkthdr.rdomain = ifl->ifp->if_rdomain;
#if NBPFILTER > 0
@@ -1552,7 +1552,7 @@ bridge_broadcast(struct bridge_softc *sc
bridge_localbroadcast(sc, dst_if, eh, m);
/* If last one, reuse the passed-in mbuf */
- if (TAILQ_NEXT(p, next) == TAILQ_END(&sc->sc_iflist)) {
+ if (TAILQ_NEXT(p, next) == NULL) {
mc = m;
used = 1;
} else {
@@ -1708,7 +1708,7 @@ bridge_rtupdate(struct bridge_softc *sc,
h = bridge_hash(sc, ea);
p = LIST_FIRST(&sc->sc_rts[h]);
- if (p == LIST_END(&sc->sc_rts[h])) {
+ if (p == NULL) {
if (sc->sc_brtcnt >= sc->sc_brtmax)
goto done;
p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT);
@@ -1768,7 +1768,7 @@ bridge_rtupdate(struct bridge_softc *sc,
goto want;
}
- if (p == LIST_END(&sc->sc_rts[h])) {
+ if (p == NULL) {
if (sc->sc_brtcnt >= sc->sc_brtmax)
goto done;
p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT);
@@ -1787,7 +1787,7 @@ bridge_rtupdate(struct bridge_softc *sc,
sc->sc_brtcnt++;
goto want;
}
- } while (p != LIST_END(&sc->sc_rts[h]));
+ } while (p != NULL);
done:
ifp = NULL;
@@ -1871,7 +1871,7 @@ bridge_rtage(struct bridge_softc *sc)
for (i = 0; i < BRIDGE_RTABLE_SIZE; i++) {
n = LIST_FIRST(&sc->sc_rts[i]);
- while (n != LIST_END(&sc->sc_rts[i])) {
+ while (n != NULL) {
if ((n->brt_flags & IFBAF_TYPEMASK) == IFBAF_STATIC) {
n->brt_age = !n->brt_age;
if (n->brt_age)
@@ -1937,7 +1937,7 @@ bridge_rtflush(struct bridge_softc *sc,
for (i = 0; i < BRIDGE_RTABLE_SIZE; i++) {
n = LIST_FIRST(&sc->sc_rts[i]);
- while (n != LIST_END(&sc->sc_rts[i])) {
+ while (n != NULL) {
if (full ||
(n->brt_flags & IFBAF_TYPEMASK) == IFBAF_DYNAMIC) {
p = LIST_NEXT(n, brt_next);
@@ -1987,7 +1987,7 @@ bridge_rtdelete(struct bridge_softc *sc,
*/
for (i = 0; i < BRIDGE_RTABLE_SIZE; i++) {
n = LIST_FIRST(&sc->sc_rts[i]);
- while (n != LIST_END(&sc->sc_rts[i])) {
+ while (n != NULL) {
if (n->brt_if != ifp) {
/* Not ours */
n = LIST_NEXT(n, brt_next);
Index: if_ethersubr.c
===================================================================
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.153
diff -u -p -r1.153 if_ethersubr.c
--- if_ethersubr.c 18 Jan 2013 12:10:11 -0000 1.153
+++ if_ethersubr.c 7 Mar 2013 21:11:10 -0000
@@ -815,7 +815,7 @@ ether_ifdetach(ifp)
struct ether_multi *enm;
for (enm = LIST_FIRST(&ac->ac_multiaddrs);
- enm != LIST_END(&ac->ac_multiaddrs);
+ enm != NULL;
enm = LIST_FIRST(&ac->ac_multiaddrs)) {
LIST_REMOVE(enm, enm_list);
free(enm, M_IFMADDR);
Index: rtsock.c
===================================================================
RCS file: /cvs/src/sys/net/rtsock.c,v
retrieving revision 1.124
diff -u -p -r1.124 rtsock.c
--- rtsock.c 7 Mar 2013 09:03:16 -0000 1.124
+++ rtsock.c 7 Mar 2013 21:12:34 -0000
@@ -1346,8 +1346,7 @@ sysctl_iflist(int af, struct walkarg *w)
w->w_where += len;
}
ifpaddr = 0;
- while ((ifa = TAILQ_NEXT(ifa, ifa_list)) !=
- TAILQ_END(&ifp->if_addrlist)) {
+ while ((ifa = TAILQ_NEXT(ifa, ifa_list)) != NULL) {
if (af && af != ifa->ifa_addr->sa_family)
continue;
ifaaddr = ifa->ifa_addr;