Hello -

Here are the final bcopy->memcpy conversions in netinet6 that I am
comfortable with.  There is also one (bcmp()) to (memcmp() != 0)
conversion since the memory is not overlapping.

This, with the last netinet6 diff, has dropped the number of bcopy()
calls from 62 to 29 in netinet6/

Index: icmp6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/icmp6.c,v
retrieving revision 1.190
diff -u -p -r1.190 icmp6.c
--- icmp6.c     24 Aug 2016 09:38:29 -0000      1.190
+++ icmp6.c     20 Sep 2016 01:00:36 -0000
@@ -1401,7 +1401,7 @@ icmp6_redirect_input(struct mbuf *m, int
        bzero(&sin6, sizeof(sin6));
        sin6.sin6_family = AF_INET6;
        sin6.sin6_len = sizeof(struct sockaddr_in6);
-       bcopy(&reddst6, &sin6.sin6_addr, sizeof(reddst6));
+       memcpy(&sin6.sin6_addr, &reddst6, sizeof(reddst6));
        rt = rtalloc(sin6tosa(&sin6), 0, m->m_pkthdr.ph_rtableid);
        if (rt) {
                if (rt->rt_gateway == NULL ||
@@ -1509,9 +1509,9 @@ icmp6_redirect_input(struct mbuf *m, int
                sdst.sin6_family = sgw.sin6_family = ssrc.sin6_family = 
AF_INET6;
                sdst.sin6_len = sgw.sin6_len = ssrc.sin6_len =
                        sizeof(struct sockaddr_in6);
-               bcopy(&redtgt6, &sgw.sin6_addr, sizeof(struct in6_addr));
-               bcopy(&reddst6, &sdst.sin6_addr, sizeof(struct in6_addr));
-               bcopy(&src6, &ssrc.sin6_addr, sizeof(struct in6_addr));
+               memcpy(&sgw.sin6_addr, &redtgt6, sizeof(struct in6_addr));
+               memcpy(&sdst.sin6_addr, &reddst6, sizeof(struct in6_addr));
+               memcpy(&ssrc.sin6_addr, &src6, sizeof(struct in6_addr));
                rtredirect(sin6tosa(&sdst), sin6tosa(&sgw), sin6tosa(&ssrc),
                    &newrt, m->m_pkthdr.ph_rtableid);
 
@@ -1528,7 +1528,7 @@ icmp6_redirect_input(struct mbuf *m, int
                bzero(&sdst, sizeof(sdst));
                sdst.sin6_family = AF_INET6;
                sdst.sin6_len = sizeof(struct sockaddr_in6);
-               bcopy(&reddst6, &sdst.sin6_addr, sizeof(struct in6_addr));
+               memcpy(&sdst.sin6_addr, &reddst6, sizeof(struct in6_addr));
                pfctlinput(PRC_REDIRECT_HOST, sin6tosa(&sdst));
        }
 
Index: in6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6.c,v
retrieving revision 1.192
diff -u -p -r1.192 in6.c
--- in6.c       4 Sep 2016 10:32:01 -0000       1.192
+++ in6.c       20 Sep 2016 01:00:36 -0000
@@ -1029,9 +1029,9 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
 
                /* copy args to in6_aliasreq, perform ioctl(SIOCAIFADDR_IN6). */
                bzero(&ifra, sizeof(ifra));
-               bcopy(iflr->iflr_name, ifra.ifra_name, sizeof(ifra.ifra_name));
+               memcpy(ifra.ifra_name, iflr->iflr_name, sizeof(ifra.ifra_name));
 
-               bcopy(&iflr->addr, &ifra.ifra_addr,
+               memcpy(&ifra.ifra_addr, &iflr->addr,
                    ((struct sockaddr *)&iflr->addr)->sa_len);
                if (hostid) {
                        /* fill in hostid part */
@@ -1042,7 +1042,7 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
                }
 
                if (((struct sockaddr *)&iflr->dstaddr)->sa_family) {   /*XXX*/
-                       bcopy(&iflr->dstaddr, &ifra.ifra_dstaddr,
+                       memcpy(&ifra.ifra_dstaddr, &iflr->dstaddr,
                            ((struct sockaddr *)&iflr->dstaddr)->sa_len);
                        if (hostid) {
                                ifra.ifra_dstaddr.sin6_addr.s6_addr32[2] =
@@ -1073,14 +1073,14 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
                        in6_prefixlen2mask(&mask, iflr->prefixlen);
 
                        sin6 = (struct sockaddr_in6 *)&iflr->addr;
-                       bcopy(&sin6->sin6_addr, &match, sizeof(match));
+                       memcpy(&match, &sin6->sin6_addr, sizeof(match));
                        match.s6_addr32[0] &= mask.s6_addr32[0];
                        match.s6_addr32[1] &= mask.s6_addr32[1];
                        match.s6_addr32[2] &= mask.s6_addr32[2];
                        match.s6_addr32[3] &= mask.s6_addr32[3];
 
                        /* if you set extra bits, that's wrong */
-                       if (bcmp(&match, &sin6->sin6_addr, sizeof(match)))
+                       if (memcmp(&match, &sin6->sin6_addr, sizeof(match)) != 
0)
                                return EINVAL;
 
                        cmp = 1;
@@ -1092,7 +1092,7 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
                                /* on deleting an address, do exact match */
                                in6_prefixlen2mask(&mask, 128);
                                sin6 = (struct sockaddr_in6 *)&iflr->addr;
-                               bcopy(&sin6->sin6_addr, &match, sizeof(match));
+                               memcpy(&match, &sin6->sin6_addr, sizeof(match));
 
                                cmp = 1;
                        }
@@ -1104,7 +1104,7 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
                        if (!cmp)
                                break;
 
-                       bcopy(IFA_IN6(ifa), &candidate, sizeof(candidate));
+                       memcpy(&candidate, IFA_IN6(ifa), sizeof(candidate));
                        candidate.s6_addr32[0] &= mask.s6_addr32[0];
                        candidate.s6_addr32[1] &= mask.s6_addr32[1];
                        candidate.s6_addr32[2] &= mask.s6_addr32[2];
@@ -1136,19 +1136,19 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
 
                        /* fill in6_aliasreq and do ioctl(SIOCDIFADDR_IN6) */
                        bzero(&ifra, sizeof(ifra));
-                       bcopy(iflr->iflr_name, ifra.ifra_name,
+                       memcpy(ifra.ifra_name, iflr->iflr_name,
                            sizeof(ifra.ifra_name));
 
-                       bcopy(&ia6->ia_addr, &ifra.ifra_addr,
+                       memcpy(&ifra.ifra_addr, &ia6->ia_addr,
                            ia6->ia_addr.sin6_len);
                        if ((ifp->if_flags & IFF_POINTOPOINT) != 0) {
-                               bcopy(&ia6->ia_dstaddr, &ifra.ifra_dstaddr,
+                               memcpy(&ifra.ifra_dstaddr, &ia6->ia_dstaddr,
                                    ia6->ia_dstaddr.sin6_len);
                        } else {
                                bzero(&ifra.ifra_dstaddr,
                                    sizeof(ifra.ifra_dstaddr));
                        }
-                       bcopy(&ia6->ia_prefixmask, &ifra.ifra_dstaddr,
+                       memcpy(&ifra.ifra_dstaddr, &ia6->ia_prefixmask,
                            ia6->ia_prefixmask.sin6_len);
 
                        ifra.ifra_flags = ia6->ia6_flags;
Index: in6_ifattach.c
===================================================================
RCS file: /cvs/src/sys/netinet6/in6_ifattach.c,v
retrieving revision 1.100
diff -u -p -r1.100 in6_ifattach.c
--- in6_ifattach.c      30 Jun 2016 08:19:03 -0000      1.100
+++ in6_ifattach.c      20 Sep 2016 01:00:36 -0000
@@ -99,7 +99,7 @@ get_last_resort_ifid(struct ifnet *ifp, 
        SHA512Final(digest, &ctx);
 
        /* assumes sizeof(digest) > sizeof(ifid) */
-       bcopy(digest, &in6->s6_addr[8], 8);
+       memcpy(&in6->s6_addr[8], digest, 8);
 
        /* make sure to set "u" bit to local, and "g" bit to individual. */
        in6->s6_addr[8] &= ~EUI64_GBIT; /* g bit to "individual" */
@@ -453,7 +453,7 @@ in6_nigroup(struct ifnet *ifp, const cha
        sa6->sin6_addr.s6_addr16[0] = htons(0xff02);
        sa6->sin6_addr.s6_addr16[1] = htons(ifp->if_index);
        sa6->sin6_addr.s6_addr8[11] = 2;
-       bcopy(digest, &sa6->sin6_addr.s6_addr32[3],
+       memcpy(&sa6->sin6_addr.s6_addr32[3], digest,
            sizeof(sa6->sin6_addr.s6_addr32[3]));
 
        return 0;
Index: ip6_input.c
===================================================================
RCS file: /cvs/src/sys/netinet6/ip6_input.c,v
retrieving revision 1.168
diff -u -p -r1.168 ip6_input.c
--- ip6_input.c 24 Aug 2016 09:41:12 -0000      1.168
+++ ip6_input.c 20 Sep 2016 01:00:37 -0000
@@ -794,7 +794,7 @@ ip6_process_hopopts(struct mbuf *m, u_in
                                return (-1);
                        }
                        optlen = IP6OPT_RTALERT_LEN;
-                       bcopy((caddr_t)(opt + 2), (caddr_t)&rtalert_val, 2);
+                       memcpy((caddr_t)&rtalert_val, (caddr_t)(opt + 2), 2);
                        *rtalertp = ntohs(rtalert_val);
                        break;
                case IP6OPT_JUMBO:
@@ -827,9 +827,9 @@ ip6_process_hopopts(struct mbuf *m, u_in
 
                        /*
                         * We may see jumbolen in unaligned location, so
-                        * we'd need to perform bcopy().
+                        * we'd need to perform memcpy().
                         */
-                       bcopy(opt + 2, &jumboplen, sizeof(jumboplen));
+                       memcpy(&jumboplen, opt + 2, sizeof(jumboplen));
                        jumboplen = (u_int32_t)htonl(jumboplen);
 
 #if 1
@@ -952,7 +952,7 @@ ip6_savecontrol(struct inpcb *in6p, stru
        /* RFC 2292 sec. 5 */
        if ((in6p->inp_flags & IN6P_PKTINFO) != 0) {
                struct in6_pktinfo pi6;
-               bcopy(&ip6->ip6_dst, &pi6.ipi6_addr, sizeof(struct in6_addr));
+               memcpy(&pi6.ipi6_addr, &ip6->ip6_dst, sizeof(struct in6_addr));
                if (IN6_IS_SCOPE_EMBED(&pi6.ipi6_addr))
                        pi6.ipi6_addr.s6_addr16[1] = 0;
                pi6.ipi6_ifindex = m ? m->m_pkthdr.ph_ifidx : 0;
Index: mld6.c
===================================================================
RCS file: /cvs/src/sys/netinet6/mld6.c,v
retrieving revision 1.48
diff -u -p -r1.48 mld6.c
--- mld6.c      5 Jul 2016 10:17:14 -0000       1.48
+++ mld6.c      20 Sep 2016 01:00:37 -0000
@@ -109,7 +109,7 @@ mld6_init(void)
        hbh_buf[3] = 0;
        hbh_buf[4] = IP6OPT_ROUTER_ALERT;
        hbh_buf[5] = IP6OPT_RTALERT_LEN - 2;
-       bcopy((caddr_t)&rtalert_code, &hbh_buf[6], sizeof(u_int16_t));
+       memcpy(&hbh_buf[6], (caddr_t)&rtalert_code, sizeof(u_int16_t));
 
        ip6_opts.ip6po_hbh = hbh;
 }
Index: nd6_rtr.c
===================================================================
RCS file: /cvs/src/sys/netinet6/nd6_rtr.c,v
retrieving revision 1.145
diff -u -p -r1.145 nd6_rtr.c
--- nd6_rtr.c   8 Sep 2016 09:02:42 -0000       1.145
+++ nd6_rtr.c   20 Sep 2016 01:00:37 -0000
@@ -1914,7 +1914,7 @@ in6_ifadd(struct nd_prefix *pr, int priv
        ifra.ifra_addr.sin6_family = AF_INET6;
        ifra.ifra_addr.sin6_len = sizeof(struct sockaddr_in6);
        /* prefix */
-       bcopy(&pr->ndpr_prefix.sin6_addr, &ifra.ifra_addr.sin6_addr,
+       memcpy(&ifra.ifra_addr.sin6_addr, &pr->ndpr_prefix.sin6_addr,
            sizeof(ifra.ifra_addr.sin6_addr));
        ifra.ifra_addr.sin6_addr.s6_addr32[0] &= mask.s6_addr32[0];
        ifra.ifra_addr.sin6_addr.s6_addr32[1] &= mask.s6_addr32[1];
@@ -1924,7 +1924,7 @@ in6_ifadd(struct nd_prefix *pr, int priv
        /* interface ID */
        if (privacy) {
                ifra.ifra_flags |= IN6_IFF_PRIVACY;
-               bcopy(&pr->ndpr_prefix.sin6_addr, &rand_ifid,
+               memcpy(&rand_ifid, &pr->ndpr_prefix.sin6_addr,
                    sizeof(rand_ifid));
                in6_get_rand_ifid(ifp, &rand_ifid);
                ifra.ifra_addr.sin6_addr.s6_addr32[0] |=
@@ -1949,7 +1949,7 @@ in6_ifadd(struct nd_prefix *pr, int priv
        /* new prefix mask. */
        ifra.ifra_prefixmask.sin6_len = sizeof(struct sockaddr_in6);
        ifra.ifra_prefixmask.sin6_family = AF_INET6;
-       bcopy(&mask, &ifra.ifra_prefixmask.sin6_addr,
+       memcpy(&ifra.ifra_prefixmask.sin6_addr, &mask,
            sizeof(ifra.ifra_prefixmask.sin6_addr));
 
        /*

Reply via email to