diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2008-11-08 12:54:59 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2008-11-08 12:54:59 +0000 |
commit | 8082b519e8eb7d4b72eb0bbea42ac126c4ce8d8c (patch) | |
tree | 1db91e3f2a917fe69d1b56dd56852adb9458e7a0 | |
parent | 7b3a9f02e74287ece0a22b140146ed8e4ace729d (diff) |
fix macros up so they use the do { } while (/* CONSTCOND */ 0) idiom
ok deraadt@ otto@
-rw-r--r-- | sys/netinet/if_ether.h | 46 | ||||
-rw-r--r-- | sys/netinet/in_var.h | 122 | ||||
-rw-r--r-- | sys/netinet/ip6.h | 10 | ||||
-rw-r--r-- | sys/netinet/ip_ipsp.h | 29 | ||||
-rw-r--r-- | sys/netinet/tcp_timer.h | 17 | ||||
-rw-r--r-- | sys/netinet/tcp_var.h | 6 |
6 files changed, 116 insertions, 114 deletions
diff --git a/sys/netinet/if_ether.h b/sys/netinet/if_ether.h index 9e61e09cc4a..6945c22c5ee 100644 --- a/sys/netinet/if_ether.h +++ b/sys/netinet/if_ether.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.h,v 1.43 2008/10/31 21:08:33 claudio Exp $ */ +/* $OpenBSD: if_ether.h,v 1.44 2008/11/08 12:54:58 dlg Exp $ */ /* $NetBSD: if_ether.h,v 1.22 1996/05/11 13:00:00 mycroft Exp $ */ /* @@ -97,14 +97,14 @@ struct ether_header { #define ETHER_MAP_IP_MULTICAST(ipaddr, enaddr) \ /* struct in_addr *ipaddr; */ \ /* u_int8_t enaddr[ETHER_ADDR_LEN]; */ \ -{ \ +do { \ (enaddr)[0] = 0x01; \ (enaddr)[1] = 0x00; \ (enaddr)[2] = 0x5e; \ (enaddr)[3] = ((u_int8_t *)ipaddr)[1] & 0x7f; \ (enaddr)[4] = ((u_int8_t *)ipaddr)[2]; \ (enaddr)[5] = ((u_int8_t *)ipaddr)[3]; \ -} +} while (/* CONSTCOND */ 0) /* * Macro to map an IPv6 multicast address to an Ethernet multicast address. @@ -114,14 +114,14 @@ struct ether_header { #define ETHER_MAP_IPV6_MULTICAST(ip6addr, enaddr) \ /* struct in6_addr *ip6addr; */ \ /* u_int8_t enaddr[ETHER_ADDR_LEN]; */ \ -{ \ +do { \ (enaddr)[0] = 0x33; \ (enaddr)[1] = 0x33; \ (enaddr)[2] = ((u_int8_t *)ip6addr)[12]; \ (enaddr)[3] = ((u_int8_t *)ip6addr)[13]; \ (enaddr)[4] = ((u_int8_t *)ip6addr)[14]; \ (enaddr)[5] = ((u_int8_t *)ip6addr)[15]; \ -} +} while (/* CONSTCOND */ 0) #endif /* @@ -241,13 +241,13 @@ struct ether_multistep { /* u_int8_t addrhi[ETHER_ADDR_LEN]; */ \ /* struct arpcom *ac; */ \ /* struct ether_multi *enm; */ \ -{ \ +do { \ for ((enm) = LIST_FIRST(&(ac)->ac_multiaddrs); \ (enm) != LIST_END(&(ac)->ac_multiaddrs) && \ (bcmp((enm)->enm_addrlo, (addrlo), ETHER_ADDR_LEN) != 0 || \ bcmp((enm)->enm_addrhi, (addrhi), ETHER_ADDR_LEN) != 0); \ (enm) = LIST_NEXT((enm), enm_list)); \ -} +} while (/* CONSTCOND */ 0) /* * Macro to step through all of the ether_multi records, one at a time. @@ -256,22 +256,22 @@ struct ether_multistep { * and get the first record. Both macros return a NULL "enm" when there * are no remaining records. */ -#define ETHER_NEXT_MULTI(step, enm) \ - /* struct ether_multistep step; */ \ - /* struct ether_multi *enm; */ \ -{ \ - if (((enm) = (step).e_enm) != NULL) \ - (step).e_enm = LIST_NEXT((enm), enm_list); \ -} - -#define ETHER_FIRST_MULTI(step, ac, enm) \ - /* struct ether_multistep step; */ \ - /* struct arpcom *ac; */ \ - /* struct ether_multi *enm; */ \ -{ \ - (step).e_enm = LIST_FIRST(&(ac)->ac_multiaddrs); \ - ETHER_NEXT_MULTI((step), (enm)); \ -} +#define ETHER_NEXT_MULTI(step, enm) \ + /* struct ether_multistep step; */ \ + /* struct ether_multi *enm; */ \ +do { \ + if (((enm) = (step).e_enm) != NULL) \ + (step).e_enm = LIST_NEXT((enm), enm_list); \ +} while (/* CONSTCOND */ 0) + +#define ETHER_FIRST_MULTI(step, ac, enm) \ + /* struct ether_multistep step; */ \ + /* struct arpcom *ac; */ \ + /* struct ether_multi *enm; */ \ +do { \ + (step).e_enm = LIST_FIRST(&(ac)->ac_multiaddrs); \ + ETHER_NEXT_MULTI((step), (enm)); \ +} while (/* CONSTCOND */ 0) #ifdef _KERNEL diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index c1cd6412ede..8ebf216cb61 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_var.h,v 1.10 2007/07/20 19:00:35 claudio Exp $ */ +/* $OpenBSD: in_var.h,v 1.11 2008/11/08 12:54:58 dlg Exp $ */ /* $NetBSD: in_var.h,v 1.16 1996/02/13 23:42:15 christos Exp $ */ /* @@ -89,32 +89,32 @@ 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) \ - /* struct in_addr addr; */ \ - /* struct ifnet *ifp; */ \ -{ \ - struct in_ifaddr *ia; \ -\ +#define INADDR_TO_IFP(addr, ifp) \ + /* struct in_addr addr; */ \ + /* struct ifnet *ifp; */ \ +do { \ + struct in_ifaddr *ia; \ + \ for (ia = TAILQ_FIRST(&in_ifaddr); ia != TAILQ_END(&in_ifaddr) && \ - ia->ia_addr.sin_addr.s_addr != (addr).s_addr; \ - ia = TAILQ_NEXT(ia, ia_list)) \ - continue; \ - (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \ -} + ia->ia_addr.sin_addr.s_addr != (addr).s_addr; \ + ia = TAILQ_NEXT(ia, ia_list)) \ + continue; \ + (ifp) = (ia == NULL) ? NULL : ia->ia_ifp; \ +} while (/* CONSTCOND */ 0) /* * Macro for finding the internet address structure (in_ifaddr) corresponding * to a given interface (ifnet structure). */ -#define IFP_TO_IA(ifp, ia) \ - /* struct ifnet *ifp; */ \ - /* struct in_ifaddr *ia; */ \ -{ \ - for ((ia) = TAILQ_FIRST(&in_ifaddr); \ - (ia) != TAILQ_END(&in_ifaddr) && (ia)->ia_ifp != (ifp); \ - (ia) = TAILQ_NEXT((ia), ia_list)) \ - continue; \ -} +#define IFP_TO_IA(ifp, ia) \ + /* struct ifnet *ifp; */ \ + /* struct in_ifaddr *ia; */ \ +do { \ + for ((ia) = TAILQ_FIRST(&in_ifaddr); \ + (ia) != TAILQ_END(&in_ifaddr) && (ia)->ia_ifp != (ifp); \ + (ia) = TAILQ_NEXT((ia), ia_list)) \ + continue; \ +} while (/* CONSTCOND */ 0) #endif /* @@ -157,23 +157,23 @@ struct in_multistep { * Macro for looking up the in_multi record for a given IP multicast address * on a given interface. If no matching record is found, "inm" returns NULL. */ -#define IN_LOOKUP_MULTI(addr, ifp, inm) \ - /* struct in_addr addr; */ \ - /* struct ifnet *ifp; */ \ - /* struct in_multi *inm; */ \ -{ \ - struct in_ifaddr *ia; \ -\ - IFP_TO_IA((ifp), ia); \ - if (ia == NULL) \ - (inm) = NULL; \ - else \ - for ((inm) = LIST_FIRST(&ia->ia_multiaddrs); \ - (inm) != LIST_END(&ia->ia_multiaddrs) && \ - (inm)->inm_addr.s_addr != (addr).s_addr; \ - (inm) = LIST_NEXT(inm, inm_list)) \ - continue; \ -} +#define IN_LOOKUP_MULTI(addr, ifp, inm) \ + /* struct in_addr addr; */ \ + /* struct ifnet *ifp; */ \ + /* struct in_multi *inm; */ \ +do { \ + struct in_ifaddr *ia; \ + \ + IFP_TO_IA((ifp), ia); \ + if (ia == NULL) \ + (inm) = NULL; \ + else \ + for ((inm) = LIST_FIRST(&ia->ia_multiaddrs); \ + (inm) != LIST_END(&ia->ia_multiaddrs) && \ + (inm)->inm_addr.s_addr != (addr).s_addr; \ + (inm) = LIST_NEXT(inm, inm_list)) \ + continue; \ +} while (/* CONSTCOND */ 0) /* * Macro to step through all of the in_multi records, one at a time. @@ -182,31 +182,31 @@ struct in_multistep { * and get the first record. Both macros return a NULL "inm" when there * are no remaining records. */ -#define IN_NEXT_MULTI(step, inm) \ - /* struct in_multistep step; */ \ - /* struct in_multi *inm; */ \ -{ \ - if (((inm) = (step).i_inm) != NULL) \ - (step).i_inm = LIST_NEXT((inm), inm_list); \ - else \ - while ((step).i_ia != NULL) { \ +#define IN_NEXT_MULTI(step, inm) \ + /* struct in_multistep step; */ \ + /* struct in_multi *inm; */ \ +do { \ + if (((inm) = (step).i_inm) != NULL) \ + (step).i_inm = LIST_NEXT((inm), inm_list); \ + else \ + while ((step).i_ia != NULL) { \ (inm) = LIST_FIRST(&(step).i_ia->ia_multiaddrs); \ - (step).i_ia = TAILQ_NEXT((step).i_ia, ia_list); \ - if ((inm) != NULL) { \ + (step).i_ia = TAILQ_NEXT((step).i_ia, ia_list); \ + if ((inm) != NULL) { \ (step).i_inm = LIST_NEXT((inm), inm_list); \ - break; \ - } \ - } \ -} - -#define IN_FIRST_MULTI(step, inm) \ - /* struct in_multistep step; */ \ - /* struct in_multi *inm; */ \ -{ \ - (step).i_ia = TAILQ_FIRST(&in_ifaddr); \ - (step).i_inm = NULL; \ - IN_NEXT_MULTI((step), (inm)); \ -} + break; \ + } \ + } \ +} while (/* CONSTCOND */ 0) + +#define IN_FIRST_MULTI(step, inm) \ + /* struct in_multistep step; */ \ + /* struct in_multi *inm; */ \ +do { \ + (step).i_ia = TAILQ_FIRST(&in_ifaddr); \ + (step).i_inm = NULL; \ + IN_NEXT_MULTI((step), (inm)); \ +} while (/* CONSTCOND */ 0) int in_ifinit(struct ifnet *, struct in_ifaddr *, struct sockaddr_in *, int); diff --git a/sys/netinet/ip6.h b/sys/netinet/ip6.h index a9c09536445..c9d54fc352a 100644 --- a/sys/netinet/ip6.h +++ b/sys/netinet/ip6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6.h,v 1.18 2006/12/09 01:12:28 itojun Exp $ */ +/* $OpenBSD: ip6.h,v 1.19 2008/11/08 12:54:58 dlg Exp $ */ /* $KAME: ip6.h,v 1.45 2003/06/05 04:46:38 keiichi Exp $ */ /* @@ -274,7 +274,7 @@ struct ip6_frag { * IP6_EXTHDR_GET0 does the same, except that it aligns the structure at the * very top of mbuf. GET0 is likely to make memory copy than GET. */ -#define IP6_EXTHDR_GET(val, typ, m, off, len) \ +#define IP6_EXTHDR_GET(val, typ, m, off, len) \ do { \ struct mbuf *t; \ int tmp; \ @@ -291,9 +291,9 @@ do { \ (m) = NULL; \ } \ } \ -} while (0) +} while (/* CONSTCOND */ 0) -#define IP6_EXTHDR_GET0(val, typ, m, off, len) \ +#define IP6_EXTHDR_GET0(val, typ, m, off, len) \ do { \ struct mbuf *t; \ if ((off) == 0 && (m)->m_len >= len) \ @@ -309,6 +309,6 @@ do { \ (m) = NULL; \ } \ } \ -} while (0) +} while (/* CONSTCOND */ 0) #endif /* _KERNEL */ #endif /* _NETINET_IP6_H_ */ diff --git a/sys/netinet/ip_ipsp.h b/sys/netinet/ip_ipsp.h index 06fcc70f549..01bf7c077e5 100644 --- a/sys/netinet/ip_ipsp.h +++ b/sys/netinet/ip_ipsp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_ipsp.h,v 1.135 2006/11/24 13:52:14 reyk Exp $ */ +/* $OpenBSD: ip_ipsp.h,v 1.136 2008/11/08 12:54:58 dlg Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), * Angelos D. Keromytis (kermit@csd.uch.gr), @@ -484,19 +484,20 @@ extern struct xformsw xformsw[], *xformswNXFORMSW; /* Traverse spi chain and get attributes */ -#define SPI_CHAIN_ATTRIB(have, TDB_DIR, TDBP) do {\ - int s = spltdb(); \ - struct tdb *tmptdb = (TDBP); \ - \ - (have) = 0; \ - while (tmptdb && tmptdb->tdb_xform) { \ - if (tmptdb == NULL || tmptdb->tdb_flags & TDBF_INVALID) \ - break; \ - (have) |= TDB_ATTRIB(tmptdb); \ - tmptdb = tmptdb->TDB_DIR; \ - } \ - splx(s); \ -} while (0) +#define SPI_CHAIN_ATTRIB(have, TDB_DIR, TDBP) \ +do { \ + int s = spltdb(); \ + struct tdb *tmptdb = (TDBP); \ + \ + (have) = 0; \ + while (tmptdb && tmptdb->tdb_xform) { \ + if (tmptdb == NULL || tmptdb->tdb_flags & TDBF_INVALID) \ + break; \ + (have) |= TDB_ATTRIB(tmptdb); \ + tmptdb = tmptdb->TDB_DIR; \ + } \ + splx(s); \ +} while (/* CONSTCOND */ 0) /* Misc. */ extern char *inet_ntoa4(struct in_addr); diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h index 805c5bd0628..6f0dceda02a 100644 --- a/sys/netinet/tcp_timer.h +++ b/sys/netinet/tcp_timer.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.h,v 1.11 2007/11/24 12:59:28 jmc Exp $ */ +/* $OpenBSD: tcp_timer.h,v 1.12 2008/11/08 12:54:58 dlg Exp $ */ /* $NetBSD: tcp_timer.h,v 1.6 1995/03/26 20:32:37 jtc Exp $ */ /* @@ -130,13 +130,14 @@ const char *tcptimers[] = /* * Force a time value to be in a certain range. */ -#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \ - (tv) = (value); \ - if ((tv) < (tvmin)) \ - (tv) = (tvmin); \ - else if ((tv) > (tvmax)) \ - (tv) = (tvmax); \ -} +#define TCPT_RANGESET(tv, value, tvmin, tvmax) \ +do { \ + (tv) = (value); \ + if ((tv) < (tvmin)) \ + (tv) = (tvmin); \ + else if ((tv) > (tvmax)) \ + (tv) = (tvmax); \ +} while (/* CONSTCOND */ 0) #ifdef _KERNEL typedef void (*tcp_timer_func_t)(void *); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index d197b088401..dcd291b0124 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.89 2008/05/24 19:48:32 thib Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.90 2008/11/08 12:54:58 dlg Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -218,7 +218,7 @@ do { \ (tp)->t_flags |= TF_DELACK; \ TCP_RESTART_DELACK(tp); \ } \ -} while (/*CONSTCOND*/0) +} while (/* CONSTCOND */ 0) #define TCP_CLEAR_DELACK(tp) \ do { \ @@ -226,7 +226,7 @@ do { \ (tp)->t_flags &= ~TF_DELACK; \ timeout_del(&(tp)->t_delack_to); \ } \ -} while (/*CONSTCOND*/0) +} while (/* CONSTCOND */ 0) /* * Handy way of passing around TCP option info. |