summaryrefslogtreecommitdiffstats
path: root/src/ipv6.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2017-10-05 08:05:08 +0100
committerRoy Marples <roy@marples.name>2017-10-05 08:05:08 +0100
commit18539557d779fbd72a887eb5eca484f5dedaecf5 (patch)
tree3564dab6bcdd290c3eebf69898c174edc32b400b /src/ipv6.c
parent32f3d049dd1e99d284787e0c18a5adef8c029bc7 (diff)
downloaddhcpcd-18539557d779fbd72a887eb5eca484f5dedaecf5.tar.xz
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.
Diffstat (limited to 'src/ipv6.c')
-rw-r--r--src/ipv6.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/ipv6.c b/src/ipv6.c
index da0f64db..2b9dba3a 100644
--- a/src/ipv6.c
+++ b/src/ipv6.c
@@ -2222,9 +2222,7 @@ inet6_staticroutes(struct rt_head *routes, struct dhcpcd_ctx *ctx)
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 @@ inet6_staticroutes(struct rt_head *routes, struct dhcpcd_ctx *ctx)
(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 @@ inet6_raroutes(struct rt_head *routes, struct dhcpcd_ctx *ctx, int expired,
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 @@ inet6_raroutes(struct rt_head *routes, struct dhcpcd_ctx *ctx, int expired,
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 @@ inet6_dhcproutes(struct rt_head *routes, struct dhcpcd_ctx *ctx,
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