From 5098b0e414172b2ed3ee9d0db33ca3ddcb72ac8c Mon Sep 17 00:00:00 2001 From: jtl Date: Fri, 20 Apr 2018 14:34:04 +0000 Subject: [PATCH] MFC r331484: Remove some unneccessary variable sets in IPv6 code, as detected by clang's static analyzer. Sponsored by: Netflix, Inc. --- sys/netinet6/dest6.c | 2 +- sys/netinet6/icmp6.c | 1 - sys/netinet6/ip6_output.c | 2 +- sys/netinet6/udp6_usrreq.c | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sys/netinet6/dest6.c b/sys/netinet6/dest6.c index 2b95fd9d011..19c8d26163b 100644 --- a/sys/netinet6/dest6.c +++ b/sys/netinet6/dest6.c @@ -91,7 +91,7 @@ dest6_input(struct mbuf **mp, int *offp, int proto) opt = (u_int8_t *)dstopts + sizeof(struct ip6_dest); /* search header for all options. */ - for (optlen = 0; dstoptlen > 0; dstoptlen -= optlen, opt += optlen) { + for (; dstoptlen > 0; dstoptlen -= optlen, opt += optlen) { if (*opt != IP6OPT_PAD1 && (dstoptlen < IP6OPT_MINLEN || *(opt + 1) + 2 > dstoptlen)) { IP6STAT_INC(ip6s_toosmall); diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 53a228c29ba..7203f497d9e 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -592,7 +592,6 @@ icmp6_input(struct mbuf **mp, int *offp, int proto) n->m_pkthdr.len = n0len + (noff - off); n->m_next = n0; } else { - nip6 = mtod(n, struct ip6_hdr *); IP6_EXTHDR_GET(nicmp6, struct icmp6_hdr *, n, off, sizeof(*nicmp6)); noff = off; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index aa3775cf1f3..8f74d84e08e 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1038,7 +1038,7 @@ ip6_output(struct mbuf *m0, struct ip6_pktopts *opt, m = m0->m_nextpkt; m0->m_nextpkt = 0; m_freem(m0); - for (m0 = m; m; m = m0) { + for (; m; m = m0) { m0 = m->m_nextpkt; m->m_nextpkt = 0; if (error == 0) { diff --git a/sys/netinet6/udp6_usrreq.c b/sys/netinet6/udp6_usrreq.c index 56faf5a8515..c38375331ed 100644 --- a/sys/netinet6/udp6_usrreq.c +++ b/sys/netinet6/udp6_usrreq.c @@ -208,7 +208,6 @@ udp6_input(struct mbuf **mp, int *offp, int proto) uint8_t nxt; ifp = m->m_pkthdr.rcvif; - ip6 = mtod(m, struct ip6_hdr *); #ifndef PULLDOWN_TEST IP6_EXTHDR_CHECK(m, off, sizeof(struct udphdr), IPPROTO_DONE); @@ -218,6 +217,7 @@ udp6_input(struct mbuf **mp, int *offp, int proto) IP6_EXTHDR_GET(uh, struct udphdr *, m, off, sizeof(*uh)); if (!uh) return (IPPROTO_DONE); + ip6 = mtod(m, struct ip6_hdr *); #endif UDPSTAT_INC(udps_ipackets); -- 2.45.0