summaryrefslogtreecommitdiff
path: root/sys/netinet
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2013-08-28 21:19:17 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2013-08-28 21:19:17 +0000
commitf633f78f2a4eb33688e4356f6c0f5ff0ef55ed25 (patch)
treee74e384ef67f45027c648ed5828244eb61a71c30 /sys/netinet
parent36cf4c2a3e476cc6f26d736acddadfb3af09ee0c (diff)
Replace hand-crafted for loop over in_ifaddr with FOREACH macro.
OK mpi@
Diffstat (limited to 'sys/netinet')
-rw-r--r--sys/netinet/in_var.h20
1 files changed, 9 insertions, 11 deletions
diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h
index 1af8e80ab84..b6d55289a2f 100644
--- a/sys/netinet/in_var.h
+++ b/sys/netinet/in_var.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_var.h,v 1.20 2013/05/31 19:16:52 mpi Exp $ */
+/* $OpenBSD: in_var.h,v 1.21 2013/08/28 21:19:16 bluhm Exp $ */
/* $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $ */
/*
@@ -92,17 +92,16 @@ void in_socktrim(struct sockaddr_in *);
* Macro for finding the interface (ifnet structure) corresponding to one
* of our IP addresses.
*/
-#define INADDR_TO_IFP(addr, ifp, rdomain) \
+#define INADDR_TO_IFP(addr, ifp, rtableid) \
/* struct in_addr addr; */ \
/* struct ifnet *ifp; */ \
do { \
struct in_ifaddr *ia; \
\
- for (ia = TAILQ_FIRST(&in_ifaddr); ia != NULL && \
- (ia->ia_ifp->if_rdomain != rtable_l2(rdomain) || \
- ia->ia_addr.sin_addr.s_addr != (addr).s_addr); \
- ia = TAILQ_NEXT(ia, ia_list)) \
- continue; \
+ TAILQ_FOREACH(ia, &in_ifaddr, ia_list) \
+ if (ia->ia_ifp->if_rdomain == rtable_l2(rtableid) && \
+ ia->ia_addr.sin_addr.s_addr == (addr).s_addr) \
+ break; \
(ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \
} while (/* CONSTCOND */ 0)
@@ -114,10 +113,9 @@ do { \
/* struct ifnet *ifp; */ \
/* struct in_ifaddr *ia; */ \
do { \
- for ((ia) = TAILQ_FIRST(&in_ifaddr); \
- (ia) != NULL && (ia)->ia_ifp != (ifp); \
- (ia) = TAILQ_NEXT((ia), ia_list)) \
- continue; \
+ TAILQ_FOREACH((ia), &in_ifaddr, ia_list) \
+ if ((ia)->ia_ifp == (ifp)) \
+ break; \
} while (/* CONSTCOND */ 0)
#endif