Re: my final netinet6 bcopy->memcpy

2016-09-30 Thread David Hill
Ping.

On Mon, Sep 19, 2016 at 09:22:50PM -0400, David Hill wrote:
> 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 -  1.190
> +++ icmp6.c   20 Sep 2016 01:00:36 -
> @@ -1401,7 +1401,7 @@ icmp6_redirect_input(struct mbuf *m, int
>   bzero(, sizeof(sin6));
>   sin6.sin6_family = AF_INET6;
>   sin6.sin6_len = sizeof(struct sockaddr_in6);
> - bcopy(, _addr, sizeof(reddst6));
> + memcpy(_addr, , sizeof(reddst6));
>   rt = rtalloc(sin6tosa(), 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(, _addr, sizeof(struct in6_addr));
> - bcopy(, _addr, sizeof(struct in6_addr));
> - bcopy(, _addr, sizeof(struct in6_addr));
> + memcpy(_addr, , sizeof(struct in6_addr));
> + memcpy(_addr, , sizeof(struct in6_addr));
> + memcpy(_addr, , sizeof(struct in6_addr));
>   rtredirect(sin6tosa(), sin6tosa(), sin6tosa(),
>   , m->m_pkthdr.ph_rtableid);
>  
> @@ -1528,7 +1528,7 @@ icmp6_redirect_input(struct mbuf *m, int
>   bzero(, sizeof(sdst));
>   sdst.sin6_family = AF_INET6;
>   sdst.sin6_len = sizeof(struct sockaddr_in6);
> - bcopy(, _addr, sizeof(struct in6_addr));
> + memcpy(_addr, , sizeof(struct in6_addr));
>   pfctlinput(PRC_REDIRECT_HOST, sin6tosa());
>   }
>  
> 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 -   1.192
> +++ in6.c 20 Sep 2016 01:00:36 -
> @@ -1029,9 +1029,9 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
>  
>   /* copy args to in6_aliasreq, perform ioctl(SIOCAIFADDR_IN6). */
>   bzero(, 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(>addr, _addr,
> + memcpy(_addr, >addr,
>   ((struct sockaddr *)>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 *)>dstaddr)->sa_family) {   /*XXX*/
> - bcopy(>dstaddr, _dstaddr,
> + memcpy(_dstaddr, >dstaddr,
>   ((struct sockaddr *)>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(, iflr->prefixlen);
>  
>   sin6 = (struct sockaddr_in6 *)>addr;
> - bcopy(>sin6_addr, , sizeof(match));
> + memcpy(, >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(, >sin6_addr, sizeof(match)))
> + if (memcmp(, >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(, 128);
>   sin6 = (struct sockaddr_in6 *)>addr;
> - bcopy(>sin6_addr, , sizeof(match));
> + memcpy(, >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), 

my final netinet6 bcopy->memcpy

2016-09-19 Thread David Hill
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 -  1.190
+++ icmp6.c 20 Sep 2016 01:00:36 -
@@ -1401,7 +1401,7 @@ icmp6_redirect_input(struct mbuf *m, int
bzero(, sizeof(sin6));
sin6.sin6_family = AF_INET6;
sin6.sin6_len = sizeof(struct sockaddr_in6);
-   bcopy(, _addr, sizeof(reddst6));
+   memcpy(_addr, , sizeof(reddst6));
rt = rtalloc(sin6tosa(), 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(, _addr, sizeof(struct in6_addr));
-   bcopy(, _addr, sizeof(struct in6_addr));
-   bcopy(, _addr, sizeof(struct in6_addr));
+   memcpy(_addr, , sizeof(struct in6_addr));
+   memcpy(_addr, , sizeof(struct in6_addr));
+   memcpy(_addr, , sizeof(struct in6_addr));
rtredirect(sin6tosa(), sin6tosa(), sin6tosa(),
, m->m_pkthdr.ph_rtableid);
 
@@ -1528,7 +1528,7 @@ icmp6_redirect_input(struct mbuf *m, int
bzero(, sizeof(sdst));
sdst.sin6_family = AF_INET6;
sdst.sin6_len = sizeof(struct sockaddr_in6);
-   bcopy(, _addr, sizeof(struct in6_addr));
+   memcpy(_addr, , sizeof(struct in6_addr));
pfctlinput(PRC_REDIRECT_HOST, sin6tosa());
}
 
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 -   1.192
+++ in6.c   20 Sep 2016 01:00:36 -
@@ -1029,9 +1029,9 @@ in6_lifaddr_ioctl(u_long cmd, caddr_t da
 
/* copy args to in6_aliasreq, perform ioctl(SIOCAIFADDR_IN6). */
bzero(, 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(>addr, _addr,
+   memcpy(_addr, >addr,
((struct sockaddr *)>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 *)>dstaddr)->sa_family) {   /*XXX*/
-   bcopy(>dstaddr, _dstaddr,
+   memcpy(_dstaddr, >dstaddr,
((struct sockaddr *)>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(, iflr->prefixlen);
 
sin6 = (struct sockaddr_in6 *)>addr;
-   bcopy(>sin6_addr, , sizeof(match));
+   memcpy(, >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(, >sin6_addr, sizeof(match)))
+   if (memcmp(, >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(, 128);
sin6 = (struct sockaddr_in6 *)>addr;
-   bcopy(>sin6_addr, , sizeof(match));
+   memcpy(, >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), , sizeof(candidate));
+   memcpy(, IFA_IN6(ifa), sizeof(candidate));
candidate.s6_addr32[0] &=