From f633f78f2a4eb33688e4356f6c0f5ff0ef55ed25 Mon Sep 17 00:00:00 2001 From: Alexander Bluhm Date: Wed, 28 Aug 2013 21:19:17 +0000 Subject: Replace hand-crafted for loop over in_ifaddr with FOREACH macro. OK mpi@ --- sys/netinet/in_var.h | 20 +++++++++----------- 1 file 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 -- cgit v1.2.3