Date: Tue, 23 Oct 2012 10:29:31 +0000 (UTC) From: Gleb Smirnoff <glebius@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241925 - head/sys/netinet Message-ID: <201210231029.q9NATVKx040433@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: glebius Date: Tue Oct 23 10:29:31 2012 New Revision: 241925 URL: http://svn.freebsd.org/changeset/base/241925 Log: Simplify ip_stripoptions() reducing number of intermediate variables. Modified: head/sys/netinet/ip_options.c Modified: head/sys/netinet/ip_options.c ============================================================================== --- head/sys/netinet/ip_options.c Tue Oct 23 09:59:46 2012 (r241924) +++ head/sys/netinet/ip_options.c Tue Oct 23 10:29:31 2012 (r241925) @@ -458,20 +458,18 @@ ip_srcroute(struct mbuf *m0) void ip_stripoptions(struct mbuf *m) { - int i; struct ip *ip = mtod(m, struct ip *); - caddr_t opts; int olen; - olen = (ip->ip_hl << 2) - sizeof (struct ip); - opts = (caddr_t)(ip + 1); - i = m->m_len - (sizeof (struct ip) + olen); - bcopy(opts + olen, opts, (unsigned)i); + olen = (ip->ip_hl << 2) - sizeof(struct ip); m->m_len -= olen; if (m->m_flags & M_PKTHDR) m->m_pkthdr.len -= olen; ip->ip_len = htons(ntohs(ip->ip_len) - olen); ip->ip_hl = sizeof(struct ip) >> 2; + + bcopy((char *)ip + sizeof(struct ip) + olen, (ip + 1), + (size_t )(m->m_len - sizeof(struct ip))); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210231029.q9NATVKx040433>