summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2007-09-15 16:43:52 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2007-09-15 16:43:52 +0000
commitedb2678b922125cc3a94923d29e556e735c9b7e7 (patch)
treeb179c9713e26890a9c158d42a1e1db6b305d2240 /sys
parent9aadb8edf593100cac2242cb9715624b7948b5e7 (diff)
malloc sweep:
-remove useless casts -MALLOC/FREE -> malloc/free -use M_ZERO where appropriate instead of seperate bzero feedback & ok krw, hshoexer
Diffstat (limited to 'sys')
-rw-r--r--sys/net/bpf.c5
-rw-r--r--sys/net/bridgestp.c8
-rw-r--r--sys/net/bsd-comp.c15
-rw-r--r--sys/net/if.c22
-rw-r--r--sys/net/if_bridge.c24
-rw-r--r--sys/net/if_ethersubr.c4
-rw-r--r--sys/net/if_faith.c5
-rw-r--r--sys/net/if_gif.c9
-rw-r--r--sys/net/if_gre.c5
-rw-r--r--sys/net/if_loop.c5
-rw-r--r--sys/net/if_pfsync.c6
-rw-r--r--sys/net/if_ppp.c22
-rw-r--r--sys/net/if_pppoe.c5
-rw-r--r--sys/net/if_sl.c5
-rw-r--r--sys/net/if_trunk.c8
-rw-r--r--sys/net/if_tun.c5
-rw-r--r--sys/net/if_vlan.c14
-rw-r--r--sys/net/pf_if.c5
-rw-r--r--sys/net/pf_ioctl.c24
-rw-r--r--sys/net/ppp-deflate.c20
-rw-r--r--sys/net/route.c12
-rw-r--r--sys/net/rtsock.c5
22 files changed, 93 insertions, 140 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index 15cfeecee8e..658dd6a7d5a 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.66 2007/07/25 23:11:53 art Exp $ */
+/* $OpenBSD: bpf.c,v 1.67 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -1485,8 +1485,7 @@ bpfilter_create(int unit)
if ((bd = bpfilter_lookup(unit)) != NULL)
return (NULL);
- if ((bd = malloc(sizeof(*bd), M_DEVBUF, M_NOWAIT)) != NULL) {
- bzero(bd, sizeof(*bd));
+ if ((bd = malloc(sizeof(*bd), M_DEVBUF, M_NOWAIT|M_ZERO)) != NULL) {
bd->bd_unit = unit;
LIST_INSERT_HEAD(&bpf_d_list, bd, bd_list);
}
diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c
index 579c837b393..3b9d5b5657f 100644
--- a/sys/net/bridgestp.c
+++ b/sys/net/bridgestp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bridgestp.c,v 1.26 2007/02/15 12:43:26 reyk Exp $ */
+/* $OpenBSD: bridgestp.c,v 1.27 2007/09/15 16:43:51 henning Exp $ */
/*
* Copyright (c) 2000 Jason L. Wright (jason@thought.net)
@@ -1940,8 +1940,7 @@ bstp_create(struct ifnet *ifp)
int s;
s = splnet();
- bs = (struct bstp_state *)malloc(sizeof(*bs), M_DEVBUF, M_WAITOK);
- bzero(bs, sizeof(*bs));
+ bs = malloc(sizeof(*bs), M_DEVBUF, M_WAITOK|M_ZERO);
LIST_INIT(&bs->bs_bplist);
bs->bs_ifp = ifp;
@@ -2005,10 +2004,9 @@ bstp_add(struct bstp_state *bs, struct ifnet *ifp)
return (NULL);
}
- bp = (struct bstp_port *)malloc(sizeof(*bp), M_DEVBUF, M_NOWAIT);
+ bp = malloc(sizeof(*bp), M_DEVBUF, M_NOWAIT|M_ZERO);
if (bp == NULL)
return (NULL);
- bzero(bp, sizeof(*bp));
bp->bp_ifp = ifp;
bp->bp_bs = bs;
diff --git a/sys/net/bsd-comp.c b/sys/net/bsd-comp.c
index 97a04380f9e..84190e5057a 100644
--- a/sys/net/bsd-comp.c
+++ b/sys/net/bsd-comp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bsd-comp.c,v 1.6 2003/06/02 23:28:11 millert Exp $ */
+/* $OpenBSD: bsd-comp.c,v 1.7 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: bsd-comp.c,v 1.6 1996/10/13 02:10:58 christos Exp $ */
/* Because this code is derived from the 4.3BSD compress source:
@@ -346,18 +346,17 @@ bsd_alloc(options, opt_len, decomp)
maxmaxcode = MAXCODE(bits);
newlen = sizeof(*db) + (hsize-1) * (sizeof(db->dict[0]));
- MALLOC(db, struct bsd_db *, newlen, M_DEVBUF, M_NOWAIT);
+ db = malloc(newlen, M_DEVBUF, M_NOWAIT|M_ZERO);
if (!db)
return NULL;
- bzero(db, sizeof(*db) - sizeof(db->dict));
if (!decomp) {
db->lens = NULL;
} else {
- MALLOC(db->lens, u_int16_t *, (maxmaxcode+1) * sizeof(db->lens[0]),
- M_DEVBUF, M_NOWAIT);
+ db->lens = malloc((maxmaxcode+1) * sizeof(db->lens[0]), M_DEVBUF,
+ M_NOWAIT);
if (!db->lens) {
- FREE(db, M_DEVBUF);
+ free(db, M_DEVBUF);
return NULL;
}
}
@@ -378,8 +377,8 @@ bsd_free(state)
struct bsd_db *db = (struct bsd_db *) state;
if (db->lens)
- FREE(db->lens, M_DEVBUF);
- FREE(db, M_DEVBUF);
+ free(db->lens, M_DEVBUF);
+ free(db, M_DEVBUF);
}
static void *
diff --git a/sys/net/if.c b/sys/net/if.c
index e34c1b3ad2b..9a425dc2f22 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if.c,v 1.165 2007/07/06 14:00:59 naddy Exp $ */
+/* $OpenBSD: if.c,v 1.166 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@@ -234,8 +234,7 @@ if_attachsetup(struct ifnet *ifp)
/* grow ifnet_addrs */
m = oldlim * sizeof(ifa);
n = if_indexlim * sizeof(ifa);
- q = (caddr_t)malloc(n, M_IFADDR, M_WAITOK);
- bzero(q, n);
+ q = (caddr_t)malloc(n, M_IFADDR, M_WAITOK|M_ZERO);
if (ifnet_addrs) {
bcopy((caddr_t)ifnet_addrs, q, m);
free((caddr_t)ifnet_addrs, M_IFADDR);
@@ -245,8 +244,7 @@ if_attachsetup(struct ifnet *ifp)
/* grow ifindex2ifnet */
m = oldlim * sizeof(struct ifnet *);
n = if_indexlim * sizeof(struct ifnet *);
- q = (caddr_t)malloc(n, M_IFADDR, M_WAITOK);
- bzero(q, n);
+ q = (caddr_t)malloc(n, M_IFADDR, M_WAITOK|M_ZERO);
if (ifindex2ifnet) {
bcopy((caddr_t)ifindex2ifnet, q, m);
free((caddr_t)ifindex2ifnet, M_IFADDR);
@@ -311,8 +309,7 @@ if_alloc_sadl(struct ifnet *ifp)
socksize = sizeof(*sdl);
socksize = ROUNDUP(socksize);
ifasize = sizeof(*ifa) + 2 * socksize;
- ifa = (struct ifaddr *)malloc(ifasize, M_IFADDR, M_WAITOK);
- bzero((caddr_t)ifa, ifasize);
+ ifa = malloc(ifasize, M_IFADDR, M_WAITOK|M_ZERO);
sdl = (struct sockaddr_dl *)(ifa + 1);
sdl->sdl_len = socksize;
sdl->sdl_family = AF_LINK;
@@ -1592,10 +1589,9 @@ if_detached_watchdog(struct ifnet *ifp)
struct ifg_group *
if_creategroup(const char *groupname)
{
- struct ifg_group *ifg = NULL;
+ struct ifg_group *ifg;
- if ((ifg = (struct ifg_group *)malloc(sizeof(struct ifg_group),
- M_TEMP, M_NOWAIT)) == NULL)
+ if ((ifg = malloc(sizeof(*ifg), M_TEMP, M_NOWAIT)) == NULL)
return (NULL);
strlcpy(ifg->ifg_group, groupname, sizeof(ifg->ifg_group));
@@ -1628,12 +1624,10 @@ if_addgroup(struct ifnet *ifp, const char *groupname)
if (!strcmp(ifgl->ifgl_group->ifg_group, groupname))
return (EEXIST);
- if ((ifgl = (struct ifg_list *)malloc(sizeof(struct ifg_list), M_TEMP,
- M_NOWAIT)) == NULL)
+ if ((ifgl = malloc(sizeof(*ifgl), M_TEMP, M_NOWAIT)) == NULL)
return (ENOMEM);
- if ((ifgm = (struct ifg_member *)malloc(sizeof(struct ifg_member),
- M_TEMP, M_NOWAIT)) == NULL) {
+ if ((ifgm = malloc(sizeof(*ifgm), M_TEMP, M_NOWAIT)) == NULL) {
free(ifgl, M_TEMP);
return (ENOMEM);
}
diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c
index 5049b380262..63adb652da0 100644
--- a/sys/net/if_bridge.c
+++ b/sys/net/if_bridge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_bridge.c,v 1.164 2007/05/28 17:16:39 henning Exp $ */
+/* $OpenBSD: if_bridge.c,v 1.165 2007/09/15 16:43:51 henning Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
@@ -189,10 +189,9 @@ bridge_clone_create(struct if_clone *ifc, int unit)
struct ifnet *ifp;
int i, s;
- sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
return (ENOMEM);
- bzero(sc, sizeof(*sc));
sc->sc_stp = bstp_create(&sc->sc_if);
if (!sc->sc_stp) {
@@ -374,15 +373,13 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
break;
}
- p = (struct bridge_iflist *)malloc(
- sizeof(struct bridge_iflist), M_DEVBUF, M_NOWAIT);
+ p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT|M_ZERO);
if (p == NULL) {
if (ifs->if_type == IFT_ETHER)
ifpromisc(ifs, 0);
error = ENOMEM;
break;
}
- bzero(p, sizeof(struct bridge_iflist));
p->ifp = ifs;
p->bif_flags = IFBIF_LEARNING | IFBIF_DISCOVER;
@@ -435,13 +432,11 @@ bridge_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
error = EBUSY;
break;
}
- p = (struct bridge_iflist *)malloc(
- sizeof(struct bridge_iflist), M_DEVBUF, M_NOWAIT);
+ p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT|M_ZERO);
if (p == NULL) {
error = ENOMEM;
break;
}
- bzero(p, sizeof(struct bridge_iflist));
p->ifp = ifs;
p->bif_flags = IFBIF_SPAN;
SIMPLEQ_INIT(&p->bif_brlin);
@@ -1688,8 +1683,7 @@ bridge_rtupdate(struct bridge_softc *sc, struct ether_addr *ea,
if (p == LIST_END(&sc->sc_rts[h])) {
if (sc->sc_brtcnt >= sc->sc_brtmax)
goto done;
- p = (struct bridge_rtnode *)malloc(
- sizeof(struct bridge_rtnode), M_DEVBUF, M_NOWAIT);
+ p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT);
if (p == NULL)
goto done;
@@ -1728,8 +1722,7 @@ bridge_rtupdate(struct bridge_softc *sc, struct ether_addr *ea,
if (dir > 0) {
if (sc->sc_brtcnt >= sc->sc_brtmax)
goto done;
- p = (struct bridge_rtnode *)malloc(
- sizeof(struct bridge_rtnode), M_DEVBUF, M_NOWAIT);
+ p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT);
if (p == NULL)
goto done;
@@ -1750,8 +1743,7 @@ bridge_rtupdate(struct bridge_softc *sc, struct ether_addr *ea,
if (p == LIST_END(&sc->sc_rts[h])) {
if (sc->sc_brtcnt >= sc->sc_brtmax)
goto done;
- p = (struct bridge_rtnode *)malloc(
- sizeof(struct bridge_rtnode), M_DEVBUF, M_NOWAIT);
+ p = malloc(sizeof(*p), M_DEVBUF, M_NOWAIT);
if (p == NULL)
goto done;
@@ -2160,7 +2152,7 @@ bridge_addrule(struct bridge_iflist *bif, struct ifbrlreq *req, int out)
{
struct brl_node *n;
- n = (struct brl_node *)malloc(sizeof(struct brl_node), M_DEVBUF, M_NOWAIT);
+ n = malloc(sizeof(*n), M_DEVBUF, M_NOWAIT);
if (n == NULL)
return (ENOMEM);
bcopy(&req->ifbr_src, &n->brl_src, sizeof(struct ether_addr));
diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c
index b9da352cf60..06712b5b49c 100644
--- a/sys/net/if_ethersubr.c
+++ b/sys/net/if_ethersubr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ethersubr.c,v 1.110 2007/06/06 10:04:36 henning Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.111 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
@@ -1052,7 +1052,7 @@ ether_addmulti(ifr, ac)
* New address or range; malloc a new multicast record
* and link it into the interface's multicast list.
*/
- enm = (struct ether_multi *)malloc(sizeof(*enm), M_IFMADDR, M_NOWAIT);
+ enm = malloc(sizeof(*enm), M_IFMADDR, M_NOWAIT);
if (enm == NULL) {
splx(s);
return (ENOBUFS);
diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c
index cf73950da1e..f6a772ece8f 100644
--- a/sys/net/if_faith.c
+++ b/sys/net/if_faith.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_faith.c,v 1.22 2006/03/25 22:41:47 djm Exp $ */
+/* $OpenBSD: if_faith.c,v 1.23 2007/09/15 16:43:51 henning Exp $ */
/*
* Copyright (c) 1982, 1986, 1993
* The Regents of the University of California. All rights reserved.
@@ -95,10 +95,9 @@ faith_clone_create(ifc, unit)
{
struct ifnet *ifp;
- ifp = malloc(sizeof(*ifp), M_DEVBUF, M_NOWAIT);
+ ifp = malloc(sizeof(*ifp), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!ifp)
return (ENOMEM);
- bzero(ifp, sizeof(*ifp));
snprintf(ifp->if_xname, sizeof ifp->if_xname, "%s%d", ifc->ifc_name,
unit);
ifp->if_mtu = FAITHMTU;
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index 3cab3a6badf..56a377123dd 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gif.c,v 1.45 2007/05/26 17:13:30 jason Exp $ */
+/* $OpenBSD: if_gif.c,v 1.46 2007/09/15 16:43:51 henning Exp $ */
/* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */
/*
@@ -92,10 +92,9 @@ gif_clone_create(ifc, unit)
struct gif_softc *sc;
int s;
- sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
return (ENOMEM);
- bzero(sc, sizeof(*sc));
snprintf(sc->gif_if.if_xname, sizeof sc->gif_if.if_xname,
"%s%d", ifc->ifc_name, unit);
@@ -485,13 +484,13 @@ gif_ioctl(ifp, cmd, data)
if (sc->gif_psrc)
free((caddr_t)sc->gif_psrc, M_IFADDR);
- sa = (struct sockaddr *)malloc(src->sa_len, M_IFADDR, M_WAITOK);
+ sa = malloc(src->sa_len, M_IFADDR, M_WAITOK);
bcopy((caddr_t)src, (caddr_t)sa, src->sa_len);
sc->gif_psrc = sa;
if (sc->gif_pdst)
free((caddr_t)sc->gif_pdst, M_IFADDR);
- sa = (struct sockaddr *)malloc(dst->sa_len, M_IFADDR, M_WAITOK);
+ sa = malloc(dst->sa_len, M_IFADDR, M_WAITOK);
bcopy((caddr_t)dst, (caddr_t)sa, dst->sa_len);
sc->gif_pdst = sa;
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index 67b4463b2da..3e17572f67a 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_gre.c,v 1.41 2006/05/28 04:30:16 claudio Exp $ */
+/* $OpenBSD: if_gre.c,v 1.42 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */
/*
@@ -132,10 +132,9 @@ gre_clone_create(struct if_clone *ifc, int unit)
struct gre_softc *sc;
int s;
- sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
return (ENOMEM);
- bzero(sc, sizeof(*sc));
snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, "%s%d",
ifc->ifc_name, unit);
sc->sc_if.if_softc = sc;
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 3485bc75b2d..eb7169144ad 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_loop.c,v 1.41 2007/06/06 10:04:36 henning Exp $ */
+/* $OpenBSD: if_loop.c,v 1.42 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */
/*
@@ -180,10 +180,9 @@ loop_clone_create(ifc, unit)
{
struct ifnet *ifp;
- MALLOC(ifp, struct ifnet *, sizeof(*ifp), M_DEVBUF, M_NOWAIT);
+ ifp = malloc(sizeof(*ifp), M_DEVBUF, M_NOWAIT|M_ZERO);
if (ifp == NULL)
return (ENOMEM);
- bzero(ifp, sizeof(struct ifnet));
snprintf(ifp->if_xname, sizeof ifp->if_xname, "lo%d", unit);
ifp->if_softc = NULL;
diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c
index 0154dfb2807..6edc36e3512 100644
--- a/sys/net/if_pfsync.c
+++ b/sys/net/if_pfsync.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pfsync.c,v 1.85 2007/09/03 06:15:06 joel Exp $ */
+/* $OpenBSD: if_pfsync.c,v 1.86 2007/09/15 16:43:51 henning Exp $ */
/*
* Copyright (c) 2002 Michael Shalayeff
@@ -125,9 +125,9 @@ pfsync_clone_create(struct if_clone *ifc, int unit)
return (EINVAL);
pfsync_sync_ok = 1;
- if ((pfsyncif = malloc(sizeof(*pfsyncif), M_DEVBUF, M_NOWAIT)) == NULL)
+ if ((pfsyncif = malloc(sizeof(*pfsyncif), M_DEVBUF,
+ M_NOWAIT|M_ZERO)) == NULL)
return (ENOMEM);
- bzero(pfsyncif, sizeof(*pfsyncif));
pfsyncif->sc_mbuf = NULL;
pfsyncif->sc_mbuf_net = NULL;
pfsyncif->sc_mbuf_tdb = NULL;
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index e73a3a916ec..1037cd3ad7e 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_ppp.c,v 1.49 2007/05/26 17:13:31 jason Exp $ */
+/* $OpenBSD: if_ppp.c,v 1.50 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */
/*
@@ -233,10 +233,9 @@ ppp_clone_create(ifc, unit)
struct ppp_softc *sc;
int s;
- sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
return (ENOMEM);
- bzero(sc, sizeof(*sc));
sc->sc_unit = unit;
snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, "%s%d",
@@ -314,8 +313,7 @@ pppalloc(pid)
sc->sc_relinq = NULL;
bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats));
#ifdef VJC
- MALLOC(sc->sc_comp, struct slcompress *, sizeof(struct slcompress),
- M_DEVBUF, M_NOWAIT);
+ sc->sc_comp = malloc(sizeof(struct slcompress), M_DEVBUF, M_NOWAIT);
if (sc->sc_comp)
sl_compress_init(sc->sc_comp);
#endif
@@ -380,19 +378,19 @@ pppdealloc(sc)
#endif /* PPP_COMPRESS */
#if NBPFILTER > 0
if (sc->sc_pass_filt.bf_insns != 0) {
- FREE(sc->sc_pass_filt.bf_insns, M_DEVBUF);
+ free(sc->sc_pass_filt.bf_insns, M_DEVBUF);
sc->sc_pass_filt.bf_insns = 0;
sc->sc_pass_filt.bf_len = 0;
}
if (sc->sc_active_filt.bf_insns != 0) {
- FREE(sc->sc_active_filt.bf_insns, M_DEVBUF);
+ free(sc->sc_active_filt.bf_insns, M_DEVBUF);
sc->sc_active_filt.bf_insns = 0;
sc->sc_active_filt.bf_len = 0;
}
#endif
#ifdef VJC
if (sc->sc_comp != 0) {
- FREE(sc->sc_comp, M_DEVBUF);
+ free(sc->sc_comp, M_DEVBUF);
sc->sc_comp = 0;
}
#endif
@@ -583,14 +581,14 @@ pppioctl(sc, cmd, data, flag, p)
return EINVAL;
newcodelen = nbp->bf_len * sizeof(struct bpf_insn);
if (newcodelen != 0) {
- MALLOC(newcode, struct bpf_insn *, newcodelen, M_DEVBUF, M_WAITOK);
+ newcode = malloc(newcodelen, M_DEVBUF, M_WAITOK);
if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode,
newcodelen)) != 0) {
- FREE(newcode, M_DEVBUF);
+ free(newcode, M_DEVBUF);
return error;
}
if (!bpf_validate(newcode, nbp->bf_len)) {
- FREE(newcode, M_DEVBUF);
+ free(newcode, M_DEVBUF);
return EINVAL;
}
} else
@@ -602,7 +600,7 @@ pppioctl(sc, cmd, data, flag, p)
bp->bf_insns = newcode;
splx(s);
if (oldcode != 0)
- FREE(oldcode, M_DEVBUF);
+ free(oldcode, M_DEVBUF);
break;
#endif
diff --git a/sys/net/if_pppoe.c b/sys/net/if_pppoe.c
index 4ea94bd6646..4686e8dd6bf 100644
--- a/sys/net/if_pppoe.c
+++ b/sys/net/if_pppoe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_pppoe.c,v 1.12 2007/05/28 06:31:01 mcbride Exp $ */
+/* $OpenBSD: if_pppoe.c,v 1.13 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: if_pppoe.c,v 1.51 2003/11/28 08:56:48 keihan Exp $ */
/*
@@ -225,10 +225,9 @@ pppoe_clone_create(struct if_clone *ifc, int unit)
struct pppoe_softc *sc;
int s;
- MALLOC(sc, struct pppoe_softc *, sizeof(*sc), M_DEVBUF, M_WAITOK);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
if (sc == NULL)
return (ENOMEM);
- bzero(sc, sizeof(struct pppoe_softc));
sc->sc_unique = arc4random();
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index d8ca585064a..8fd80ad9414 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sl.c,v 1.32 2006/03/25 22:41:47 djm Exp $ */
+/* $OpenBSD: if_sl.c,v 1.33 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: if_sl.c,v 1.39.4.1 1996/06/02 16:26:31 thorpej Exp $ */
/*
@@ -206,10 +206,9 @@ sl_clone_create(ifc, unit)
struct sl_softc *sc;
int s;
- sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT);
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!sc)
return (ENOMEM);
- bzero(sc, sizeof(*sc));
sc->sc_unit = unit; /* XXX */
snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, "%s%d",
diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c
index cce73a9341a..6dbba168e12 100644
--- a/sys/net/if_trunk.c
+++ b/sys/net/if_trunk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_trunk.c,v 1.35 2007/09/07 11:00:47 reyk Exp $ */
+/* $OpenBSD: if_trunk.c,v 1.36 2007/09/15 16:43:51 henning Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org>
@@ -752,8 +752,7 @@ trunk_ether_addmulti(struct trunk_softc *tr, struct ifreq *ifr)
if ((error = ether_addmulti(ifr, &tr->tr_ac)) != ENETRESET)
return (error);
- if ((mc = (struct trunk_mc *)malloc(sizeof(struct trunk_mc),
- M_DEVBUF, M_NOWAIT)) == NULL) {
+ if ((mc = malloc(sizeof(*mc), M_DEVBUF, M_NOWAIT)) == NULL) {
error = ENOMEM;
goto failed;
}
@@ -1318,8 +1317,7 @@ trunk_lb_attach(struct trunk_softc *tr)
{
struct trunk_lb *lb;
- if ((lb = (struct trunk_lb *)malloc(sizeof(struct trunk_lb),
- M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
+ if ((lb = malloc(sizeof(*lb), M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
return (ENOMEM);
tr->tr_detach = trunk_lb_detach;
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index b37393e14d5..7581b552119 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_tun.c,v 1.89 2007/06/06 10:04:36 henning Exp $ */
+/* $OpenBSD: if_tun.c,v 1.90 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */
/*
@@ -166,10 +166,9 @@ tun_create(struct if_clone *ifc, int unit, int flags)
u_int32_t macaddr_rnd;
int s;
- tp = malloc(sizeof(*tp), M_DEVBUF, M_NOWAIT);
+ tp = malloc(sizeof(*tp), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!tp)
return (ENOMEM);
- bzero(tp, sizeof(*tp));
tp->tun_unit = unit;
tp->tun_flags = TUN_INITED|TUN_STAYUP;
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c
index 1ced14fa274..cc6a447440c 100644
--- a/sys/net/if_vlan.c
+++ b/sys/net/if_vlan.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_vlan.c,v 1.70 2007/06/06 14:05:58 henning Exp $ */
+/* $OpenBSD: if_vlan.c,v 1.71 2007/09/15 16:43:51 henning Exp $ */
/*
* Copyright 1998 Massachusetts Institute of Technology
@@ -118,10 +118,9 @@ vlan_clone_create(struct if_clone *ifc, int unit)
struct ifvlan *ifv;
struct ifnet *ifp;
- ifv = malloc(sizeof(*ifv), M_DEVBUF, M_NOWAIT);
+ ifv = malloc(sizeof(*ifv), M_DEVBUF, M_NOWAIT|M_ZERO);
if (!ifv)
return (ENOMEM);
- bzero(ifv, sizeof(*ifv));
LIST_INIT(&ifv->vlan_mc_listhead);
ifp = &ifv->ifv_if;
@@ -678,8 +677,7 @@ vlan_ether_addmulti(struct ifvlan *ifv, struct ifreq *ifr)
* about it. Also, remember this multicast address so that
* we can delete them on unconfigure.
*/
- MALLOC(mc, struct vlan_mc_entry *, sizeof(struct vlan_mc_entry),
- M_DEVBUF, M_NOWAIT);
+ mc = malloc(sizeof(*mc), M_DEVBUF, M_NOWAIT);
if (mc == NULL) {
error = ENOMEM;
goto alloc_failed;
@@ -702,7 +700,7 @@ vlan_ether_addmulti(struct ifvlan *ifv, struct ifreq *ifr)
ioctl_failed:
LIST_REMOVE(mc, mc_entries);
- FREE(mc, M_DEVBUF);
+ free(mc, M_DEVBUF);
alloc_failed:
(void)ether_delmulti(ifr, (struct arpcom *)&ifv->ifv_ac);
@@ -745,7 +743,7 @@ vlan_ether_delmulti(struct ifvlan *ifv, struct ifreq *ifr)
if (error == 0) {
/* And forget about this address. */
LIST_REMOVE(mc, mc_entries);
- FREE(mc, M_DEVBUF);
+ free(mc, M_DEVBUF);
} else
(void)ether_addmulti(ifr, (struct arpcom *)&ifv->ifv_ac);
return (error);
@@ -774,6 +772,6 @@ vlan_ether_purgemulti(struct ifvlan *ifv)
memcpy(&ifr->ifr_addr, &mc->mc_addr, mc->mc_addr.ss_len);
(void)(*ifp->if_ioctl)(ifp, SIOCDELMULTI, (caddr_t)ifr);
LIST_REMOVE(mc, mc_entries);
- FREE(mc, M_DEVBUF);
+ free(mc, M_DEVBUF);
}
}
diff --git a/sys/net/pf_if.c b/sys/net/pf_if.c
index 35b932eb43e..fe243705df1 100644
--- a/sys/net/pf_if.c
+++ b/sys/net/pf_if.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_if.c,v 1.48 2007/09/01 18:49:27 henning Exp $ */
+/* $OpenBSD: pf_if.c,v 1.49 2007/09/15 16:43:51 henning Exp $ */
/*
* Copyright 2005 Henning Brauer <henning@openbsd.org>
@@ -111,10 +111,9 @@ pfi_kif_get(const char *kif_name)
return (kif);
/* create new one */
- if ((kif = malloc(sizeof(*kif), PFI_MTYPE, M_DONTWAIT)) == NULL)
+ if ((kif = malloc(sizeof(*kif), PFI_MTYPE, M_DONTWAIT|M_ZERO)) == NULL)
return (NULL);
- bzero(kif, sizeof(*kif));
strlcpy(kif->pfik_name, kif_name, sizeof(kif->pfik_name));
kif->pfik_tzero = time_second;
TAILQ_INIT(&kif->pfik_dynaddrs);
diff --git a/sys/net/pf_ioctl.c b/sys/net/pf_ioctl.c
index 01fba691d99..dd1a9744614 100644
--- a/sys/net/pf_ioctl.c
+++ b/sys/net/pf_ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pf_ioctl.c,v 1.184 2007/09/01 15:14:44 martin Exp $ */
+/* $OpenBSD: pf_ioctl.c,v 1.185 2007/09/15 16:43:51 henning Exp $ */
/*
* Copyright (c) 2001 Daniel Hartmeier
@@ -379,11 +379,9 @@ tagname2tag(struct pf_tags *head, char *tagname)
return (0);
/* allocate and fill new struct pf_tagname */
- tag = (struct pf_tagname *)malloc(sizeof(struct pf_tagname),
- M_TEMP, M_NOWAIT);
+ tag = malloc(sizeof(*tag), M_TEMP, M_NOWAIT|M_ZERO);
if (tag == NULL)
return (0);
- bzero(tag, sizeof(struct pf_tagname));
strlcpy(tag->name, tagname, sizeof(tag->name));
tag->tag = new_tagid;
tag->ref++;
@@ -2547,10 +2545,8 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
error = ENODEV;
goto fail;
}
- ioe = (struct pfioc_trans_e *)malloc(sizeof(*ioe),
- M_TEMP, M_WAITOK);
- table = (struct pfr_table *)malloc(sizeof(*table),
- M_TEMP, M_WAITOK);
+ ioe = malloc(sizeof(*ioe), M_TEMP, M_WAITOK);
+ table = malloc(sizeof(*table), M_TEMP, M_WAITOK);
for (i = 0; i < io->size; i++) {
if (copyin(io->array+i, ioe, sizeof(*ioe))) {
free(table, M_TEMP);
@@ -2616,10 +2612,8 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
error = ENODEV;
goto fail;
}
- ioe = (struct pfioc_trans_e *)malloc(sizeof(*ioe),
- M_TEMP, M_WAITOK);
- table = (struct pfr_table *)malloc(sizeof(*table),
- M_TEMP, M_WAITOK);
+ ioe = malloc(sizeof(*ioe), M_TEMP, M_WAITOK);
+ table = malloc(sizeof(*table), M_TEMP, M_WAITOK);
for (i = 0; i < io->size; i++) {
if (copyin(io->array+i, ioe, sizeof(*ioe))) {
free(table, M_TEMP);
@@ -2680,10 +2674,8 @@ pfioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p)
error = ENODEV;
goto fail;
}
- ioe = (struct pfioc_trans_e *)malloc(sizeof(*ioe),
- M_TEMP, M_WAITOK);
- table = (struct pfr_table *)malloc(sizeof(*table),
- M_TEMP, M_WAITOK);
+ ioe = malloc(sizeof(*ioe), M_TEMP, M_WAITOK);
+ table = malloc(sizeof(*table), M_TEMP, M_WAITOK);
/* first makes sure everything will succeed */
for (i = 0; i < io->size; i++) {
if (copyin(io->array+i, ioe, sizeof(*ioe))) {
diff --git a/sys/net/ppp-deflate.c b/sys/net/ppp-deflate.c
index 927e572e108..c489b6c2b20 100644
--- a/sys/net/ppp-deflate.c
+++ b/sys/net/ppp-deflate.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ppp-deflate.c,v 1.7 2002/09/13 00:12:07 deraadt Exp $ */
+/* $OpenBSD: ppp-deflate.c,v 1.8 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: ppp-deflate.c,v 1.1 1996/03/15 02:28:09 paulus Exp $ */
/*
@@ -131,7 +131,7 @@ zalloc(notused, items, size)
{
void *ptr;
- MALLOC(ptr, void *, items * size, M_DEVBUF, M_NOWAIT);
+ ptr = malloc(items * size, M_DEVBUF, M_NOWAIT);
return ptr;
}
@@ -141,7 +141,7 @@ zfree(notused, ptr, nbytes)
void *ptr;
u_int nbytes;
{
- FREE(ptr, M_DEVBUF);
+ free(ptr, M_DEVBUF);
}
/*
@@ -165,8 +165,7 @@ z_comp_alloc(options, opt_len)
if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
return NULL;
- MALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
- M_DEVBUF, M_NOWAIT);
+ state = malloc(sizeof(*state), M_DEVBUF, M_NOWAIT);
if (state == NULL)
return NULL;
@@ -175,7 +174,7 @@ z_comp_alloc(options, opt_len)
state->strm.zfree = zfree;
if (deflateInit2(&state->strm, Z_DEFAULT_COMPRESSION, DEFLATE_METHOD_VAL,
-w_size, 8, Z_DEFAULT_STRATEGY, DEFLATE_OVHD+2) != Z_OK) {
- FREE(state, M_DEVBUF);
+ free(state, M_DEVBUF);
return NULL;
}
@@ -191,7 +190,7 @@ z_comp_free(arg)
struct deflate_state *state = (struct deflate_state *) arg;
deflateEnd(&state->strm);
- FREE(state, M_DEVBUF);
+ free(state, M_DEVBUF);
}
static int
@@ -398,8 +397,7 @@ z_decomp_alloc(options, opt_len)
if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
return NULL;
- MALLOC(state, struct deflate_state *, sizeof(struct deflate_state),
- M_DEVBUF, M_NOWAIT);
+ state = malloc(sizeof(*state), M_DEVBUF, M_NOWAIT);
if (state == NULL)
return NULL;
@@ -407,7 +405,7 @@ z_decomp_alloc(options, opt_len)
state->strm.zalloc = zalloc;
state->strm.zfree = zfree;
if (inflateInit2(&state->strm, -w_size) != Z_OK) {
- FREE(state, M_DEVBUF);
+ free(state, M_DEVBUF);
return NULL;
}
@@ -423,7 +421,7 @@ z_decomp_free(arg)
struct deflate_state *state = (struct deflate_state *) arg;
inflateEnd(&state->strm);
- FREE(state, M_DEVBUF);
+ free(state, M_DEVBUF);
}
static int
diff --git a/sys/net/route.c b/sys/net/route.c
index 0005e2c0b74..6595aeb1701 100644
--- a/sys/net/route.c
+++ b/sys/net/route.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: route.c,v 1.84 2007/06/14 18:31:49 reyk Exp $ */
+/* $OpenBSD: route.c,v 1.85 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: route.c,v 1.14 1996/02/13 22:00:46 christos Exp $ */
/*
@@ -175,9 +175,8 @@ rtable_init(struct radix_node_head ***table)
struct domain *dom;
if ((p = malloc(sizeof(void *) * (rtafidx_max + 1), M_RTABLE,
- M_NOWAIT)) == NULL)
+ M_NOWAIT|M_ZERO)) == NULL)
return (-1);
- bzero(p, sizeof(void *) * (rtafidx_max + 1));
/* 2nd pass: attach */
for (dom = domains; dom != NULL; dom = dom->dom_next)
@@ -221,9 +220,8 @@ rtable_add(u_int id) /* must be called at splsoftnet */
if (id == 0 || id > rtbl_id_max) {
size_t newlen = sizeof(void *) * (id+1);
- if ((p = malloc(newlen, M_RTABLE, M_NOWAIT)) == NULL)
+ if ((p = malloc(newlen, M_RTABLE, M_NOWAIT|M_ZERO)) == NULL)
return (-1);
- bzero(p, newlen);
if (id > 0) {
bcopy(rt_tables, p, sizeof(void *) * (rtbl_id_max+1));
free(rt_tables, M_RTABLE);
@@ -1315,11 +1313,9 @@ rtlabel_name2id(char *name)
if (new_id > LABELID_MAX)
return (0);
- label = (struct rt_label *)malloc(sizeof(struct rt_label),
- M_TEMP, M_NOWAIT);
+ label = malloc(sizeof(*label), M_TEMP, M_NOWAIT|M_ZERO);
if (label == NULL)
return (0);
- bzero(label, sizeof(struct rt_label));
strlcpy(label->rtl_name, name, sizeof(label->rtl_name));
label->rtl_id = new_id;
label->rtl_ref++;
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 76f246ee9d0..6ff81919676 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rtsock.c,v 1.67 2007/09/09 12:01:58 claudio Exp $ */
+/* $OpenBSD: rtsock.c,v 1.68 2007/09/15 16:43:51 henning Exp $ */
/* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */
/*
@@ -114,9 +114,8 @@ route_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam,
int s;
if (req == PRU_ATTACH) {
- MALLOC(rp, struct rawcb *, sizeof(*rp), M_PCB, M_WAITOK);
+ rp = malloc(sizeof(*rp), M_PCB, M_WAITOK|M_ZERO);
so->so_pcb = rp;
- bzero(so->so_pcb, sizeof(*rp));
}
if (req == PRU_DETACH && rp) {
int af = rp->rcb_proto.sp_protocol;