From 6c6287fe271247607d595cdf2777af3e65547680 Mon Sep 17 00:00:00 2001 From: David Gwynne Date: Wed, 21 Aug 2013 05:21:47 +0000 Subject: get rid of the copy argument in m_devget that let you provide an alternative to bcopy since noone uses it. while there use memcpy instead of bcopy because we know the memory cannot overlap. ok henning@ matthew@ mikeb@ deraadt@ --- sys/arch/sparc/dev/hme.c | 4 ++-- sys/arch/sparc64/dev/vnet.c | 4 ++-- sys/dev/ic/dc.c | 5 ++--- sys/dev/ic/mtd8xx.c | 5 ++--- sys/dev/ic/rtl81x9.c | 7 +++---- sys/dev/ic/ti.c | 4 ++-- sys/dev/pci/if_ale.c | 4 ++-- sys/dev/pci/if_bce.c | 4 ++-- sys/dev/pci/if_cas.c | 6 +++--- sys/dev/pci/if_lge.c | 4 ++-- sys/dev/pci/if_nge.c | 4 ++-- sys/dev/pci/if_sis.c | 4 ++-- sys/dev/pci/if_sk.c | 4 ++-- sys/dev/pci/if_vge.c | 4 ++-- sys/dev/pci/if_vr.c | 4 ++-- sys/dev/pci/if_wb.c | 4 ++-- sys/dev/pcmcia/if_malo.c | 4 ++-- sys/dev/usb/if_upgt.c | 4 ++-- sys/kern/uipc_mbuf.c | 11 +++-------- sys/net/pfkeyv2.c | 4 ++-- sys/sys/mbuf.h | 5 ++--- 21 files changed, 45 insertions(+), 54 deletions(-) (limited to 'sys') diff --git a/sys/arch/sparc/dev/hme.c b/sys/arch/sparc/dev/hme.c index fbe9f57f20c..b9dab909d29 100644 --- a/sys/arch/sparc/dev/hme.c +++ b/sys/arch/sparc/dev/hme.c @@ -1,4 +1,4 @@ -/* $OpenBSD: hme.c,v 1.62 2009/08/13 17:01:31 phessler Exp $ */ +/* $OpenBSD: hme.c,v 1.63 2013/08/21 05:21:42 dlg Exp $ */ /* * Copyright (c) 1998 Jason L. Wright (jason@thought.net) @@ -938,7 +938,7 @@ hme_read(sc, idx, len, flags) /* Pull packet off interface. */ m = m_devget(sc->sc_bufs->rx_buf[idx] + HME_RX_OFFSET, len, - HME_RX_OFFSET, &sc->sc_arpcom.ac_if, NULL); + HME_RX_OFFSET, &sc->sc_arpcom.ac_if); if (m == NULL) { ifp->if_ierrors++; return; diff --git a/sys/arch/sparc64/dev/vnet.c b/sys/arch/sparc64/dev/vnet.c index 614c137ff3e..007f60b4343 100644 --- a/sys/arch/sparc64/dev/vnet.c +++ b/sys/arch/sparc64/dev/vnet.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vnet.c,v 1.28 2012/12/07 21:56:06 kettenis Exp $ */ +/* $OpenBSD: vnet.c,v 1.29 2013/08/21 05:21:42 dlg Exp $ */ /* * Copyright (c) 2009 Mark Kettenis * @@ -719,7 +719,7 @@ vnet_rx_vio_desc_data(struct vnet_softc *sc, struct vio_msg_tag *tag) } /* Stupid OBP doesn't align properly. */ - m = m_devget(buf, dm->nbytes, ETHER_ALIGN, ifp, NULL); + m = m_devget(buf, dm->nbytes, ETHER_ALIGN, ifp); pool_put(&sc->sc_pool, buf); if (m == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/ic/dc.c b/sys/dev/ic/dc.c index ea1f251b3cc..4bf3b26a21e 100644 --- a/sys/dev/ic/dc.c +++ b/sys/dev/ic/dc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dc.c,v 1.126 2013/08/07 01:06:29 bluhm Exp $ */ +/* $OpenBSD: dc.c,v 1.127 2013/08/21 05:21:43 dlg Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -2185,8 +2185,7 @@ dc_rxeof(struct dc_softc *sc) total_len -= ETHER_CRC_LEN; m->m_pkthdr.rcvif = ifp; - m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, - ifp, NULL); + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp); dc_newbuf(sc, i, m); DC_INC(i, DC_RX_LIST_CNT); if (m0 == NULL) { diff --git a/sys/dev/ic/mtd8xx.c b/sys/dev/ic/mtd8xx.c index 5e416f2fc8c..add477fefc5 100644 --- a/sys/dev/ic/mtd8xx.c +++ b/sys/dev/ic/mtd8xx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mtd8xx.c,v 1.19 2012/11/29 21:10:32 brad Exp $ */ +/* $OpenBSD: mtd8xx.c,v 1.20 2013/08/21 05:21:43 dlg Exp $ */ /* * Copyright (c) 2003 Oleg Safiullin @@ -926,8 +926,7 @@ mtd_rxeof(struct mtd_softc *sc) 0, sc->mtd_cdata.mtd_rx_chain[i].sd_map->dm_mapsize, BUS_DMASYNC_POSTREAD); - m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, - ifp, NULL); + m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, ifp); mtd_newbuf(sc, i, m); i = (i + 1) % MTD_RX_LIST_CNT; if (m0 == NULL) { diff --git a/sys/dev/ic/rtl81x9.c b/sys/dev/ic/rtl81x9.c index 6beb7559ad1..ea3430b3d65 100644 --- a/sys/dev/ic/rtl81x9.c +++ b/sys/dev/ic/rtl81x9.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl81x9.c,v 1.78 2013/08/07 01:06:31 bluhm Exp $ */ +/* $OpenBSD: rtl81x9.c,v 1.79 2013/08/21 05:21:43 dlg Exp $ */ /* * Copyright (c) 1997, 1998 @@ -650,7 +650,7 @@ rl_rxeof(struct rl_softc *sc) wrap = (sc->rl_cdata.rl_rx_buf + RL_RXBUFLEN) - rxbufpos; if (total_len > wrap) { - m = m_devget(rxbufpos, wrap, ETHER_ALIGN, ifp, NULL); + m = m_devget(rxbufpos, wrap, ETHER_ALIGN, ifp); if (m != NULL) { m_copyback(m, wrap, total_len - wrap, sc->rl_cdata.rl_rx_buf, M_NOWAIT); @@ -661,8 +661,7 @@ rl_rxeof(struct rl_softc *sc) } cur_rx = (total_len - wrap + ETHER_CRC_LEN); } else { - m = m_devget(rxbufpos, total_len, ETHER_ALIGN, ifp, - NULL); + m = m_devget(rxbufpos, total_len, ETHER_ALIGN, ifp); cur_rx += total_len + 4 + ETHER_CRC_LEN; } diff --git a/sys/dev/ic/ti.c b/sys/dev/ic/ti.c index 078b078bdb5..0adef4bf466 100644 --- a/sys/dev/ic/ti.c +++ b/sys/dev/ic/ti.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ti.c,v 1.5 2013/08/07 01:06:31 bluhm Exp $ */ +/* $OpenBSD: ti.c,v 1.6 2013/08/21 05:21:43 dlg Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -1742,7 +1742,7 @@ ti_rxeof(struct ti_softc *sc) == ENOBUFS) { struct mbuf *m0; m0 = m_devget(mtod(m, char *), cur_rx->ti_len, - ETHER_ALIGN, ifp, NULL); + ETHER_ALIGN, ifp); ti_newbuf_jumbo(sc, sc->ti_jumbo, m); if (m0 == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/pci/if_ale.c b/sys/dev/pci/if_ale.c index 3794f9b0530..aadeb1c96b5 100644 --- a/sys/dev/pci/if_ale.c +++ b/sys/dev/pci/if_ale.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ale.c,v 1.27 2013/08/07 01:06:33 bluhm Exp $ */ +/* $OpenBSD: if_ale.c,v 1.28 2013/08/21 05:21:43 dlg Exp $ */ /*- * Copyright (c) 2008, Pyun YongHyeon * All rights reserved. @@ -1548,7 +1548,7 @@ ale_rxeof(struct ale_softc *sc) * on these low-end consumer ethernet controller. */ m = m_devget((char *)(rs + 1), length - ETHER_CRC_LEN, - ETHER_ALIGN, ifp, NULL); + ETHER_ALIGN, ifp); if (m == NULL) { ifp->if_iqdrops++; ale_rx_update_page(sc, &rx_page, length, &prod); diff --git a/sys/dev/pci/if_bce.c b/sys/dev/pci/if_bce.c index 5ef750d3464..5b745973e6e 100644 --- a/sys/dev/pci/if_bce.c +++ b/sys/dev/pci/if_bce.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bce.c,v 1.36 2013/08/07 01:06:33 bluhm Exp $ */ +/* $OpenBSD: if_bce.c,v 1.37 2013/08/21 05:21:43 dlg Exp $ */ /* $NetBSD: if_bce.c,v 1.3 2003/09/29 01:53:02 mrg Exp $ */ /* @@ -753,7 +753,7 @@ bce_rxintr(struct bce_softc *sc) len -= ETHER_CRC_LEN; m = m_devget(sc->bce_data + i * MCLBYTES + - BCE_PREPKT_HEADER_SIZE, len, ETHER_ALIGN, ifp, NULL); + BCE_PREPKT_HEADER_SIZE, len, ETHER_ALIGN, ifp); ifp->if_ipackets++; #if NBPFILTER > 0 diff --git a/sys/dev/pci/if_cas.c b/sys/dev/pci/if_cas.c index cd62796915d..37d6985418a 100644 --- a/sys/dev/pci/if_cas.c +++ b/sys/dev/pci/if_cas.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_cas.c,v 1.32 2011/04/03 15:36:02 jasper Exp $ */ +/* $OpenBSD: if_cas.c,v 1.33 2013/08/21 05:21:44 dlg Exp $ */ /* * @@ -1192,7 +1192,7 @@ cas_rint(struct cas_softc *sc) rxs->rxs_dmamap->dm_mapsize, BUS_DMASYNC_POSTREAD); cp = rxs->rxs_kva + off * 256 + ETHER_ALIGN; - m = m_devget(cp, len, ETHER_ALIGN, ifp, NULL); + m = m_devget(cp, len, ETHER_ALIGN, ifp); if (word[0] & CAS_RC0_RELEASE_HDR) cas_add_rxbuf(sc, idx); @@ -1228,7 +1228,7 @@ cas_rint(struct cas_softc *sc) /* XXX We should not be copying the packet here. */ cp = rxs->rxs_kva + off + ETHER_ALIGN; - m = m_devget(cp, len, ETHER_ALIGN, ifp, NULL); + m = m_devget(cp, len, ETHER_ALIGN, ifp); if (word[0] & CAS_RC0_RELEASE_DATA) cas_add_rxbuf(sc, idx); diff --git a/sys/dev/pci/if_lge.c b/sys/dev/pci/if_lge.c index fa97c0854a7..7c4977aaac6 100644 --- a/sys/dev/pci/if_lge.c +++ b/sys/dev/pci/if_lge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_lge.c,v 1.58 2013/08/07 01:06:36 bluhm Exp $ */ +/* $OpenBSD: if_lge.c,v 1.59 2013/08/21 05:21:44 dlg Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -890,7 +890,7 @@ lge_rxeof(struct lge_softc *sc, int cnt) if (lge_newbuf(sc, &LGE_RXTAIL(sc), NULL) == ENOBUFS) { m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, - ifp, NULL); + ifp); lge_newbuf(sc, &LGE_RXTAIL(sc), m); if (m0 == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/pci/if_nge.c b/sys/dev/pci/if_nge.c index 5c47a37cae7..bfc983d2f75 100644 --- a/sys/dev/pci/if_nge.c +++ b/sys/dev/pci/if_nge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nge.c,v 1.74 2013/08/07 01:06:36 bluhm Exp $ */ +/* $OpenBSD: if_nge.c,v 1.75 2013/08/21 05:21:44 dlg Exp $ */ /* * Copyright (c) 2001 Wind River Systems * Copyright (c) 1997, 1998, 1999, 2000, 2001 @@ -1295,7 +1295,7 @@ nge_rxeof(sc) if (nge_newbuf(sc, cur_rx, NULL) == ENOBUFS) { #endif m0 = m_devget(mtod(m, char *), total_len, - ETHER_ALIGN, ifp, NULL); + ETHER_ALIGN, ifp); nge_newbuf(sc, cur_rx, m); if (m0 == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/pci/if_sis.c b/sys/dev/pci/if_sis.c index 10c13e8b73f..b33fe005453 100644 --- a/sys/dev/pci/if_sis.c +++ b/sys/dev/pci/if_sis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sis.c,v 1.112 2013/08/07 01:06:37 bluhm Exp $ */ +/* $OpenBSD: if_sis.c,v 1.113 2013/08/21 05:21:44 dlg Exp $ */ /* * Copyright (c) 1997, 1998, 1999 * Bill Paul . All rights reserved. @@ -1402,7 +1402,7 @@ sis_rxeof(struct sis_softc *sc) { struct mbuf *m0; m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, - ifp, NULL); + ifp); m_freem(m); if (m0 == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/pci/if_sk.c b/sys/dev/pci/if_sk.c index 2cbb83fdbac..85269227228 100644 --- a/sys/dev/pci/if_sk.c +++ b/sys/dev/pci/if_sk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_sk.c,v 1.165 2013/08/07 01:06:37 bluhm Exp $ */ +/* $OpenBSD: if_sk.c,v 1.166 2013/08/21 05:21:44 dlg Exp $ */ /* * Copyright (c) 1997, 1998, 1999, 2000 @@ -1740,7 +1740,7 @@ sk_rxeof(struct sk_if_softc *sc_if) if (sk_newbuf(sc_if, cur, NULL, dmamap) == ENOBUFS) { struct mbuf *m0; m0 = m_devget(mtod(m, char *), total_len, ETHER_ALIGN, - ifp, NULL); + ifp); sk_newbuf(sc_if, cur, m, dmamap); if (m0 == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/pci/if_vge.c b/sys/dev/pci/if_vge.c index cb813ccbc8f..658fa5114f1 100644 --- a/sys/dev/pci/if_vge.c +++ b/sys/dev/pci/if_vge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vge.c,v 1.56 2013/08/07 01:06:38 bluhm Exp $ */ +/* $OpenBSD: if_vge.c,v 1.57 2013/08/21 05:21:44 dlg Exp $ */ /* $FreeBSD: if_vge.c,v 1.3 2004/09/11 22:13:25 wpaul Exp $ */ /* * Copyright (c) 2004 @@ -1081,7 +1081,7 @@ vge_rxeof(struct vge_softc *sc) } m0 = m_devget(mtod(m, char *), - total_len - ETHER_CRC_LEN, ETHER_ALIGN, ifp, NULL); + total_len - ETHER_CRC_LEN, ETHER_ALIGN, ifp); vge_newbuf(sc, i, m); if (m0 == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/pci/if_vr.c b/sys/dev/pci/if_vr.c index cb460c3ba5d..394451e3baa 100644 --- a/sys/dev/pci/if_vr.c +++ b/sys/dev/pci/if_vr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vr.c,v 1.129 2013/08/07 01:06:38 bluhm Exp $ */ +/* $OpenBSD: if_vr.c,v 1.130 2013/08/21 05:21:44 dlg Exp $ */ /* * Copyright (c) 1997, 1998 @@ -902,7 +902,7 @@ vr_rxeof(struct vr_softc *sc) { struct mbuf *m0; m0 = m_devget(mtod(m, caddr_t), total_len, - ETHER_ALIGN, ifp, NULL); + ETHER_ALIGN, ifp); m_freem(m); if (m0 == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/pci/if_wb.c b/sys/dev/pci/if_wb.c index c79b4c0e514..96762a10723 100644 --- a/sys/dev/pci/if_wb.c +++ b/sys/dev/pci/if_wb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wb.c,v 1.52 2013/08/07 01:06:39 bluhm Exp $ */ +/* $OpenBSD: if_wb.c,v 1.53 2013/08/21 05:21:45 dlg Exp $ */ /* * Copyright (c) 1997, 1998 @@ -976,7 +976,7 @@ void wb_rxeof(sc) total_len -= ETHER_CRC_LEN; m = m_devget(cur_rx->wb_buf + sizeof(u_int64_t), total_len, - ETHER_ALIGN, ifp, NULL); + ETHER_ALIGN, ifp); wb_newbuf(sc, cur_rx); if (m == NULL) { ifp->if_ierrors++; diff --git a/sys/dev/pcmcia/if_malo.c b/sys/dev/pcmcia/if_malo.c index 199626cd7e6..86b70da6b7c 100644 --- a/sys/dev/pcmcia/if_malo.c +++ b/sys/dev/pcmcia/if_malo.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_malo.c,v 1.73 2011/07/03 15:47:17 matthew Exp $ */ +/* $OpenBSD: if_malo.c,v 1.74 2013/08/21 05:21:45 dlg Exp $ */ /* * Copyright (c) 2007 Marcus Glocker @@ -971,7 +971,7 @@ cmalo_rx(struct malo_softc *sc) /* prepare mbuf */ m = m_devget(sc->sc_data + rxdesc->pkgoffset, - rxdesc->pkglen, ETHER_ALIGN, ifp, NULL); + rxdesc->pkglen, ETHER_ALIGN, ifp); if (m == NULL) { DPRINTF(1, "RX m_devget failed\n"); ifp->if_ierrors++; diff --git a/sys/dev/usb/if_upgt.c b/sys/dev/usb/if_upgt.c index 43acf4471e2..3d371f1d106 100644 --- a/sys/dev/usb/if_upgt.c +++ b/sys/dev/usb/if_upgt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_upgt.c,v 1.59 2013/08/07 01:06:42 bluhm Exp $ */ +/* $OpenBSD: if_upgt.c,v 1.60 2013/08/21 05:21:45 dlg Exp $ */ /* * Copyright (c) 2007 Marcus Glocker @@ -1760,7 +1760,7 @@ upgt_rx(struct upgt_softc *sc, uint8_t *data, int pkglen) rxdesc = (struct upgt_lmac_rx_desc *)data; /* create mbuf which is suitable for strict alignment archs */ - m = m_devget(rxdesc->data, pkglen, ETHER_ALIGN, ifp, NULL); + m = m_devget(rxdesc->data, pkglen, ETHER_ALIGN, ifp); if (m == NULL) { DPRINTF(1, "%s: could not create RX mbuf!\n", sc->sc_dev.dv_xname); ifp->if_ierrors++; diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c index fdc4b887c32..774a5e16ffd 100644 --- a/sys/kern/uipc_mbuf.c +++ b/sys/kern/uipc_mbuf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_mbuf.c,v 1.174 2013/08/08 23:25:06 syl Exp $ */ +/* $OpenBSD: uipc_mbuf.c,v 1.175 2013/08/21 05:21:45 dlg Exp $ */ /* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */ /* @@ -1168,8 +1168,7 @@ extpacket: * Routine to copy from device local memory into mbufs. */ struct mbuf * -m_devget(char *buf, int totlen, int off, struct ifnet *ifp, - void (*copy)(const void *, void *, size_t)) +m_devget(char *buf, int totlen, int off, struct ifnet *ifp) { struct mbuf *m; struct mbuf *top, **mp; @@ -1224,11 +1223,7 @@ m_devget(char *buf, int totlen, int off, struct ifnet *ifp, } m->m_len = len = min(totlen, len); - - if (copy) - copy(buf, mtod(m, caddr_t), (size_t)len); - else - bcopy(buf, mtod(m, caddr_t), (size_t)len); + memcpy(mtod(m, void *), buf, (size_t)len); buf += len; *mp = m; diff --git a/sys/net/pfkeyv2.c b/sys/net/pfkeyv2.c index 45dadc17b96..3cdd65201fb 100644 --- a/sys/net/pfkeyv2.c +++ b/sys/net/pfkeyv2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pfkeyv2.c,v 1.130 2013/03/09 16:51:30 deraadt Exp $ */ +/* $OpenBSD: pfkeyv2.c,v 1.131 2013/08/21 05:21:46 dlg Exp $ */ /* * @(#)COPYRIGHT 1.1 (NRL) 17 January 1995 @@ -137,7 +137,7 @@ extern struct pool ipsec_policy_pool; int pfdatatopacket(void *data, int len, struct mbuf **packet) { - if (!(*packet = m_devget(data, len, 0, NULL, NULL))) + if (!(*packet = m_devget(data, len, 0, NULL))) return (ENOMEM); /* Make sure, all data gets zeroized on free */ diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index c6eaba98c13..376d1341c04 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mbuf.h,v 1.166 2013/08/13 09:52:54 mpi Exp $ */ +/* $OpenBSD: mbuf.h,v 1.167 2013/08/21 05:21:46 dlg Exp $ */ /* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */ /* @@ -423,8 +423,7 @@ void m_freem(struct mbuf *); void m_reclaim(void *, int); void m_copydata(struct mbuf *, int, int, caddr_t); void m_cat(struct mbuf *, struct mbuf *); -struct mbuf *m_devget(char *, int, int, struct ifnet *, - void (*)(const void *, void *, size_t)); +struct mbuf *m_devget(char *, int, int, struct ifnet *); int m_apply(struct mbuf *, int, int, int (*)(caddr_t, caddr_t, unsigned int), caddr_t); int m_dup_pkthdr(struct mbuf *, struct mbuf *, int); -- cgit v1.2.3