summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorGilles Chehade <gilles@cvs.openbsd.org>2007-09-08 17:59:24 +0000
committerGilles Chehade <gilles@cvs.openbsd.org>2007-09-08 17:59:24 +0000
commita02306beb42cb99a63ea9f051434b6c4f181d4be (patch)
tree83c68ac4ff05849527d4977549449ec1fe40af2d /sys/dev
parent04b01bd35eb823788ab7bd003fb857a71979144b (diff)
more M_ZERO changes
ok pyr@ and krw@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ccd.c17
-rw-r--r--sys/dev/ksyms.c5
-rw-r--r--sys/dev/midisyn.c5
-rw-r--r--sys/dev/ramdisk.c5
-rw-r--r--sys/dev/softraid.c39
-rw-r--r--sys/dev/vnd.c5
6 files changed, 27 insertions, 49 deletions
diff --git a/sys/dev/ccd.c b/sys/dev/ccd.c
index 142f6149a62..413a406f8c6 100644
--- a/sys/dev/ccd.c
+++ b/sys/dev/ccd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ccd.c,v 1.79 2007/09/01 15:28:39 thib Exp $ */
+/* $OpenBSD: ccd.c,v 1.80 2007/09/08 17:59:23 gilles Exp $ */
/* $NetBSD: ccd.c,v 1.33 1996/05/05 04:21:14 thorpej Exp $ */
/*-
@@ -239,9 +239,9 @@ ccdattach(int num)
}
ccd_softc = (struct ccd_softc *)malloc(num * sizeof(struct ccd_softc),
- M_DEVBUF, M_NOWAIT);
+ M_DEVBUF, M_NOWAIT|M_ZERO);
ccddevs = (struct ccddevice *)malloc(num * sizeof(struct ccddevice),
- M_DEVBUF, M_NOWAIT);
+ M_DEVBUF, M_NOWAIT|M_ZERO);
if ((ccd_softc == NULL) || (ccddevs == NULL)) {
printf("WARNING: no memory for concatenated disks\n");
if (ccd_softc != NULL)
@@ -254,8 +254,6 @@ ccdattach(int num)
rw_init(&ccd_softc[i].sc_rwlock, "ccdlock");
}
numccd = num;
- bzero(ccd_softc, num * sizeof(struct ccd_softc));
- bzero(ccddevs, num * sizeof(struct ccddevice));
pool_init(&ccdbufpl, sizeof(struct ccdbuf), 0, 0, 0, "ccdbufpl", NULL);
pool_setlowat(&ccdbufpl, 16);
@@ -292,8 +290,7 @@ ccdinit(struct ccddevice *ccd, char **cpaths, struct proc *p)
/* Allocate space for the component info. */
cs->sc_cinfo = malloc(cs->sc_nccdisks * sizeof(struct ccdcinfo),
- M_DEVBUF, M_WAITOK);
- bzero(cs->sc_cinfo, cs->sc_nccdisks * sizeof(struct ccdcinfo));
+ M_DEVBUF, M_WAITOK|M_ZERO);
/*
* Verify that each component piece exists and record
@@ -479,8 +476,7 @@ ccdinterleave(struct ccd_softc *cs)
* Chances are this is too big, but we don't care.
*/
size = (cs->sc_nccdisks + 1) * sizeof(struct ccdiinfo);
- cs->sc_itable = (struct ccdiinfo *)malloc(size, M_DEVBUF, M_WAITOK);
- bzero((caddr_t)cs->sc_itable, size);
+ cs->sc_itable = (struct ccdiinfo *)malloc(size, M_DEVBUF, M_WAITOK|M_ZERO);
/*
* Trivial case: no interleave (actually interleave of disk size).
@@ -728,8 +724,7 @@ ccdstart(struct ccd_softc *cs, struct buf *bp)
* Allocate component buffers
*/
cbpp = malloc(2 * cs->sc_nccdisks * sizeof(struct ccdbuf *), M_DEVBUF,
- M_WAITOK);
- bzero(cbpp, 2 * cs->sc_nccdisks * sizeof(struct ccdbuf *));
+ M_WAITOK|M_ZERO);
addr = bp->b_data;
for (bcount = bp->b_bcount; bcount > 0; bcount -= rcount) {
rcount = ccdbuffer(cs, bp, bn, addr, bcount, cbpp);
diff --git a/sys/dev/ksyms.c b/sys/dev/ksyms.c
index f3c5439e8a1..8f80509b5bd 100644
--- a/sys/dev/ksyms.c
+++ b/sys/dev/ksyms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ksyms.c,v 1.17 2006/07/12 18:09:24 martin Exp $ */
+/* $OpenBSD: ksyms.c,v 1.18 2007/09/08 17:59:23 gilles Exp $ */
/*
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2001 Artur Grabowski <art@openbsd.org>
@@ -132,12 +132,11 @@ ksymsattach(num)
struct exec *k1;
ksym_head_size = __LDPGSZ;
- ksym_head = malloc(ksym_head_size, M_DEVBUF, M_NOWAIT);
+ ksym_head = malloc(ksym_head_size, M_DEVBUF, M_NOWAIT|M_ZERO);
if (ksym_head == NULL) {
printf("failed to allocate memory for /dev/ksyms\n");
return;
}
- bzero(ksym_head, ksym_head_size);
k1 = (struct exec *)ksym_head;
diff --git a/sys/dev/midisyn.c b/sys/dev/midisyn.c
index 41cfc9198b8..20916bf9f8d 100644
--- a/sys/dev/midisyn.c
+++ b/sys/dev/midisyn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: midisyn.c,v 1.6 2006/04/07 22:41:32 jsg Exp $ */
+/* $OpenBSD: midisyn.c,v 1.7 2007/09/08 17:59:23 gilles Exp $ */
/* $NetBSD: midisyn.c,v 1.5 1998/11/25 22:17:07 augustss Exp $ */
/*
@@ -180,8 +180,7 @@ midisyn_attach(sc, ms)
{
if (ms->flags & MS_DOALLOC) {
ms->voices = malloc(ms->nvoice * sizeof (struct voice),
- M_DEVBUF, M_WAITOK);
- memset(ms->voices, 0, ms->nvoice * sizeof (struct voice));
+ M_DEVBUF, M_WAITOK|M_ZERO);
ms->seqno = 1;
if (ms->mets->allocv == 0)
ms->mets->allocv = &midisyn_allocvoice;
diff --git a/sys/dev/ramdisk.c b/sys/dev/ramdisk.c
index dc1bf70499c..18685fdd91f 100644
--- a/sys/dev/ramdisk.c
+++ b/sys/dev/ramdisk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ramdisk.c,v 1.37 2007/06/20 18:15:46 deraadt Exp $ */
+/* $OpenBSD: ramdisk.c,v 1.38 2007/09/08 17:59:23 gilles Exp $ */
/* $NetBSD: ramdisk.c,v 1.8 1996/04/12 08:30:09 leo Exp $ */
/*
@@ -147,8 +147,7 @@ rdattach(n)
/* Attach as if by autoconfig. */
for (i = 0; i < n; i++) {
- sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK);
- bzero((caddr_t)sc, sizeof(*sc));
+ sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
if (snprintf(sc->sc_dev.dv_xname, sizeof(sc->sc_dev.dv_xname),
"rd%d", i) >= sizeof(sc->sc_dev.dv_xname)) {
printf("rdattach: device name too long\n");
diff --git a/sys/dev/softraid.c b/sys/dev/softraid.c
index 4f16fcaf6e3..87d9f28fad6 100644
--- a/sys/dev/softraid.c
+++ b/sys/dev/softraid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: softraid.c,v 1.82 2007/06/24 05:34:35 dlg Exp $ */
+/* $OpenBSD: softraid.c,v 1.83 2007/09/08 17:59:23 gilles Exp $ */
/*
* Copyright (c) 2007 Marco Peereboom <marco@peereboom.us>
*
@@ -248,9 +248,7 @@ sr_alloc_ccb(struct sr_discipline *sd)
return (1);
sd->sd_ccb = malloc(sizeof(struct sr_ccb) *
- sd->sd_max_wu * sd->sd_max_ccb_per_wu, M_DEVBUF, M_WAITOK);
- memset(sd->sd_ccb, 0, sizeof(struct sr_ccb) *
- sd->sd_max_wu * sd->sd_max_ccb_per_wu);
+ sd->sd_max_wu * sd->sd_max_ccb_per_wu, M_DEVBUF, M_WAITOK|M_ZERO);
TAILQ_INIT(&sd->sd_ccb_freeq);
for (i = 0; i < sd->sd_max_wu * sd->sd_max_ccb_per_wu; i++) {
ccb = &sd->sd_ccb[i];
@@ -342,8 +340,7 @@ sr_alloc_wu(struct sr_discipline *sd)
sd->sd_wu_pending = no_wu;
sd->sd_wu = malloc(sizeof(struct sr_workunit) * no_wu,
- M_DEVBUF, M_WAITOK);
- memset(sd->sd_wu, 0, sizeof(struct sr_workunit) * no_wu);
+ M_DEVBUF, M_WAITOK|M_ZERO);
TAILQ_INIT(&sd->sd_wu_freeq);
TAILQ_INIT(&sd->sd_wu_pendq);
TAILQ_INIT(&sd->sd_wu_defq);
@@ -766,15 +763,13 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
if (bc->bc_dev_list_len > BIOC_CRMAXLEN)
goto unwind;
- dt = malloc(bc->bc_dev_list_len, M_DEVBUF, M_WAITOK);
- bzero(dt, bc->bc_dev_list_len);
+ dt = malloc(bc->bc_dev_list_len, M_DEVBUF, M_WAITOK|M_ZERO);
if (user)
copyin(bc->bc_dev_list, dt, bc->bc_dev_list_len);
else
bcopy(bc->bc_dev_list, dt, bc->bc_dev_list_len);
- sd = malloc(sizeof(struct sr_discipline), M_DEVBUF, M_WAITOK);
- memset(sd, 0, sizeof(struct sr_discipline));
+ sd = malloc(sizeof(struct sr_discipline), M_DEVBUF, M_WAITOK|M_ZERO);
sd->sd_sc = sc;
no_chunk = bc->bc_dev_list_len / sizeof(dev_t);
@@ -784,13 +779,11 @@ sr_ioctl_createraid(struct sr_softc *sc, struct bioc_createraid *bc, int user)
goto unwind;
/* in memory copy of metadata */
- sd->sd_meta = malloc(SR_META_SIZE * 512 , M_DEVBUF, M_WAITOK);
- bzero(sd->sd_meta, SR_META_SIZE * 512);
+ sd->sd_meta = malloc(SR_META_SIZE * 512 , M_DEVBUF, M_WAITOK|M_ZERO);
/* we have a valid list now create an array index */
sd->sd_vol.sv_chunks = malloc(sizeof(struct sr_chunk *) * no_chunk,
- M_DEVBUF, M_WAITOK);
- bzero(sd->sd_vol.sv_chunks, sizeof(struct sr_chunk *) * no_chunk);
+ M_DEVBUF, M_WAITOK|M_ZERO);
/* force the raid volume by clearing metadata region */
if (bc->bc_flags & BIOC_SCFORCE) {
@@ -1028,8 +1021,7 @@ sr_open_chunks(struct sr_softc *sc, struct sr_chunk_head *cl, dev_t *dt,
/* fill out chunk list */
for (i = 0; i < no_chunk; i++) {
- ch_entry = malloc(sizeof(struct sr_chunk), M_DEVBUF, M_WAITOK);
- bzero(ch_entry, sizeof(struct sr_chunk));
+ ch_entry = malloc(sizeof(struct sr_chunk), M_DEVBUF, M_WAITOK|M_ZERO);
/* keep disks in user supplied order */
if (ch_prev)
SLIST_INSERT_AFTER(ch_prev, ch_entry, src_link);
@@ -1112,8 +1104,7 @@ sr_read_meta(struct sr_discipline *sd)
DNPRINTF(SR_D_META, "%s: sr_read_meta\n", DEVNAME(sc));
- m = malloc(sz , M_DEVBUF, M_WAITOK);
- bzero(m, sz);
+ m = malloc(sz , M_DEVBUF, M_WAITOK|M_ZERO);
SLIST_FOREACH(ch_entry, cl, src_link) {
bzero(&b, sizeof(b));
@@ -1794,8 +1785,7 @@ sr_clear_metadata(struct sr_discipline *sd)
DNPRINTF(SR_D_META, "%s: sr_clear_metadata\n", DEVNAME(sc));
- m = malloc(sz , M_DEVBUF, M_WAITOK);
- bzero(m, sz);
+ m = malloc(sz , M_DEVBUF, M_WAITOK|M_ZERO);
SLIST_FOREACH(ch_entry, cl, src_link) {
bzero(&b, sizeof(b));
@@ -2108,11 +2098,9 @@ sr_boot_assembly(struct sr_softc *sc)
sm = (struct sr_metadata *)bp->b_data;
if (!sr_validate_metadata(sc, devr, sm)) {
/* we got one; save it off */
- mle = malloc(sizeof(*mle), M_DEVBUF, M_WAITOK);
- bzero(mle, sizeof(*mle));
+ mle = malloc(sizeof(*mle), M_DEVBUF, M_WAITOK|M_ZERO);
mle->sml_metadata = malloc(sz, M_DEVBUF,
- M_WAITOK);
- bzero(mle->sml_metadata, sz);
+ M_WAITOK|M_ZERO);
bcopy(sm, mle->sml_metadata, sz);
mle->sml_mm = devr;
SLIST_INSERT_HEAD(&mlh, mle, sml_link);
@@ -2913,8 +2901,7 @@ sr_raidc_getcryptop(struct sr_workunit *wu, int encrypt)
DNPRINTF(SR_D_DIS, "%s: sr_raidc_getcryptop wu: %p encrypt: %d\n",
DEVNAME(sd->sd_sc), wu, encrypt);
- uio = malloc(sizeof(*uio), M_DEVBUF, M_WAITOK);
- memset(uio, 0, sizeof(*uio));
+ uio = malloc(sizeof(*uio), M_DEVBUF, M_WAITOK|M_ZERO);
uio->uio_iov = malloc(sizeof(*uio->uio_iov), M_DEVBUF, M_WAITOK);
uio->uio_iovcnt = 1;
uio->uio_iov->iov_base = xs->data;
diff --git a/sys/dev/vnd.c b/sys/dev/vnd.c
index 426c5739393..4373b0eee51 100644
--- a/sys/dev/vnd.c
+++ b/sys/dev/vnd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnd.c,v 1.79 2007/06/20 18:15:46 deraadt Exp $ */
+/* $OpenBSD: vnd.c,v 1.80 2007/09/08 17:59:23 gilles Exp $ */
/* $NetBSD: vnd.c,v 1.26 1996/03/30 23:06:11 christos Exp $ */
/*
@@ -198,12 +198,11 @@ vndattach(int num)
if (num <= 0)
return;
size = num * sizeof(struct vnd_softc);
- mem = malloc(size, M_DEVBUF, M_NOWAIT);
+ mem = malloc(size, M_DEVBUF, M_NOWAIT|M_ZERO);
if (mem == NULL) {
printf("WARNING: no memory for vnode disks\n");
return;
}
- bzero(mem, size);
vnd_softc = (struct vnd_softc *)mem;
for (i = 0; i < num; i++) {
rw_init(&vnd_softc[i].sc_rwlock, "vndlock");