From: Roy Marples Date: Mon, 22 Jul 2019 11:44:20 +0000 (+0100) Subject: DHCP6: Assert auto sla is only 32-bits X-Git-Tag: v8.0.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c39fde3fe84d301a6f897ec5163ac08ec9cc178e;p=thirdparty%2Fdhcpcd.git DHCP6: Assert auto sla is only 32-bits It already is due to the use of fls32 above, but this assertion makes clang static analyser happy. --- diff --git a/src/dhcp6.c b/src/dhcp6.c index 75473ea8..42face2d 100644 --- a/src/dhcp6.c +++ b/src/dhcp6.c @@ -583,10 +583,14 @@ dhcp6_delegateaddr(struct in6_addr *addr, struct interface *ifp, #define BIT(n) (1UL << (n)) #define BIT_MASK(len) (BIT(len) - 1) - if (ia->sla_max == 0) + if (ia->sla_max == 0) { /* Work out the real sla_max from our bits used */ - ia->sla_max = (uint32_t)BIT_MASK(asla.prefix_len - - prefix->prefix_len); + bits = asla.prefix_len - prefix->prefix_len; + /* Make static analysis happy. + * Bits cannot be bigger than 32 thanks to fls32. */ + assert(bits <= 32); + ia->sla_max = (uint32_t)BIT_MASK(bits); + } } if (ipv6_userprefix(&prefix->prefix, prefix->prefix_len,