Replaced some bcopy()'s with memcpy()'s so that gcc while inline/optimize.

This commit is contained in:
David Greenman 1995-05-09 13:35:48 +00:00
parent e6ba2cd30e
commit 94a5d9b6a1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=8384
8 changed files with 59 additions and 68 deletions

View File

@ -37,7 +37,7 @@
*
* @(#)bpf.c 8.2 (Berkeley) 3/28/94
*
* $Id: bpf.c,v 1.4 1994/10/09 07:35:03 davidg Exp $
* $Id: bpf.c,v 1.5 1995/03/14 09:14:10 davidg Exp $
*/
#include "bpfilter.h"
@ -1039,7 +1039,7 @@ bpf_mcopy(src_arg, dst_arg, len)
if (m == 0)
panic("bpf_mcopy");
count = min(m->m_len, len);
bcopy(mtod(m, caddr_t), (caddr_t)dst, count);
(void)memcpy((caddr_t)dst, mtod(m, caddr_t), count);
m = m->m_next;
dst += count;
len -= count;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93
* $Id: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp $
* $Id: if_ethersubr.c,v 1.6 1995/03/16 18:14:25 bde Exp $
*/
#include <sys/param.h>
@ -245,7 +245,7 @@ ether_output(ifp, m0, dst, rt0)
case AF_UNSPEC:
eh = (struct ether_header *)dst->sa_data;
bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst));
(void)memcpy(edst, eh->ether_dhost, sizeof (edst));
type = eh->ether_type;
break;
@ -267,10 +267,10 @@ ether_output(ifp, m0, dst, rt0)
senderr(ENOBUFS);
eh = mtod(m, struct ether_header *);
type = htons((u_short)type);
bcopy((caddr_t)&type,(caddr_t)&eh->ether_type,
(void)memcpy(&eh->ether_type, &type,
sizeof(eh->ether_type));
bcopy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
bcopy((caddr_t)ac->ac_enaddr, (caddr_t)eh->ether_shost,
(void)memcpy(eh->ether_dhost, edst, sizeof (edst));
(void)memcpy(eh->ether_shost, ac->ac_enaddr,
sizeof(eh->ether_shost));
s = splimp();
/*

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: if_ethersubr.c,v 1.5 1994/12/13 22:31:45 wollman Exp
* $Id: if_fddisubr.c,v 1.2 1995/03/14 22:15:36 davidg Exp $
* $Id: if_fddisubr.c,v 1.3 1995/03/16 18:14:26 bde Exp $
*/
#include <sys/param.h>
@ -264,7 +264,7 @@ fddi_output(ifp, m0, dst, rt0)
{
struct ether_header *eh;
eh = (struct ether_header *)dst->sa_data;
bcopy((caddr_t)eh->ether_dhost, (caddr_t)edst, sizeof (edst));
(void)memcpy((caddr_t)edst, (caddr_t)eh->ether_dhost, sizeof (edst));
if (*edst & 1)
m->m_flags |= (M_BCAST|M_MCAST);
type = eh->ether_type;
@ -325,7 +325,7 @@ fddi_output(ifp, m0, dst, rt0)
l->llc_dsap = l->llc_ssap = LLC_SNAP_LSAP;
l->llc_snap.org_code[0] = l->llc_snap.org_code[1] = l->llc_snap.org_code[2] = 0;
type = ntohs(type);
bcopy((caddr_t) &type, (caddr_t) &l->llc_snap.ether_type,
(void)memcpy((caddr_t) &l->llc_snap.ether_type, (caddr_t) &type,
sizeof(u_short));
}
/*
@ -337,9 +337,9 @@ fddi_output(ifp, m0, dst, rt0)
senderr(ENOBUFS);
fh = mtod(m, struct fddi_header *);
fh->fddi_fc = FDDIFC_LLC_ASYNC|FDDIFC_LLC_PRIO4;
bcopy((caddr_t)edst, (caddr_t)fh->fddi_dhost, sizeof (edst));
(void)memcpy((caddr_t)fh->fddi_dhost, (caddr_t)edst, sizeof (edst));
queue_it:
bcopy((caddr_t)ac->ac_enaddr, (caddr_t)fh->fddi_shost,
(void)memcpy((caddr_t)fh->fddi_shost, (caddr_t)ac->ac_enaddr,
sizeof(fh->fddi_shost));
s = splimp();
/*

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)if_ether.c 8.1 (Berkeley) 6/10/93
* $Id: if_ether.c,v 1.13 1995/03/16 18:14:49 bde Exp $
* $Id: if_ether.c,v 1.14 1995/04/26 18:10:52 pst Exp $
*/
/*
@ -270,17 +270,16 @@ arprequest(ac, sip, tip, enaddr)
ea = mtod(m, struct ether_arp *);
eh = (struct ether_header *)sa.sa_data;
bzero((caddr_t)ea, sizeof (*ea));
bcopy((caddr_t)etherbroadcastaddr, (caddr_t)eh->ether_dhost,
sizeof(eh->ether_dhost));
(void)memcpy(eh->ether_dhost, etherbroadcastaddr, sizeof(eh->ether_dhost));
eh->ether_type = ETHERTYPE_ARP; /* if_output will swap */
ea->arp_hrd = htons(ARPHRD_ETHER);
ea->arp_pro = htons(ETHERTYPE_IP);
ea->arp_hln = sizeof(ea->arp_sha); /* hardware address length */
ea->arp_pln = sizeof(ea->arp_spa); /* protocol address length */
ea->arp_op = htons(ARPOP_REQUEST);
bcopy((caddr_t)enaddr, (caddr_t)ea->arp_sha, sizeof(ea->arp_sha));
bcopy((caddr_t)sip, (caddr_t)ea->arp_spa, sizeof(ea->arp_spa));
bcopy((caddr_t)tip, (caddr_t)ea->arp_tpa, sizeof(ea->arp_tpa));
(void)memcpy(ea->arp_sha, enaddr, sizeof(ea->arp_sha));
(void)memcpy(ea->arp_spa, sip, sizeof(ea->arp_spa));
(void)memcpy(ea->arp_tpa, tip, sizeof(ea->arp_tpa));
sa.sa_family = AF_UNSPEC;
sa.sa_len = sizeof(sa);
(*ac->ac_if.if_output)(&ac->ac_if, m, &sa, (struct rtentry *)0);
@ -309,8 +308,7 @@ arpresolve(ac, rt, m, dst, desten, rt0)
struct sockaddr_dl *sdl;
if (m->m_flags & M_BCAST) { /* broadcast */
bcopy((caddr_t)etherbroadcastaddr, (caddr_t)desten,
sizeof(etherbroadcastaddr));
(void)memcpy(desten, etherbroadcastaddr, sizeof(etherbroadcastaddr));
return (1);
}
if (m->m_flags & M_MCAST) { /* multicast */
@ -336,7 +334,7 @@ arpresolve(ac, rt, m, dst, desten, rt0)
*/
if ((rt->rt_expire == 0 || rt->rt_expire > time.tv_sec) &&
sdl->sdl_family == AF_LINK && sdl->sdl_alen != 0) {
bcopy(LLADDR(sdl), desten, sdl->sdl_alen);
(void)memcpy(desten, LLADDR(sdl), sdl->sdl_alen);
return 1;
}
/*
@ -429,8 +427,8 @@ in_arpinput(m)
ea = mtod(m, struct ether_arp *);
op = ntohs(ea->arp_op);
bcopy((caddr_t)ea->arp_spa, (caddr_t)&isaddr, sizeof (isaddr));
bcopy((caddr_t)ea->arp_tpa, (caddr_t)&itaddr, sizeof (itaddr));
(void)memcpy(&isaddr, ea->arp_spa, sizeof (isaddr));
(void)memcpy(&itaddr, ea->arp_tpa, sizeof (itaddr));
for (ia = in_ifaddr; ia; ia = ia->ia_next)
if (ia->ia_ifp == &ac->ac_if) {
maybe_ia = ia;
@ -464,8 +462,8 @@ in_arpinput(m)
bcmp((caddr_t)ea->arp_sha, LLADDR(sdl), sdl->sdl_alen))
log(LOG_INFO, "arp info overwritten for %s by %s\n",
inet_ntoa(isaddr), ether_sprintf(ea->arp_sha));
bcopy((caddr_t)ea->arp_sha, LLADDR(sdl),
sdl->sdl_alen = sizeof(ea->arp_sha));
(void)memcpy(LLADDR(sdl), ea->arp_sha, sizeof(ea->arp_sha));
sdl->sdl_alen = sizeof(ea->arp_sha);
if (rt->rt_expire)
rt->rt_expire = time.tv_sec + arpt_keep;
rt->rt_flags &= ~RTF_REJECT;
@ -484,10 +482,8 @@ reply:
}
if (itaddr.s_addr == myaddr.s_addr) {
/* I am the target */
bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
sizeof(ea->arp_sha));
bcopy((caddr_t)ac->ac_enaddr, (caddr_t)ea->arp_sha,
sizeof(ea->arp_sha));
(void)memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha));
(void)memcpy(ea->arp_sha, ac->ac_enaddr, sizeof(ea->arp_sha));
} else {
la = arplookup(itaddr.s_addr, 0, SIN_PROXY);
if (la == NULL) {
@ -513,10 +509,8 @@ reply:
rtfree(rt);
goto out;
}
bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
sizeof(ea->arp_sha));
bcopy(ac->ac_enaddr, (caddr_t)ea->arp_sha,
sizeof(ea->arp_sha));
(void)memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha));
(void)memcpy(ea->arp_sha, ac->ac_enaddr, sizeof(ea->arp_sha));
rtfree(rt);
#ifdef DEBUG_PROXY
printf("arp: proxying for %s\n",
@ -527,21 +521,18 @@ reply:
#endif
} else {
rt = la->la_rt;
bcopy((caddr_t)ea->arp_sha, (caddr_t)ea->arp_tha,
sizeof(ea->arp_sha));
(void)memcpy(ea->arp_tha, ea->arp_sha, sizeof(ea->arp_sha));
sdl = SDL(rt->rt_gateway);
bcopy(LLADDR(sdl), (caddr_t)ea->arp_sha,
sizeof(ea->arp_sha));
(void)memcpy(ea->arp_sha, LLADDR(sdl), sizeof(ea->arp_sha));
}
}
bcopy((caddr_t)ea->arp_spa, (caddr_t)ea->arp_tpa, sizeof(ea->arp_spa));
bcopy((caddr_t)&itaddr, (caddr_t)ea->arp_spa, sizeof(ea->arp_spa));
(void)memcpy(ea->arp_tpa, ea->arp_spa, sizeof(ea->arp_spa));
(void)memcpy(ea->arp_spa, &itaddr, sizeof(ea->arp_spa));
ea->arp_op = htons(ARPOP_REPLY);
ea->arp_pro = htons(ETHERTYPE_IP); /* let's be sure! */
eh = (struct ether_header *)sa.sa_data;
bcopy((caddr_t)ea->arp_tha, (caddr_t)eh->ether_dhost,
sizeof(eh->ether_dhost));
(void)memcpy(eh->ether_dhost, ea->arp_tha, sizeof(eh->ether_dhost));
eh->ether_type = ETHERTYPE_ARP;
sa.sa_family = AF_UNSPEC;
sa.sa_len = sizeof(sa);

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_input.c 8.2 (Berkeley) 1/4/94
* $Id: ip_input.c,v 1.18 1995/03/16 18:14:55 bde Exp $
* $Id: ip_input.c,v 1.19 1995/03/16 18:22:28 wollman Exp $
*/
#include <sys/param.h>
@ -755,7 +755,7 @@ ip_dooptions(m)
/*
* locate outgoing interface
*/
bcopy((caddr_t)(cp + off), (caddr_t)&ipaddr.sin_addr,
(void)memcpy(&ipaddr.sin_addr, cp + off,
sizeof(ipaddr.sin_addr));
if (opt == IPOPT_SSRR) {
@ -771,8 +771,8 @@ ip_dooptions(m)
goto bad;
}
ip->ip_dst = ipaddr.sin_addr;
bcopy((caddr_t)&(IA_SIN(ia)->sin_addr),
(caddr_t)(cp + off), sizeof(struct in_addr));
(void)memcpy(cp + off, &(IA_SIN(ia)->sin_addr),
sizeof(struct in_addr));
cp[IPOPT_OFFSET] += sizeof(struct in_addr);
/*
* Let ip_intr's mcast routing check handle mcast pkts
@ -791,7 +791,7 @@ ip_dooptions(m)
off--; /* 0 origin */
if (off > optlen - sizeof(struct in_addr))
break;
bcopy((caddr_t)(&ip->ip_dst), (caddr_t)&ipaddr.sin_addr,
(void)memcpy(&ipaddr.sin_addr, &ip->ip_dst,
sizeof(ipaddr.sin_addr));
/*
* locate outgoing interface; if we're the destination,
@ -803,8 +803,8 @@ ip_dooptions(m)
code = ICMP_UNREACH_HOST;
goto bad;
}
bcopy((caddr_t)&(IA_SIN(ia)->sin_addr),
(caddr_t)(cp + off), sizeof(struct in_addr));
(void)memcpy(cp + off, &(IA_SIN(ia)->sin_addr),
sizeof(struct in_addr));
cp[IPOPT_OFFSET] += sizeof(struct in_addr);
break;
@ -833,8 +833,8 @@ ip_dooptions(m)
m->m_pkthdr.rcvif);
if (ia == 0)
continue;
bcopy((caddr_t)&IA_SIN(ia)->sin_addr,
(caddr_t)sin, sizeof(struct in_addr));
(void)memcpy(sin, &IA_SIN(ia)->sin_addr,
sizeof(struct in_addr));
ipt->ipt_ptr += sizeof(struct in_addr);
break;
@ -842,7 +842,7 @@ ip_dooptions(m)
if (ipt->ipt_ptr + sizeof(n_time) +
sizeof(struct in_addr) > ipt->ipt_len)
goto bad;
bcopy((caddr_t)sin, (caddr_t)&ipaddr.sin_addr,
(void)memcpy(&ipaddr.sin_addr, sin,
sizeof(struct in_addr));
if (ifa_ifwithaddr((SA)&ipaddr) == 0)
continue;
@ -853,7 +853,7 @@ ip_dooptions(m)
goto bad;
}
ntime = iptime();
bcopy((caddr_t)&ntime, (caddr_t)cp + ipt->ipt_ptr - 1,
(void)memcpy(cp + ipt->ipt_ptr - 1, &ntime,
sizeof(n_time));
ipt->ipt_ptr += sizeof(n_time);
}
@ -916,7 +916,7 @@ save_rte(option, dst)
#endif
if (olen > sizeof(ip_srcrt) - (1 + sizeof(dst)))
return;
bcopy((caddr_t)option, (caddr_t)ip_srcrt.srcopt, olen);
(void)memcpy(ip_srcrt.srcopt, option, olen);
ip_nhops = (olen - IPOPT_OFFSET - 1) / sizeof(struct in_addr);
ip_srcrt.dst = dst;
}
@ -963,8 +963,8 @@ ip_srcroute()
*/
ip_srcrt.nop = IPOPT_NOP;
ip_srcrt.srcopt[IPOPT_OFFSET] = IPOPT_MINOFF;
bcopy((caddr_t)&ip_srcrt.nop,
mtod(m, caddr_t) + sizeof(struct in_addr), OPTSIZ);
(void)memcpy(mtod(m, caddr_t) + sizeof(struct in_addr),
&ip_srcrt.nop, OPTSIZ);
q = (struct in_addr *)(mtod(m, caddr_t) +
sizeof(struct in_addr) + OPTSIZ);
#undef OPTSIZ
@ -1010,7 +1010,7 @@ ip_stripoptions(m, mopt)
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);
bcopy(opts + olen, opts, (unsigned)i);
m->m_len -= olen;
if (m->m_flags & M_PKTHDR)
m->m_pkthdr.len -= olen;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)ip_output.c 8.3 (Berkeley) 1/21/94
* $Id: ip_output.c,v 1.16 1995/04/09 01:29:22 davidg Exp $
* $Id: ip_output.c,v 1.17 1995/04/26 18:10:55 pst Exp $
*/
#include <sys/param.h>
@ -461,7 +461,7 @@ ip_insertoptions(m, opt, phlen)
m = n;
m->m_len = optlen + sizeof(struct ip);
m->m_data += max_linkhdr;
bcopy((caddr_t)ip, mtod(m, caddr_t), sizeof(struct ip));
(void)memcpy(mtod(m, void *), ip, sizeof(struct ip));
} else {
m->m_data -= optlen;
m->m_len += optlen;
@ -469,7 +469,7 @@ ip_insertoptions(m, opt, phlen)
ovbcopy((caddr_t)ip, mtod(m, caddr_t), sizeof(struct ip));
}
ip = mtod(m, struct ip *);
bcopy((caddr_t)p->ipopt_list, (caddr_t)(ip + 1), (unsigned)optlen);
(void)memcpy(ip + 1, p->ipopt_list, (unsigned)optlen);
*phlen = sizeof(struct ip) + optlen;
ip->ip_len += optlen;
return (m);
@ -504,7 +504,7 @@ ip_optcopy(ip, jp)
if (optlen > cnt)
optlen = cnt;
if (IPOPT_COPIED(opt)) {
bcopy((caddr_t)cp, (caddr_t)dp, (unsigned)optlen);
(void)memcpy(dp, cp, (unsigned)optlen);
dp += optlen;
}
}
@ -608,8 +608,8 @@ ip_ctloutput(op, so, level, optname, mp)
*mp = m = m_get(M_WAIT, MT_SOOPTS);
if (inp->inp_options) {
m->m_len = inp->inp_options->m_len;
bcopy(mtod(inp->inp_options, caddr_t),
mtod(m, caddr_t), (unsigned)m->m_len);
(void)memcpy(mtod(m, void *),
mtod(inp->inp_options, void *), (unsigned)m->m_len);
} else
m->m_len = 0;
break;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tcp_output.c 8.3 (Berkeley) 12/30/93
* $Id: tcp_output.c,v 1.8 1995/02/16 00:55:40 wollman Exp $
* $Id: tcp_output.c,v 1.9 1995/04/09 01:29:25 davidg Exp $
*/
#include <sys/param.h>
@ -311,7 +311,7 @@ send:
opt[0] = TCPOPT_MAXSEG;
opt[1] = TCPOLEN_MAXSEG;
mss = htons((u_short) tcp_mssopt(tp));
bcopy((caddr_t)&mss, (caddr_t)(opt + 2), sizeof(mss));
(void)memcpy(opt + 2, &mss, sizeof(mss));
optlen = TCPOLEN_MAXSEG;
if ((tp->t_flags & TF_REQ_SCALE) &&
@ -520,7 +520,7 @@ send:
ti = mtod(m, struct tcpiphdr *);
if (tp->t_template == 0)
panic("tcp_output");
bcopy((caddr_t)tp->t_template, (caddr_t)ti, sizeof (struct tcpiphdr));
(void)memcpy(ti, tp->t_template, sizeof (struct tcpiphdr));
/*
* Fill in fields, remembering maximum advertised
@ -549,7 +549,7 @@ send:
ti->ti_seq = htonl(tp->snd_max);
ti->ti_ack = htonl(tp->rcv_nxt);
if (optlen) {
bcopy((caddr_t)opt, (caddr_t)(ti + 1), optlen);
(void)memcpy(ti + 1, opt, optlen);
ti->ti_off = (sizeof (struct tcphdr) + optlen) >> 2;
}
ti->ti_flags = flags;

View File

@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)udp_usrreq.c 8.4 (Berkeley) 1/21/94
* $Id: udp_usrreq.c,v 1.9 1995/04/09 01:29:30 davidg Exp $
* $Id: udp_usrreq.c,v 1.10 1995/05/03 07:16:53 davidg Exp $
*/
#include <sys/param.h>
@ -343,7 +343,7 @@ udp_saveopt(p, size, type)
if ((m = m_get(M_DONTWAIT, MT_CONTROL)) == NULL)
return ((struct mbuf *) NULL);
cp = (struct cmsghdr *) mtod(m, struct cmsghdr *);
bcopy(p, CMSG_DATA(cp), size);
(void)memcpy(CMSG_DATA(cp), p, size);
size += sizeof(*cp);
m->m_len = size;
cp->cmsg_len = size;