Mercurial > hg > dhcpcd
changeset 4150:4d9679283c1e draft
We don't actually care about the number of added routes, just
it we failed or not.
So just return 0 on success and -1 on failure to work around
a gcc check where signed int could overflow.
This should be impossible anyway due to the protocol limits of
DHCP and RA.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Thu, 05 Oct 2017 08:05:08 +0100 |
| parents | fce599d14e9a |
| children | 6710a4fd6898 |
| files | src/ipv4.c src/ipv6.c |
| diffstat | 2 files changed, 7 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ipv4.c Thu Oct 05 07:35:16 2017 +0100 +++ b/src/ipv4.c Thu Oct 05 08:05:08 2017 +0100 @@ -338,13 +338,11 @@ struct if_options *ifo; const struct dhcp_state *state; struct in_addr in; - int n; /* Don't add a host route for these interfaces. */ if (ifp->flags & (IFF_LOOPBACK | IFF_POINTOPOINT)) return 0; - n = 0; TAILQ_FOREACH(rt, routes, rt_next) { if (rt->rt_dest.sa_family != AF_INET) continue; @@ -414,9 +412,8 @@ rth->rt_mtu = dhcp_get_mtu(ifp); sa_in_init(&rth->rt_ifa, &state->addr->addr); TAILQ_INSERT_BEFORE(rt, rth, rt_next); - n++; } - return n; + return 0; } bool
--- a/src/ipv6.c Thu Oct 05 07:35:16 2017 +0100 +++ b/src/ipv6.c Thu Oct 05 08:05:08 2017 +0100 @@ -2222,9 +2222,7 @@ struct ipv6_state *state; struct ipv6_addr *ia; struct rt *rt; - int n; - n = 0; TAILQ_FOREACH(ifp, ctx->ifaces, next) { if ((state = IPV6_STATE(ifp)) == NULL) continue; @@ -2233,14 +2231,12 @@ (IPV6_AF_ADDED | IPV6_AF_STATIC)) { rt = inet6_makeprefix(ifp, NULL, ia); - if (rt) { + if (rt) TAILQ_INSERT_TAIL(routes, rt, rt_next); - n++; - } } } } - return n; + return 0; } static int @@ -2250,9 +2246,7 @@ struct rt *rt; struct ra *rap; const struct ipv6_addr *addr; - int n; - n = 0; TAILQ_FOREACH(rap, ctx->ra_routers, next) { if (rap->expired != expired) continue; @@ -2260,22 +2254,19 @@ if (addr->prefix_vltime == 0) continue; rt = inet6_makeprefix(rap->iface, rap, addr); - if (rt) { + if (rt) TAILQ_INSERT_TAIL(routes, rt, rt_next); - n++; - } } if (rap->lifetime) { rt = inet6_makerouter(rap); if (rt) { TAILQ_INSERT_TAIL(routes, rt, rt_next); - n++; if (have_default) *have_default = true; } } } - return n; + return 0; } static int @@ -2286,22 +2277,18 @@ const struct dhcp6_state *d6_state; const struct ipv6_addr *addr; struct rt *rt; - int n; - n = 0; TAILQ_FOREACH(ifp, ctx->ifaces, next) { d6_state = D6_CSTATE(ifp); if (d6_state && d6_state->state == dstate) { TAILQ_FOREACH(addr, &d6_state->addrs, next) { rt = inet6_makeprefix(ifp, NULL, addr); - if (rt) { + if (rt) TAILQ_INSERT_TAIL(routes, rt, rt_next); - n++; - } } } } - return n; + return 0; } bool
