Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/netinet6 Replace bcopy -> memcpy when it is obvious that...



details:   https://anonhg.NetBSD.org/src/rev/21131973f63d
branches:  trunk
changeset: 359480:21131973f63d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Feb 12 12:52:12 2018 +0000

description:
Replace bcopy -> memcpy when it is obvious that the areas don't overlap.
Rearrange ip6_splithdr() for clarity.

diffstat:

 sys/netinet6/icmp6.c      |  12 ++++++------
 sys/netinet6/ip6_input.c  |   6 +++---
 sys/netinet6/ip6_output.c |  16 ++++++++--------
 3 files changed, 17 insertions(+), 17 deletions(-)

diffs (147 lines):

diff -r ef57e7c6cde5 -r 21131973f63d sys/netinet6/icmp6.c
--- a/sys/netinet6/icmp6.c      Mon Feb 12 12:17:38 2018 +0000
+++ b/sys/netinet6/icmp6.c      Mon Feb 12 12:52:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: icmp6.c,v 1.219 2018/01/23 10:55:38 maxv Exp $ */
+/*     $NetBSD: icmp6.c,v 1.220 2018/02/12 12:52:12 maxv Exp $ */
 /*     $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.219 2018/01/23 10:55:38 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: icmp6.c,v 1.220 2018/02/12 12:52:12 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1486,7 +1486,7 @@
                nni6->ni_flags = htons(0x0000); /* raw bitmap */
                /* supports NOOP, SUPTYPES, FQDN, and NODEADDR */
                v = (u_int32_t)htonl(0x0000000f);
-               bcopy(&v, nni6 + 1, sizeof(u_int32_t));
+               memcpy(nni6 + 1, &v, sizeof(u_int32_t));
                break;
        }
        case NI_QTYPE_FQDN:
@@ -1580,7 +1580,7 @@
        if (old) {
                m->m_len = len;
                *mtod(m, char *) = namelen;
-               bcopy(name, mtod(m, char *) + 1, namelen);
+               memcpy(mtod(m, char *) + 1, name, namelen);
                return m;
        } else {
                m->m_len = 0;
@@ -1927,7 +1927,7 @@
                                ltime = 0x7fffffff;
                        ltime = htonl(ltime);
 
-                       bcopy(&ltime, cp, sizeof(u_int32_t));
+                       memcpy(cp, &ltime, sizeof(u_int32_t));
                        cp += sizeof(u_int32_t);
 
                        /* copy the address itself */
@@ -2109,7 +2109,7 @@
                        if ((m = m_pullup(m, l)) == NULL)
                                return;
                }
-               bcopy((void *)&nip6, mtod(m, void *), sizeof(nip6));
+               memcpy(mtod(m, void *), (void *)&nip6, sizeof(nip6));
        } else {
                size_t l = sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr);
                if (m->m_len < l) {
diff -r ef57e7c6cde5 -r 21131973f63d sys/netinet6/ip6_input.c
--- a/sys/netinet6/ip6_input.c  Mon Feb 12 12:17:38 2018 +0000
+++ b/sys/netinet6/ip6_input.c  Mon Feb 12 12:52:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_input.c,v 1.190 2018/02/09 18:31:52 maxv Exp $     */
+/*     $NetBSD: ip6_input.c,v 1.191 2018/02/12 12:52:12 maxv Exp $     */
 /*     $KAME: ip6_input.c,v 1.188 2001/03/29 05:34:31 itojun Exp $     */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.190 2018/02/09 18:31:52 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_input.c,v 1.191 2018/02/12 12:52:12 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_gateway.h"
@@ -960,7 +960,7 @@
 
                        /*
                         * We may see jumbolen in unaligned location, so
-                        * we'd need to perform bcopy().
+                        * we'd need to perform memcpy().
                         */
                        memcpy(&jumboplen, opt + 2, sizeof(jumboplen));
                        jumboplen = (u_int32_t)htonl(jumboplen);
diff -r ef57e7c6cde5 -r 21131973f63d sys/netinet6/ip6_output.c
--- a/sys/netinet6/ip6_output.c Mon Feb 12 12:17:38 2018 +0000
+++ b/sys/netinet6/ip6_output.c Mon Feb 12 12:52:12 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip6_output.c,v 1.200 2018/01/31 15:23:08 maxv Exp $    */
+/*     $NetBSD: ip6_output.c,v 1.201 2018/02/12 12:52:12 maxv Exp $    */
 /*     $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $    */
 
 /*
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.200 2018/01/31 15:23:08 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip6_output.c,v 1.201 2018/02/12 12:52:12 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1115,7 +1115,7 @@
        }
        m->m_len = hlen;
        if (hdr)
-               bcopy(hdr, mtod(m, void *), hlen);
+               memcpy(mtod(m, void *), hdr, hlen);
 
        *mp = m;
        return 0;
@@ -1236,7 +1236,7 @@
        optbuf[2] = IP6OPT_JUMBO;
        optbuf[3] = 4;
        v = (u_int32_t)htonl(plen + JUMBOOPTLEN);
-       bcopy(&v, &optbuf[4], sizeof(u_int32_t));
+       memcpy(&optbuf[4], &v, sizeof(u_int32_t));
 
        /* finally, adjust the packet header length */
        exthdrs->ip6e_ip6->m_pkthdr.len += JUMBOOPTLEN;
@@ -3328,7 +3328,7 @@
  * Chop IPv6 header off from the payload.
  */
 static int
-ip6_splithdr(struct mbuf *m,  struct ip6_exthdrs *exthdrs)
+ip6_splithdr(struct mbuf *m, struct ip6_exthdrs *exthdrs)
 {
        struct mbuf *mh;
        struct ip6_hdr *ip6;
@@ -3336,7 +3336,7 @@
        ip6 = mtod(m, struct ip6_hdr *);
        if (m->m_len > sizeof(*ip6)) {
                MGETHDR(mh, M_DONTWAIT, MT_HEADER);
-               if (mh == 0) {
+               if (mh == NULL) {
                        m_freem(m);
                        return ENOBUFS;
                }
@@ -3345,9 +3345,9 @@
                m->m_len -= sizeof(*ip6);
                m->m_data += sizeof(*ip6);
                mh->m_next = m;
+               mh->m_len = sizeof(*ip6);
+               memcpy(mtod(mh, void *), (void *)ip6, sizeof(*ip6));
                m = mh;
-               m->m_len = sizeof(*ip6);
-               bcopy((void *)ip6, mtod(m, void *), sizeof(*ip6));
        }
        exthdrs->ip6e_ip6 = m;
        return 0;



Home | Main Index | Thread Index | Old Index