On 15/03/13(Fri) 16:59, Ted Unangst wrote:
> Replace LIST_END with NULL, for clarity and less characters.
> 
> frag6.c was definitely a big fan of LIST_END.

Careful, I had to edit your diff to be able to apply it correctly.

I'm mostly ok with your diff, but in some place I think that it would be
better to change the whole for() loop by a LIST_FOREACH{,_SAFE}() instead
of only replacing the LIST_END, see below.

> 
> Index: netinet/if_ether.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/if_ether.c,v
> retrieving revision 1.97
> diff -u -p -r1.97 if_ether.c
> --- netinet/if_ether.c        7 Mar 2013 09:03:16 -0000       1.97
> +++ netinet/if_ether.c        15 Mar 2013 20:46:48 -0000
> @@ -126,8 +126,7 @@ arptimer(void *arg)
>  
>       s = splsoftnet();
>       timeout_add_sec(to, arpt_prune);
> -     for (la = LIST_FIRST(&llinfo_arp); la != LIST_END(&llinfo_arp);
> -         la = nla) {
> +     for (la = LIST_FIRST(&llinfo_arp); la != NULL; la = nla) {
>               struct rtentry *rt = la->la_rt;

Maybe you want to use a LIST_FOREACH_SAFE() here.


> Index: netinet/ip_carp.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet/ip_carp.c,v
> retrieving revision 1.198
> diff -u -p -r1.198 ip_carp.c
> --- netinet/ip_carp.c 8 Oct 2012 18:48:25 -0000       1.198
> +++ netinet/ip_carp.c 15 Mar 2013 20:47:24 -0000
> @@ -1028,8 +1028,7 @@ carp_destroy_vhosts(struct carp_softc *s
>       /* XXX bow out? */
>       struct carp_vhost_entry *vhe, *nvhe;
>  
> -     for (vhe = LIST_FIRST(&sc->carp_vhosts);
> -          vhe != LIST_END(&sc->carp_vhosts); vhe = nvhe) {
> +     for (vhe = LIST_FIRST(&sc->carp_vhosts); vhe != NULL; vhe = nvhe) {
>               nvhe = LIST_NEXT(vhe, vhost_entries);
>               free(vhe, M_DEVBUF);

Same here, LIST_FOREACH_SAFE() sounds more appropriate to me.

> Index: netinet/ip_input.c
> ===================================================================
> [..]
> -     for (fp = LIST_FIRST(&ipq); fp != LIST_END(&ipq); fp = nfp) {
> +     for (fp = LIST_FIRST(&ipq); fp != NULL; fp = nfp) {
>               nfp = LIST_NEXT(fp, ipq_q);

Same here.

> Index: netinet6/in6.c
> ===================================================================
> RCS file: /cvs/src/sys/netinet6/in6.c,v
> retrieving revision 1.105
> diff -u -p -r1.105 in6.c
> --- netinet6/in6.c    7 Mar 2013 09:03:16 -0000       1.105
> +++ netinet6/in6.c    15 Mar 2013 20:50:58 -0000
> @@ -1594,7 +1594,7 @@ in6_savemkludge(struct in6_ifaddr *oia)
>       IFP_TO_IA6(oia->ia_ifp, ia);
>       if (ia) {       /* there is another address */
>               for (in6m = LIST_FIRST(&oia->ia6_multiaddrs);
> -                 in6m != LIST_END(&oia->ia6_multiaddrs); in6m = next) {
> +                 in6m != NULL; in6m = next) {
>                       next = LIST_NEXT(in6m, in6m_entry);
>                       ifafree(&in6m->in6m_ia->ia_ifa);
>                       ia->ia_ifa.ifa_refcnt++;
> @@ -1612,7 +1612,7 @@ in6_savemkludge(struct in6_ifaddr *oia)
>                       panic("in6_savemkludge: no kludge space");
>  
>               for (in6m = LIST_FIRST(&oia->ia6_multiaddrs);
> -                 in6m != LIST_END(&oia->ia6_multiaddrs); in6m = next) {
> +                 in6m != NULL; in6m = next) {
>                       next = LIST_NEXT(in6m, in6m_entry);
>                       ifafree(&in6m->in6m_ia->ia_ifa); /* release reference */
>                       in6m->in6m_ia = NULL;

These two can also be replaced by a LIST_FOREACH_SAFE().

> @@ -1635,8 +1635,7 @@ in6_restoremkludge(struct in6_ifaddr *ia
>               if (mk->mk_ifp == ifp) {
>                       struct in6_multi *in6m, *next;
>  
> -                     for (in6m = LIST_FIRST(&mk->mk_head);
> -                         in6m != LIST_END(&mk->mk_head);
> +                     for (in6m = LIST_FIRST(&mk->mk_head); in6m != NULL;
>                           in6m = next) {
>                               next = LIST_NEXT(in6m, in6m_entry);
>                               in6m->in6m_ia = ia;

And this one look like a simple LIST_FOREACH() to me, isn't i?

Reply via email to