diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-06-03 21:19:07 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-06-03 21:19:07 +0000 |
commit | d275e1142db6eab9e3811c4e94eedbe9505bc2af (patch) | |
tree | 4900b3aa4c04091d369a28a1184dd543efb9e07c /usr.sbin/bgpd | |
parent | b4a652c936ec3a38d77a21496322390662e82816 (diff) |
Instead of doing a poor mans offsetof() implementation change the code
to use an end pointer to compare against. Looks less scary and makes
gcc4 happy. OK henning@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 40591898943..aeed6d4e535 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.181 2010/05/19 13:15:08 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.182 2010/06/03 21:19:06 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2334,17 +2334,17 @@ mask2prefixlen(in_addr_t ina) u_int8_t mask2prefixlen6(struct sockaddr_in6 *sa_in6) { - u_int8_t l = 0, i, len; + u_int8_t l = 0, *ap, *ep; /* * sin6_len is the size of the sockaddr so substract the offset of * the possibly truncated sin6_addr struct. */ - len = sa_in6->sin6_len - - (u_int8_t)(&((struct sockaddr_in6 *)NULL)->sin6_addr); - for (i = 0; i < len; i++) { + ap = (u_int8_t *)&sa_in6->sin6_addr; + ep = (u_int8_t *)sa_in6 + sa_in6->sin6_len; + for (; ap < ep; ap++) { /* this "beauty" is adopted from sbin/route/show.c ... */ - switch (sa_in6->sin6_addr.s6_addr[i]) { + switch (*ap) { case 0xff: l += 8; break; |