diff options
author | friehm <friehm@cvs.openbsd.org> | 2017-07-24 11:00:02 +0000 |
---|---|---|
committer | friehm <friehm@cvs.openbsd.org> | 2017-07-24 11:00:02 +0000 |
commit | f78ad8e188de00c6aaac2c42367fabb8e931405b (patch) | |
tree | 00ae8c0c6463d63c8f14fac5f1769d6bf1884b9d | |
parent | c764e5c743b5697032f2dde33bbb45521d0f5bce (diff) |
Unify ROUNDUP macros for parsing route messages.
Use the macro from route(8) / ospf6d(8) since it works also with argument 0.
OK claudio@
-rw-r--r-- | sbin/dhclient/kroute.c | 6 | ||||
-rw-r--r-- | sbin/slaacd/frontend.c | 6 | ||||
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 6 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/kroute.c | 8 | ||||
-rw-r--r-- | usr.sbin/eigrpd/kroute.c | 6 | ||||
-rw-r--r-- | usr.sbin/ldpd/kroute.c | 6 | ||||
-rw-r--r-- | usr.sbin/ospfd/kroute.c | 6 | ||||
-rw-r--r-- | usr.sbin/ripd/kroute.c | 8 | ||||
-rw-r--r-- | usr.sbin/snmpd/kroute.c | 6 |
9 files changed, 29 insertions, 29 deletions
diff --git a/sbin/dhclient/kroute.c b/sbin/dhclient/kroute.c index 8e746024bb8..5519995f4ea 100644 --- a/sbin/dhclient/kroute.c +++ b/sbin/dhclient/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.114 2017/07/23 13:44:53 krw Exp $ */ +/* $OpenBSD: kroute.c,v 1.115 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright 2012 Kenneth R Westerback <krw@openbsd.org> @@ -47,8 +47,8 @@ #include "log.h" #include "privsep.h" -#define ROUNDUP(a) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : \ - sizeof(long)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) /* * flush_unpriv_ibuf makes sure queued messages are delivered to the diff --git a/sbin/slaacd/frontend.c b/sbin/slaacd/frontend.c index 8bd49e2f1ad..f78c9802292 100644 --- a/sbin/slaacd/frontend.c +++ b/sbin/slaacd/frontend.c @@ -1,4 +1,4 @@ -/* $OpenBSD: frontend.c,v 1.4 2017/07/14 09:29:40 florian Exp $ */ +/* $OpenBSD: frontend.c,v 1.5 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright (c) 2017 Florian Obser <florian@openbsd.org> @@ -684,8 +684,8 @@ handle_route_message(struct rt_msghdr *rtm, struct sockaddr **rti_info) } -#define ROUNDUP(a) \ - (((a) & (sizeof(long) - 1)) ? (1 + ((a) | (sizeof(long) - 1))) : (a)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 8f6687ae2da..d885fe50f56 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.215 2017/05/31 10:47:21 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.216 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2446,8 +2446,8 @@ prefixlen2mask6(u_int8_t prefixlen) return (&mask); } -#define ROUNDUP(a) \ - (((a) & (sizeof(long) - 1)) ? (1 + ((a) | (sizeof(long) - 1))) : (a)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) diff --git a/usr.sbin/dvmrpd/kroute.c b/usr.sbin/dvmrpd/kroute.c index 19726ee175b..ac4376046d0 100644 --- a/usr.sbin/dvmrpd/kroute.c +++ b/usr.sbin/dvmrpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.13 2015/12/07 19:14:49 mmcc Exp $ */ +/* $OpenBSD: kroute.c,v 1.14 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -275,8 +275,8 @@ if_announce(void *msg) } /* rtsock */ -#define ROUNDUP(a, size) \ - (((a) & ((size) - 1)) ? (1 + ((a) | ((size) - 1))) : (a)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) @@ -287,7 +287,7 @@ get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) if (addrs & (1 << i)) { rti_info[i] = sa; sa = (struct sockaddr *)((char *)(sa) + - ROUNDUP(sa->sa_len, sizeof(long))); + ROUNDUP(sa->sa_len)); } else rti_info[i] = NULL; } diff --git a/usr.sbin/eigrpd/kroute.c b/usr.sbin/eigrpd/kroute.c index fb7511937dc..35c73bf85c1 100644 --- a/usr.sbin/eigrpd/kroute.c +++ b/usr.sbin/eigrpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.17 2017/02/22 14:24:50 renato Exp $ */ +/* $OpenBSD: kroute.c,v 1.18 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright (c) 2015 Renato Westphal <renato@openbsd.org> @@ -804,8 +804,8 @@ prefixlen_classful(in_addr_t ina) return (8); } -#define ROUNDUP(a) \ - (((a) & (sizeof(long) - 1)) ? (1 + ((a) | (sizeof(long) - 1))) : (a)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) static void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) diff --git a/usr.sbin/ldpd/kroute.c b/usr.sbin/ldpd/kroute.c index 7e20c40f5c1..3b0fd90f7cb 100644 --- a/usr.sbin/ldpd/kroute.c +++ b/usr.sbin/ldpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.65 2017/03/04 00:21:48 renato Exp $ */ +/* $OpenBSD: kroute.c,v 1.66 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright (c) 2015, 2016 Renato Westphal <renato@openbsd.org> @@ -947,8 +947,8 @@ prefixlen_classful(in_addr_t ina) return (8); } -#define ROUNDUP(a) \ - (((a) & (sizeof(long) - 1)) ? (1 + ((a) | (sizeof(long) - 1))) : (a)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) static void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) diff --git a/usr.sbin/ospfd/kroute.c b/usr.sbin/ospfd/kroute.c index 3ab34f29277..17febefbdcb 100644 --- a/usr.sbin/ospfd/kroute.c +++ b/usr.sbin/ospfd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.107 2016/12/27 09:15:16 jca Exp $ */ +/* $OpenBSD: kroute.c,v 1.108 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -983,8 +983,8 @@ prefixlen2mask(u_int8_t prefixlen) return (htonl(0xffffffff << (32 - prefixlen))); } -#define ROUNDUP(a) \ - (((a) & (sizeof(long) - 1)) ? (1 + ((a) | (sizeof(long) - 1))) : (a)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) diff --git a/usr.sbin/ripd/kroute.c b/usr.sbin/ripd/kroute.c index 6a602c6e506..424bcfb8aba 100644 --- a/usr.sbin/ripd/kroute.c +++ b/usr.sbin/ripd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.31 2015/09/27 17:32:36 stsp Exp $ */ +/* $OpenBSD: kroute.c,v 1.32 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -632,8 +632,8 @@ prefixlen2mask(u_int8_t prefixlen) return (htonl(0xffffffff << (32 - prefixlen))); } -#define ROUNDUP(a, size) \ - (((a) & ((size) - 1)) ? (1 + ((a) | ((size) - 1))) : (a)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) @@ -644,7 +644,7 @@ get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) if (addrs & (1 << i)) { rti_info[i] = sa; sa = (struct sockaddr *)((char *)(sa) + - ROUNDUP(sa->sa_len, sizeof(long))); + ROUNDUP(sa->sa_len)); } else rti_info[i] = NULL; } diff --git a/usr.sbin/snmpd/kroute.c b/usr.sbin/snmpd/kroute.c index 2a3bb5b2a26..e24c3f7e9a9 100644 --- a/usr.sbin/snmpd/kroute.c +++ b/usr.sbin/snmpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.34 2016/10/28 08:01:53 rzalamena Exp $ */ +/* $OpenBSD: kroute.c,v 1.35 2017/07/24 11:00:01 friehm Exp $ */ /* * Copyright (c) 2007, 2008 Reyk Floeter <reyk@openbsd.org> @@ -1070,8 +1070,8 @@ prefixlen2mask6(u_int8_t prefixlen) return (&mask); } -#define ROUNDUP(a) \ - (((a) & (sizeof(long) - 1)) ? (1 + ((a) | (sizeof(long) - 1))) : (a)) +#define ROUNDUP(a) \ + ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long)) void get_rtaddrs(int addrs, struct sockaddr *sa, struct sockaddr **rti_info) |