summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2007-09-07 15:00:21 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2007-09-07 15:00:21 +0000
commit85ce33f47337d8ae2200b69c865bad9704a53564 (patch)
tree45c03da13cdd18d57180b1614667ab28a7a26012 /sys
parent27eb8946aec561bdd8abb9e09db43d6f4093d59a (diff)
Use M_ZERO in a few more places to shave bytes from the kernel.
eyeballed and ok dlg@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/i386/esm.c16
-rw-r--r--sys/arch/i386/i386/i686_mem.c5
-rw-r--r--sys/arch/i386/i386/k6_mem.c8
-rw-r--r--sys/arch/i386/i386/machdep.c5
-rw-r--r--sys/arch/i386/i386/mem.c7
-rw-r--r--sys/arch/i386/i386/mpbios.c5
-rw-r--r--sys/arch/i386/i386/via.c12
-rw-r--r--sys/arch/i386/isa/isa_machdep.c5
-rw-r--r--sys/arch/i386/pci/glxsb.c8
-rw-r--r--sys/arch/i386/pci/pci_intr_fixup.c6
-rw-r--r--sys/kern/kern_kthread.c5
-rw-r--r--sys/kern/kern_proc.c6
-rw-r--r--sys/kern/kern_sysctl.c11
-rw-r--r--sys/kern/subr_autoconf.c9
-rw-r--r--sys/kern/subr_disk.c10
-rw-r--r--sys/kern/sys_generic.c5
-rw-r--r--sys/kern/sysv_sem.c20
-rw-r--r--sys/kern/sysv_shm.c17
-rw-r--r--sys/kern/tty.c6
-rw-r--r--sys/kern/tty_nmea.c5
-rw-r--r--sys/kern/tty_pty.c11
-rw-r--r--sys/kern/tty_subr.c12
-rw-r--r--sys/kern/uipc_usrreq.c5
-rw-r--r--sys/kern/vfs_init.c5
-rw-r--r--sys/kern/vfs_subr.c8
-rw-r--r--sys/kern/vfs_syscalls.c5
-rw-r--r--sys/ufs/ffs/ffs_vfsops.c15
-rw-r--r--sys/uvm/uvm_amap.c5
-rw-r--r--sys/uvm/uvm_aobj.c5
-rw-r--r--sys/uvm/uvm_stat.h5
-rw-r--r--sys/uvm/uvm_swap.c15
31 files changed, 104 insertions, 158 deletions
diff --git a/sys/arch/i386/i386/esm.c b/sys/arch/i386/i386/esm.c
index 3e5eec3cf5c..b68a2684272 100644
--- a/sys/arch/i386/i386/esm.c
+++ b/sys/arch/i386/i386/esm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: esm.c,v 1.46 2007/03/22 16:55:31 deraadt Exp $ */
+/* $OpenBSD: esm.c,v 1.47 2007/09/07 15:00:19 art Exp $ */
/*
* Copyright (c) 2005 Jordan Hargrave <jordan@openbsd.org>
@@ -857,11 +857,11 @@ esm_make_sensors(struct esm_softc *sc, struct esm_devmap *devmap,
break;
}
- es = malloc(sizeof(struct esm_sensor), M_DEVBUF, M_NOWAIT);
+ es = malloc(sizeof(struct esm_sensor), M_DEVBUF,
+ M_NOWAIT|M_ZERO);
if (es == NULL)
return;
- memset(es, 0, sizeof(struct esm_sensor));
es->es_dev = devmap->index;
es->es_id = i;
es->es_type = sensor_map[i].type;
@@ -874,12 +874,11 @@ esm_make_sensors(struct esm_softc *sc, struct esm_devmap *devmap,
*/
nsensors = 4;
s = malloc(sizeof(struct ksensor) * nsensors, M_DEVBUF,
- M_NOWAIT);
+ M_NOWAIT|M_ZERO);
if (s == NULL) {
free(es, M_DEVBUF);
return;
}
- memset(s, 0, sizeof(struct ksensor) * nsensors);
for (j = 0; j < nsensors; j++) {
snprintf(s[j].desc, sizeof(s[j].desc), "%s %d",
@@ -893,12 +892,11 @@ esm_make_sensors(struct esm_softc *sc, struct esm_devmap *devmap,
*/
nsensors = 6;
s = malloc(sizeof(struct ksensor) * nsensors, M_DEVBUF,
- M_NOWAIT);
+ M_NOWAIT|M_ZERO);
if (s == NULL) {
free(es, M_DEVBUF);
return;
}
- memset(s, 0, sizeof(struct ksensor) * nsensors);
for (j = 0; j < nsensors; j++) {
snprintf(s[j].desc, sizeof(s[j].desc), "%s %s",
@@ -919,12 +917,12 @@ esm_make_sensors(struct esm_softc *sc, struct esm_devmap *devmap,
default:
nsensors = 1;
- s = malloc(sizeof(struct ksensor), M_DEVBUF, M_NOWAIT);
+ s = malloc(sizeof(struct ksensor), M_DEVBUF,
+ M_NOWAIT|M_ZERO);
if (s == NULL) {
free(es, M_DEVBUF);
return;
}
- memset(s, 0, sizeof(struct ksensor));
strlcpy(s->desc, sensor_map[i].name, sizeof(s->desc));
break;
diff --git a/sys/arch/i386/i386/i686_mem.c b/sys/arch/i386/i386/i686_mem.c
index eae289331ad..0f746bd30e7 100644
--- a/sys/arch/i386/i386/i686_mem.c
+++ b/sys/arch/i386/i386/i686_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i686_mem.c,v 1.9 2006/09/19 11:06:33 jsg Exp $ */
+/* $OpenBSD: i686_mem.c,v 1.10 2007/09/07 15:00:19 art Exp $ */
/*-
* Copyright (c) 1999 Michael Smith <msmith@freebsd.org>
* All rights reserved.
@@ -553,8 +553,7 @@ i686_mrinit(struct mem_range_softc *sc)
}
sc->mr_desc = malloc(nmdesc * sizeof(struct mem_range_desc),
- M_MEMDESC, M_WAITOK);
- bzero(sc->mr_desc, nmdesc * sizeof(struct mem_range_desc));
+ M_MEMDESC, M_WAITOK|M_ZERO);
sc->mr_ndesc = nmdesc;
mrd = sc->mr_desc;
diff --git a/sys/arch/i386/i386/k6_mem.c b/sys/arch/i386/i386/k6_mem.c
index 579dc4bbf1a..30186a11298 100644
--- a/sys/arch/i386/i386/k6_mem.c
+++ b/sys/arch/i386/i386/k6_mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: k6_mem.c,v 1.7 2006/06/10 18:00:48 gwk Exp $ */
+/* $OpenBSD: k6_mem.c,v 1.8 2007/09/07 15:00:19 art Exp $ */
/*-
* Copyright (c) 1999 Brian Fundakowski Feldman
* All rights reserved.
@@ -102,12 +102,10 @@ k6_mrinit(struct mem_range_softc *sc)
sc->mr_cap = 0;
sc->mr_ndesc = 2; /* XXX (BFF) For now, we only have one msr for this */
sc->mr_desc = malloc(sc->mr_ndesc * sizeof(struct mem_range_desc),
- M_MEMDESC, M_NOWAIT);
+ M_MEMDESC, M_NOWAIT|M_ZERO);
if (sc->mr_desc == NULL)
panic("k6_mrinit: malloc returns NULL");
-
- bzero(sc->mr_desc, sc->mr_ndesc * sizeof(struct mem_range_desc));
-
+
reg = rdmsr(UWCCR);
for (d = 0; d < sc->mr_ndesc; d++) {
u_int32_t one = (reg & (0xffffffff << (32 * d))) >> (32 * d);
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 3728429aa77..49962050f41 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.406 2007/09/03 01:09:09 krw Exp $ */
+/* $OpenBSD: machdep.c,v 1.407 2007/09/07 15:00:19 art Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -3669,10 +3669,9 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
mapsize = sizeof(struct i386_bus_dmamap) +
(sizeof(bus_dma_segment_t) * (nsegments - 1));
if ((mapstore = malloc(mapsize, M_DEVBUF,
- (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL)
+ ((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK) | M_ZERO)) == NULL)
return (ENOMEM);
- bzero(mapstore, mapsize);
map = (struct i386_bus_dmamap *)mapstore;
map->_dm_size = size;
map->_dm_segcnt = nsegments;
diff --git a/sys/arch/i386/i386/mem.c b/sys/arch/i386/i386/mem.c
index 88e7a260614..86fb86aa2f4 100644
--- a/sys/arch/i386/i386/mem.c
+++ b/sys/arch/i386/i386/mem.c
@@ -1,5 +1,5 @@
/* $NetBSD: mem.c,v 1.31 1996/05/03 19:42:19 christos Exp $ */
-/* $OpenBSD: mem.c,v 1.33 2007/09/01 15:14:44 martin Exp $ */
+/* $OpenBSD: mem.c,v 1.34 2007/09/07 15:00:19 art Exp $ */
/*
* Copyright (c) 1988 University of Utah.
* Copyright (c) 1982, 1986, 1990, 1993
@@ -183,9 +183,8 @@ mmrw(dev_t dev, struct uio *uio, int flags)
break;
}
if (zeropage == NULL) {
- zeropage = (caddr_t)
- malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
- bzero(zeropage, PAGE_SIZE);
+ zeropage = malloc(PAGE_SIZE, M_TEMP,
+ M_WAITOK|M_ZERO);
}
c = min(iov->iov_len, PAGE_SIZE);
error = uiomove(zeropage, c, uio);
diff --git a/sys/arch/i386/i386/mpbios.c b/sys/arch/i386/i386/mpbios.c
index 5a14e0798a4..43be80fa57a 100644
--- a/sys/arch/i386/i386/mpbios.c
+++ b/sys/arch/i386/i386/mpbios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mpbios.c,v 1.22 2007/04/24 13:00:59 tom Exp $ */
+/* $OpenBSD: mpbios.c,v 1.23 2007/09/07 15:00:19 art Exp $ */
/* $NetBSD: mpbios.c,v 1.2 2002/10/01 12:56:57 fvdl Exp $ */
/*-
@@ -619,8 +619,7 @@ mpbios_scan(struct device *self)
}
mp_busses = malloc(sizeof(struct mp_bus) * mp_nbus,
- M_DEVBUF, M_NOWAIT);
- memset(mp_busses, 0, sizeof(struct mp_bus) * mp_nbus);
+ M_DEVBUF, M_NOWAIT|M_ZERO);
mp_intrs = malloc(sizeof(struct mp_intr_map) * intr_cnt,
M_DEVBUF, M_NOWAIT);
diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c
index 6352f08f20f..fb6324afe7e 100644
--- a/sys/arch/i386/i386/via.c
+++ b/sys/arch/i386/i386/via.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: via.c,v 1.12 2007/08/14 20:10:05 henric Exp $ */
+/* $OpenBSD: via.c,v 1.13 2007/09/07 15:00:19 art Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -107,9 +107,9 @@ viac3_crypto_setup(void)
{
int algs[CRYPTO_ALGORITHM_MAX + 1];
- if ((vc3_sc = malloc(sizeof(*vc3_sc), M_DEVBUF, M_NOWAIT)) == NULL)
+ if ((vc3_sc = malloc(sizeof(*vc3_sc), M_DEVBUF,
+ M_NOWAIT|M_ZERO)) == NULL)
return; /* YYY bitch? */
- bzero(vc3_sc, sizeof(*vc3_sc));
bzero(algs, sizeof(algs));
algs[CRYPTO_AES_CBC] = CRYPTO_ALG_FLAG_SUPPORTED;
@@ -228,14 +228,12 @@ viac3_crypto_newsession(u_int32_t *sidp, struct cryptoini *cri)
case CRYPTO_SHA2_512_HMAC:
axf = &auth_hash_hmac_sha2_512_96;
authcommon:
- MALLOC(swd, struct swcr_data *,
- sizeof(struct swcr_data), M_CRYPTO_DATA,
- M_NOWAIT);
+ swd = malloc(sizeof(struct swcr_data), M_CRYPTO_DATA,
+ M_NOWAIT|M_ZERO);
if (swd == NULL) {
viac3_crypto_freesession(sesn);
return (ENOMEM);
}
- bzero(swd, sizeof(struct swcr_data));
ses->swd = swd;
swd->sw_ictx = malloc(axf->ctxsize, M_CRYPTO_DATA,
diff --git a/sys/arch/i386/isa/isa_machdep.c b/sys/arch/i386/isa/isa_machdep.c
index 75b9874ecb3..c4fa51806e0 100644
--- a/sys/arch/i386/isa/isa_machdep.c
+++ b/sys/arch/i386/isa/isa_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isa_machdep.c,v 1.60 2007/04/28 03:55:40 jsg Exp $ */
+/* $OpenBSD: isa_machdep.c,v 1.61 2007/09/07 15:00:19 art Exp $ */
/* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */
/*-
@@ -710,11 +710,10 @@ _isa_bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments,
* Allocate our cookie.
*/
if ((cookiestore = malloc(cookiesize, M_DEVBUF,
- (flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)) == NULL) {
+ ((flags & BUS_DMA_NOWAIT) ? M_NOWAIT : M_WAITOK)|M_ZERO)) == NULL) {
error = ENOMEM;
goto out;
}
- bzero(cookiestore, cookiesize);
cookie = (struct i386_isa_dma_cookie *)cookiestore;
cookie->id_flags = cookieflags;
map->_dm_cookie = cookie;
diff --git a/sys/arch/i386/pci/glxsb.c b/sys/arch/i386/pci/glxsb.c
index 164090dbf98..4e9a6758cd1 100644
--- a/sys/arch/i386/pci/glxsb.c
+++ b/sys/arch/i386/pci/glxsb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: glxsb.c,v 1.8 2007/08/07 09:48:23 markus Exp $ */
+/* $OpenBSD: glxsb.c,v 1.9 2007/09/07 15:00:19 art Exp $ */
/*
* Copyright (c) 2006 Tom Cosgrove <tom@openbsd.org>
@@ -405,14 +405,12 @@ glxsb_crypto_newsession(uint32_t *sidp, struct cryptoini *cri)
case CRYPTO_SHA2_512_HMAC:
axf = &auth_hash_hmac_sha2_512_96;
authcommon:
- MALLOC(swd, struct swcr_data *,
- sizeof(struct swcr_data), M_CRYPTO_DATA,
- M_NOWAIT);
+ swd = malloc(sizeof(struct swcr_data), M_CRYPTO_DATA,
+ M_NOWAIT|M_ZERO);
if (swd == NULL) {
glxsb_crypto_freesession(sesn);
return (ENOMEM);
}
- bzero(swd, sizeof(struct swcr_data));
ses->ses_swd = swd;
swd->sw_ictx = malloc(axf->ctxsize, M_CRYPTO_DATA,
diff --git a/sys/arch/i386/pci/pci_intr_fixup.c b/sys/arch/i386/pci/pci_intr_fixup.c
index 2efe7042303..9bd05575879 100644
--- a/sys/arch/i386/pci/pci_intr_fixup.c
+++ b/sys/arch/i386/pci/pci_intr_fixup.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_intr_fixup.c,v 1.57 2007/07/07 13:52:42 grange Exp $ */
+/* $OpenBSD: pci_intr_fixup.c,v 1.58 2007/09/07 15:00:19 art Exp $ */
/* $NetBSD: pci_intr_fixup.c,v 1.10 2000/08/10 21:18:27 soda Exp $ */
/*
@@ -306,11 +306,9 @@ pciintr_link_alloc(pci_chipset_tag_t pc, struct pcibios_intr_routing *pir, int p
}
}
- if ((l = malloc(sizeof(*l), M_DEVBUF, M_NOWAIT)) == NULL)
+ if ((l = malloc(sizeof(*l), M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL)
return (NULL);
- memset(l, 0, sizeof(*l));
-
l->link = link;
l->bitmap = pir->linkmap[pin].bitmap;
if (pciintr_icu_tag != NULL) { /* compatible PCI ICU found */
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 8452426fbc7..1eae0eae8b7 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_kthread.c,v 1.27 2007/03/15 10:22:30 art Exp $ */
+/* $OpenBSD: kern_kthread.c,v 1.28 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: kern_kthread.c,v 1.3 1998/12/22 21:21:36 kleink Exp $ */
/*-
@@ -145,10 +145,9 @@ kthread_create_deferred(void (*func)(void *), void *arg)
return;
}
- kq = malloc(sizeof *kq, M_TEMP, M_NOWAIT);
+ kq = malloc(sizeof *kq, M_TEMP, M_NOWAIT|M_ZERO);
if (kq == NULL)
panic("unable to allocate kthread_q");
- bzero(kq, sizeof *kq);
kq->kq_func = func;
kq->kq_arg = arg;
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index ada02192c12..ef16630f108 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_proc.c,v 1.34 2007/08/04 02:43:54 ckuethe Exp $ */
+/* $OpenBSD: kern_proc.c,v 1.35 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */
/*
@@ -124,8 +124,7 @@ uid_find(uid_t uid)
break;
if (uip)
return (uip);
- MALLOC(nuip, struct uidinfo *, sizeof(*nuip), M_PROC, M_WAITOK);
- /* may have slept, have to check again */
+ nuip = malloc(sizeof(*nuip), M_PROC, M_WAITOK|M_ZERO);
LIST_FOREACH(uip, uipp, ui_hash)
if (uip->ui_uid == uid)
break;
@@ -133,7 +132,6 @@ uid_find(uid_t uid)
free(nuip, M_PROC);
return (uip);
}
- bzero(nuip, sizeof(*nuip));
nuip->ui_uid = uid;
LIST_INSERT_HEAD(uipp, nuip, ui_hash);
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index c67a1d753ac..bdc9d6850a2 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sysctl.c,v 1.156 2007/09/01 15:14:44 martin Exp $ */
+/* $OpenBSD: kern_sysctl.c,v 1.157 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */
/*-
@@ -1692,8 +1692,7 @@ sysctl_sysvipc(int *name, u_int namelen, void *where, size_t *sizep)
*sizep = 0;
return (ENOMEM);
}
- buf = malloc(min(tsize, buflen), M_TEMP, M_WAITOK);
- bzero(buf, min(tsize, buflen));
+ buf = malloc(min(tsize, buflen), M_TEMP, M_WAITOK|M_ZERO);
switch (*name) {
#ifdef SYSVMSG
@@ -1791,8 +1790,7 @@ sysctl_sensors(int *name, u_int namelen, void *oldp, size_t *oldlenp,
return (ENOENT);
/* Grab a copy, to clear the kernel pointers */
- usd = malloc(sizeof(*usd), M_TEMP, M_WAITOK);
- bzero(usd, sizeof(*usd));
+ usd = malloc(sizeof(*usd), M_TEMP, M_WAITOK|M_ZERO);
usd->num = ksd->num;
strlcpy(usd->xname, ksd->xname, sizeof(usd->xname));
memcpy(usd->maxnumt, ksd->maxnumt, sizeof(usd->maxnumt));
@@ -1813,8 +1811,7 @@ sysctl_sensors(int *name, u_int namelen, void *oldp, size_t *oldlenp,
return (ENOENT);
/* Grab a copy, to clear the kernel pointers */
- us = malloc(sizeof(*us), M_TEMP, M_WAITOK);
- bzero(us, sizeof(*us));
+ us = malloc(sizeof(*us), M_TEMP, M_WAITOK|M_ZERO);
memcpy(us->desc, ks->desc, sizeof(us->desc));
us->tv = ks->tv;
us->value = ks->value;
diff --git a/sys/kern/subr_autoconf.c b/sys/kern/subr_autoconf.c
index f19835b4275..6b57b196596 100644
--- a/sys/kern/subr_autoconf.c
+++ b/sys/kern/subr_autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_autoconf.c,v 1.52 2007/05/30 05:36:36 deraadt Exp $ */
+/* $OpenBSD: subr_autoconf.c,v 1.53 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: subr_autoconf.c,v 1.21 1996/04/04 06:06:18 cgd Exp $ */
/*
@@ -411,10 +411,10 @@ config_make_softc(struct device *parent, struct cfdata *cf)
panic("config_make_softc");
/* get memory for all device vars */
- dev = (struct device *)malloc(ca->ca_devsize, M_DEVBUF, M_NOWAIT);
+ dev = malloc(ca->ca_devsize, M_DEVBUF, M_NOWAIT|M_ZERO);
if (!dev)
panic("config_make_softc: allocation for device softc failed");
- bzero(dev, ca->ca_devsize);
+
dev->dv_class = cd->cd_class;
dev->dv_cfdata = cf;
dev->dv_flags = DVF_ACTIVE; /* always initially active */
@@ -451,11 +451,10 @@ config_make_softc(struct device *parent, struct cfdata *cf)
while (new <= dev->dv_unit)
new *= 2;
cd->cd_ndevs = new;
- nsp = malloc(new * sizeof(void *), M_DEVBUF, M_NOWAIT);
+ nsp = malloc(new * sizeof(void *), M_DEVBUF, M_NOWAIT|M_ZERO);
if (nsp == 0)
panic("config_make_softc: %sing dev array",
old != 0 ? "expand" : "creat");
- bzero(nsp + old, (new - old) * sizeof(void *));
if (old != 0) {
bcopy(cd->cd_devs, nsp, old * sizeof(void *));
free(cd->cd_devs, M_DEVBUF);
diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c
index 1764f23e0f8..d48b421f546 100644
--- a/sys/kern/subr_disk.c
+++ b/sys/kern/subr_disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_disk.c,v 1.64 2007/08/05 04:26:21 krw Exp $ */
+/* $OpenBSD: subr_disk.c,v 1.65 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: subr_disk.c,v 1.17 1996/03/16 23:17:08 christos Exp $ */
/*
@@ -725,12 +725,11 @@ disk_attach(struct disk *diskp)
* it's not safe to sleep here, since we're probably going to be
* called during autoconfiguration.
*/
- diskp->dk_label = malloc(sizeof(struct disklabel), M_DEVBUF, M_NOWAIT);
+ diskp->dk_label = malloc(sizeof(struct disklabel), M_DEVBUF,
+ M_NOWAIT|M_ZERO);
if (diskp->dk_label == NULL)
panic("disk_attach: can't allocate storage for disklabel");
- bzero(diskp->dk_label, sizeof(struct disklabel));
-
/*
* Set the attached timestamp.
*/
@@ -911,11 +910,10 @@ bufq_default_alloc(void)
{
struct bufq_default *bq;
- bq = malloc(sizeof(*bq), M_DEVBUF, M_NOWAIT);
+ bq = malloc(sizeof(*bq), M_DEVBUF, M_NOWAIT|M_ZERO);
if (bq == NULL)
panic("bufq_default_alloc: no memory");
- memset(bq, 0, sizeof(*bq));
bq->bufq.bufq_free = bufq_default_free;
bq->bufq.bufq_add = bufq_default_add;
bq->bufq.bufq_get = bufq_default_get;
diff --git a/sys/kern/sys_generic.c b/sys/kern/sys_generic.c
index f68f5251a7d..bfcf380a001 100644
--- a/sys/kern/sys_generic.c
+++ b/sys/kern/sys_generic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_generic.c,v 1.57 2007/07/25 23:11:52 art Exp $ */
+/* $OpenBSD: sys_generic.c,v 1.58 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: sys_generic.c,v 1.24 1996/03/29 00:25:32 cgd Exp $ */
/*
@@ -639,8 +639,7 @@ sys_select(struct proc *p, void *v, register_t *retval)
if (nd > sizeof(bits[0])) {
caddr_t mbits;
- mbits = malloc(ni * 6, M_TEMP, M_WAITOK);
- bzero(mbits, ni * 6);
+ mbits = malloc(ni * 6, M_TEMP, M_WAITOK|M_ZERO);
pibits[0] = (fd_set *)&mbits[ni * 0];
pibits[1] = (fd_set *)&mbits[ni * 1];
pibits[2] = (fd_set *)&mbits[ni * 2];
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index c680a97b928..fe14f0731e3 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_sem.c,v 1.33 2006/08/10 17:03:48 millert Exp $ */
+/* $OpenBSD: sysv_sem.c,v 1.34 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */
/*
@@ -72,11 +72,9 @@ seminit(void)
pool_init(&semu_pool, SEMUSZ, 0, 0, 0, "semupl",
&pool_allocator_nointr);
sema = malloc(seminfo.semmni * sizeof(struct semid_ds *),
- M_SEM, M_WAITOK);
- bzero(sema, seminfo.semmni * sizeof(struct semid_ds *));
+ M_SEM, M_WAITOK|M_ZERO);
semseqs = malloc(seminfo.semmni * sizeof(unsigned short),
- M_SEM, M_WAITOK);
- bzero(semseqs, seminfo.semmni * sizeof(unsigned short));
+ M_SEM, M_WAITOK|M_ZERO);
SLIST_INIT(&semu_list);
}
@@ -416,8 +414,7 @@ sys_semget(struct proc *p, void *v, register_t *retval)
}
semaptr_new = pool_get(&sema_pool, PR_WAITOK);
semaptr_new->sem_base = malloc(nsems * sizeof(struct sem),
- M_SEM, M_WAITOK);
- bzero(semaptr_new->sem_base, nsems * sizeof(struct sem));
+ M_SEM, M_WAITOK|M_ZERO);
}
if (key != IPC_PRIVATE) {
@@ -851,16 +848,13 @@ sysctl_sysvsem(int *name, u_int namelen, void *oldp, size_t *oldlenp,
/* Expand semsegs and semseqs arrays */
sema_new = malloc(val * sizeof(struct semid_ds *),
- M_SEM, M_WAITOK);
+ M_SEM, M_WAITOK|M_ZERO);
bcopy(sema, sema_new,
seminfo.semmni * sizeof(struct semid_ds *));
- bzero(sema_new + seminfo.semmni,
- (val - seminfo.semmni) * sizeof(struct semid_ds *));
- newseqs = malloc(val * sizeof(unsigned short), M_SEM, M_WAITOK);
+ newseqs = malloc(val * sizeof(unsigned short), M_SEM,
+ M_WAITOK|M_ZERO);
bcopy(semseqs, newseqs,
seminfo.semmni * sizeof(unsigned short));
- bzero(newseqs + seminfo.semmni,
- (val - seminfo.semmni) * sizeof(unsigned short));
free(sema, M_SEM);
free(semseqs, M_SEM);
sema = sema_new;
diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c
index 4475cc91d9e..538f530efaf 100644
--- a/sys/kern/sysv_shm.c
+++ b/sys/kern/sysv_shm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_shm.c,v 1.47 2007/05/29 10:44:28 sturm Exp $ */
+/* $OpenBSD: sysv_shm.c,v 1.48 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: sysv_shm.c,v 1.50 1998/10/21 22:24:29 tron Exp $ */
/*
@@ -535,11 +535,9 @@ shminit(void)
sizeof(struct shm_handle), 0, 0, 0, "shmpl",
&pool_allocator_nointr);
shmsegs = malloc(shminfo.shmmni * sizeof(struct shmid_ds *),
- M_SHM, M_WAITOK);
- bzero(shmsegs, shminfo.shmmni * sizeof(struct shmid_ds *));
+ M_SHM, M_WAITOK|M_ZERO);
shmseqs = malloc(shminfo.shmmni * sizeof(unsigned short),
- M_SHM, M_WAITOK);
- bzero(shmseqs, shminfo.shmmni * sizeof(unsigned short));
+ M_SHM, M_WAITOK|M_ZERO);
shminfo.shmmax *= PAGE_SIZE; /* actually in pages */
shm_last_free = 0;
@@ -601,18 +599,15 @@ sysctl_sysvshm(int *name, u_int namelen, void *oldp, size_t *oldlenp,
/* Expand shmsegs and shmseqs arrays */
newsegs = malloc(val * sizeof(struct shmid_ds *),
- M_SHM, M_WAITOK);
+ M_SHM, M_WAITOK|M_ZERO);
bcopy(shmsegs, newsegs,
shminfo.shmmni * sizeof(struct shmid_ds *));
- bzero(newsegs + shminfo.shmmni,
- (val - shminfo.shmmni) * sizeof(struct shmid_ds *));
free(shmsegs, M_SHM);
shmsegs = newsegs;
- newseqs = malloc(val * sizeof(unsigned short), M_SHM, M_WAITOK);
+ newseqs = malloc(val * sizeof(unsigned short), M_SHM,
+ M_WAITOK|M_ZERO);
bcopy(shmseqs, newseqs,
shminfo.shmmni * sizeof(unsigned short));
- bzero(newseqs + shminfo.shmmni,
- (val - shminfo.shmmni) * sizeof(unsigned short));
free(shmseqs, M_SHM);
shmseqs = newseqs;
shminfo.shmmni = val;
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 5a8c65440c0..928305b2cd9 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.72 2007/03/15 10:22:30 art Exp $ */
+/* $OpenBSD: tty.c,v 1.73 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
@@ -2235,8 +2235,8 @@ ttymalloc(void)
{
struct tty *tp;
- MALLOC(tp, struct tty *, sizeof(struct tty), M_TTYS, M_WAITOK);
- bzero(tp, sizeof *tp);
+ tp = malloc(sizeof(struct tty), M_TTYS, M_WAITOK|M_ZERO);
+
/* XXX: default to 1024 chars for now */
clalloc(&tp->t_rawq, 1024, 1);
clalloc(&tp->t_canq, 1024, 1);
diff --git a/sys/kern/tty_nmea.c b/sys/kern/tty_nmea.c
index fd7d28a5be5..5c16efb92bb 100644
--- a/sys/kern/tty_nmea.c
+++ b/sys/kern/tty_nmea.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_nmea.c,v 1.21 2007/03/22 16:55:31 deraadt Exp $ */
+/* $OpenBSD: tty_nmea.c,v 1.22 2007/09/07 15:00:20 art Exp $ */
/*
* Copyright (c) 2006, 2007 Marc Balmer <mbalmer@openbsd.org>
@@ -87,8 +87,7 @@ nmeaopen(dev_t dev, struct tty *tp)
return ENODEV;
if ((error = suser(p, 0)) != 0)
return error;
- np = malloc(sizeof(struct nmea), M_DEVBUF, M_WAITOK);
- bzero(np, sizeof(*np));
+ np = malloc(sizeof(struct nmea), M_DEVBUF, M_WAITOK|M_ZERO);
snprintf(np->timedev.xname, sizeof(np->timedev.xname), "nmea%d",
nmea_count++);
np->time.status = SENSOR_S_UNKNOWN;
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index a49334d7951..a158a80b18a 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_pty.c,v 1.34 2007/05/29 00:17:32 thib Exp $ */
+/* $OpenBSD: tty_pty.c,v 1.35 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: tty_pty.c,v 1.33.4.1 1996/06/02 09:08:11 mrg Exp $ */
/*
@@ -154,8 +154,8 @@ ptyarralloc(int nelem)
{
struct pt_softc **pt;
- pt = malloc(nelem * sizeof(struct pt_softc *), M_DEVBUF, M_WAITOK);
- bzero(pt, nelem * sizeof(struct pt_softc *));
+ pt = malloc(nelem * sizeof(struct pt_softc *), M_DEVBUF,
+ M_WAITOK|M_ZERO);
return pt;
}
@@ -199,9 +199,8 @@ check_pty(int minor)
* If the entry is not yet allocated, allocate one.
*/
if (!pt_softc[minor]) {
- MALLOC(pti, struct pt_softc *, sizeof(struct pt_softc),
- M_DEVBUF, M_WAITOK);
- bzero(pti, sizeof(struct pt_softc));
+ pti = malloc(sizeof(struct pt_softc), M_DEVBUF,
+ M_WAITOK|M_ZERO);
pti->pt_tty = ttymalloc();
ptydevname(minor, pti);
pt_softc[minor] = pti;
diff --git a/sys/kern/tty_subr.c b/sys/kern/tty_subr.c
index 6ab18d8e19d..e1e976c527d 100644
--- a/sys/kern/tty_subr.c
+++ b/sys/kern/tty_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_subr.c,v 1.18 2005/12/21 12:43:49 jsg Exp $ */
+/* $OpenBSD: tty_subr.c,v 1.19 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: tty_subr.c,v 1.13 1996/02/09 19:00:43 christos Exp $ */
/*
@@ -64,13 +64,11 @@ int
clalloc(struct clist *clp, int size, int quot)
{
- clp->c_cs = malloc(size, M_TTYS, M_WAITOK);
- bzero(clp->c_cs, size);
+ clp->c_cs = malloc(size, M_TTYS, M_WAITOK|M_ZERO);
- if (quot) {
- clp->c_cq = malloc(QMEM(size), M_TTYS, M_WAITOK);
- bzero(clp->c_cq, QMEM(size));
- } else
+ if (quot)
+ clp->c_cq = malloc(QMEM(size), M_TTYS, M_WAITOK|M_ZERO);
+ else
clp->c_cq = (u_char *)0;
clp->c_cf = clp->c_cl = (u_char *)0;
diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c
index 66ac1394dca..09097eea4be 100644
--- a/sys/kern/uipc_usrreq.c
+++ b/sys/kern/uipc_usrreq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_usrreq.c,v 1.34 2007/01/16 17:52:18 thib Exp $ */
+/* $OpenBSD: uipc_usrreq.c,v 1.35 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: uipc_usrreq.c,v 1.18 1996/02/09 19:00:50 christos Exp $ */
/*
@@ -351,10 +351,9 @@ unp_attach(struct socket *so)
if (error)
return (error);
}
- unp = malloc(sizeof(*unp), M_PCB, M_NOWAIT);
+ unp = malloc(sizeof(*unp), M_PCB, M_NOWAIT|M_ZERO);
if (unp == NULL)
return (ENOBUFS);
- bzero((caddr_t)unp, sizeof(*unp));
unp->unp_socket = so;
so->so_pcb = unp;
nanotime(&unp->unp_ctime);
diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c
index 7820e78beb1..4b13438a0d4 100644
--- a/sys/kern/vfs_init.c
+++ b/sys/kern/vfs_init.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_init.c,v 1.19 2007/05/29 16:25:07 thib Exp $ */
+/* $OpenBSD: vfs_init.c,v 1.20 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: vfs_init.c,v 1.6 1996/02/09 19:00:58 christos Exp $ */
/*
@@ -117,8 +117,7 @@ vfs_opv_init_explicit(struct vnodeopv_desc *vfs_opv_desc)
if (opv_desc_vector == NULL) {
/* XXX - shouldn't be M_VNODE */
opv_desc_vector = malloc(vfs_opv_numops * sizeof(PFI),
- M_VNODE, M_WAITOK);
- bzero(opv_desc_vector, vfs_opv_numops * sizeof(PFI));
+ M_VNODE, M_WAITOK|M_ZERO);
*(vfs_opv_desc->opv_desc_vector_p) = opv_desc_vector;
DODEBUG(printf("vector at %p allocated\n",
opv_desc_vector));
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c
index f39b05bcc05..7f192fc9767 100644
--- a/sys/kern/vfs_subr.c
+++ b/sys/kern/vfs_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_subr.c,v 1.155 2007/08/07 04:32:45 beck Exp $ */
+/* $OpenBSD: vfs_subr.c,v 1.156 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: vfs_subr.c,v 1.53 1996/04/22 01:39:13 christos Exp $ */
/*
@@ -199,8 +199,7 @@ vfs_rootmountalloc(char *fstypename, char *devname, struct mount **mpp)
break;
if (vfsp == NULL)
return (ENODEV);
- mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK);
- bzero(mp, sizeof(struct mount));
+ mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK|M_ZERO);
(void)vfs_busy(mp, VB_READ|VB_NOWAIT);
LIST_INIT(&mp->mnt_vnodelist);
mp->mnt_vfc = vfsp;
@@ -1428,8 +1427,7 @@ vfs_hang_addrlist(struct mount *mp, struct netexport *nep,
argp->ex_addrlen < 0 || argp->ex_masklen < 0)
return (EINVAL);
i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen;
- np = (struct netcred *)malloc(i, M_NETADDR, M_WAITOK);
- bzero(np, i);
+ np = (struct netcred *)malloc(i, M_NETADDR, M_WAITOK|M_ZERO);
saddr = (struct sockaddr *)(np + 1);
error = copyin(argp->ex_addr, saddr, argp->ex_addrlen);
if (error)
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 0dd0099c80d..56da038c4f0 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vfs_syscalls.c,v 1.142 2007/08/30 12:35:27 thib Exp $ */
+/* $OpenBSD: vfs_syscalls.c,v 1.143 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */
/*
@@ -237,8 +237,7 @@ sys_mount(struct proc *p, void *v, register_t *retval)
* Allocate and initialize the file system.
*/
mp = (struct mount *)malloc((u_long)sizeof(struct mount),
- M_MOUNT, M_WAITOK);
- bzero((char *)mp, (u_long)sizeof(struct mount));
+ M_MOUNT, M_WAITOK|M_ZERO);
(void) vfs_busy(mp, VB_READ|VB_NOWAIT);
mp->mnt_op = vfsp->vfc_vfsops;
mp->mnt_vfc = vfsp;
diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c
index 5ff86b1ed31..1279d3b85ef 100644
--- a/sys/ufs/ffs/ffs_vfsops.c
+++ b/sys/ufs/ffs/ffs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ffs_vfsops.c,v 1.109 2007/08/04 03:33:31 art Exp $ */
+/* $OpenBSD: ffs_vfsops.c,v 1.110 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: ffs_vfsops.c,v 1.19 1996/02/09 22:22:26 christos Exp $ */
/*
@@ -309,9 +309,8 @@ ffs_mount(struct mount *mp, const char *path, void *data,
if (error)
goto error_1;
}
- fs->fs_contigdirs=(u_int8_t*)malloc((u_long)fs->fs_ncg,
- M_UFSMNT, M_WAITOK);
- bzero(fs->fs_contigdirs, fs->fs_ncg);
+ fs->fs_contigdirs = malloc((u_long)fs->fs_ncg,
+ M_UFSMNT, M_WAITOK|M_ZERO);
ronly = 0;
}
@@ -787,8 +786,7 @@ ffs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p)
goto out;
}
- ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK);
- bzero(ump, sizeof *ump);
+ ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK|M_ZERO);
ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT,
M_WAITOK);
@@ -861,9 +859,8 @@ ffs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p)
if (ronly)
fs->fs_contigdirs = NULL;
else {
- fs->fs_contigdirs = (u_int8_t*)malloc((u_long)fs->fs_ncg,
- M_UFSMNT, M_WAITOK);
- bzero(fs->fs_contigdirs, fs->fs_ncg);
+ fs->fs_contigdirs = malloc((u_long)fs->fs_ncg,
+ M_UFSMNT, M_WAITOK|M_ZERO);
}
/*
diff --git a/sys/uvm/uvm_amap.c b/sys/uvm/uvm_amap.c
index ee105ed3b13..a3f74b64019 100644
--- a/sys/uvm/uvm_amap.c
+++ b/sys/uvm/uvm_amap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_amap.c,v 1.39 2007/06/18 21:51:15 pedro Exp $ */
+/* $OpenBSD: uvm_amap.c,v 1.40 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: uvm_amap.c,v 1.27 2000/11/25 06:27:59 chs Exp $ */
/*
@@ -902,7 +902,7 @@ amap_pp_establish(struct vm_amap *amap)
{
amap->am_ppref = malloc(sizeof(int) * amap->am_maxslot,
- M_UVMAMAP, M_NOWAIT);
+ M_UVMAMAP, M_NOWAIT|M_ZERO);
/*
* if we fail then we just won't use ppref for this amap
@@ -915,7 +915,6 @@ amap_pp_establish(struct vm_amap *amap)
/*
* init ppref
*/
- memset(amap->am_ppref, 0, sizeof(int) * amap->am_maxslot);
pp_setreflen(amap->am_ppref, 0, amap->am_ref, amap->am_nslot);
}
diff --git a/sys/uvm/uvm_aobj.c b/sys/uvm/uvm_aobj.c
index 08910778cc1..74a087ab512 100644
--- a/sys/uvm/uvm_aobj.c
+++ b/sys/uvm/uvm_aobj.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_aobj.c,v 1.34 2007/04/13 18:57:49 art Exp $ */
+/* $OpenBSD: uvm_aobj.c,v 1.35 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: uvm_aobj.c,v 1.39 2001/02/18 21:19:08 chs Exp $ */
/*
@@ -524,10 +524,9 @@ uao_create(size, flags)
panic("uao_create: hashinit swhash failed");
} else {
aobj->u_swslots = malloc(pages * sizeof(int),
- M_UVMAOBJ, mflags);
+ M_UVMAOBJ, mflags|M_ZERO);
if (aobj->u_swslots == NULL)
panic("uao_create: malloc swslots failed");
- memset(aobj->u_swslots, 0, pages * sizeof(int));
}
if (flags) {
diff --git a/sys/uvm/uvm_stat.h b/sys/uvm/uvm_stat.h
index 7aecd0de5b5..8452948a188 100644
--- a/sys/uvm/uvm_stat.h
+++ b/sys/uvm/uvm_stat.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_stat.h,v 1.14 2006/01/16 13:11:06 mickey Exp $ */
+/* $OpenBSD: uvm_stat.h,v 1.15 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: uvm_stat.h,v 1.19 2001/02/04 10:55:58 mrg Exp $ */
/*
@@ -162,8 +162,7 @@ do { \
simple_lock_init(&(NAME).l); \
(NAME).e = (struct uvm_history_ent *) \
malloc(sizeof(struct uvm_history_ent) * (N), M_TEMP, \
- M_WAITOK); \
- memset((NAME).e, 0, sizeof(struct uvm_history_ent) * (N)); \
+ M_WAITOK|M_ZERO); \
LIST_INSERT_HEAD(&uvm_histories, &(NAME), list); \
} while (0)
diff --git a/sys/uvm/uvm_swap.c b/sys/uvm/uvm_swap.c
index f5baa906794..eea4bf6717c 100644
--- a/sys/uvm/uvm_swap.c
+++ b/sys/uvm/uvm_swap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_swap.c,v 1.72 2007/06/18 21:51:15 pedro Exp $ */
+/* $OpenBSD: uvm_swap.c,v 1.73 2007/09/07 15:00:20 art Exp $ */
/* $NetBSD: uvm_swap.c,v 1.40 2000/11/17 11:39:39 mrg Exp $ */
/*
@@ -344,11 +344,10 @@ uvm_swap_initcrypt(struct swapdev *sdp, int npages)
* we may not call malloc with M_WAITOK. This consumes only
* 8KB memory for a 256MB swap partition.
*/
- sdp->swd_decrypt = malloc(SWD_DCRYPT_SIZE(npages), M_VMSWAP, M_WAITOK);
- memset(sdp->swd_decrypt, 0, SWD_DCRYPT_SIZE(npages));
+ sdp->swd_decrypt = malloc(SWD_DCRYPT_SIZE(npages), M_VMSWAP,
+ M_WAITOK|M_ZERO);
sdp->swd_keys = malloc((npages >> SWD_KEY_SHIFT) * sizeof(struct swap_key),
- M_VMSWAP, M_WAITOK);
- memset(sdp->swd_keys, 0, (npages >> SWD_KEY_SHIFT) * sizeof(struct swap_key));
+ M_VMSWAP, M_WAITOK|M_ZERO);
sdp->swd_nkeys = 0;
}
@@ -799,9 +798,8 @@ sys_swapctl(p, v, retval)
simple_unlock(&uvm.swap_data_lock);
break;
}
- sdp = malloc(sizeof *sdp, M_VMSWAP, M_WAITOK);
+ sdp = malloc(sizeof *sdp, M_VMSWAP, M_WAITOK|M_ZERO);
spp = malloc(sizeof *spp, M_VMSWAP, M_WAITOK);
- memset(sdp, 0, sizeof(*sdp));
sdp->swd_flags = SWF_FAKE; /* placeholder only */
sdp->swd_vp = vp;
sdp->swd_dev = (vp->v_type == VBLK) ? vp->v_rdev : NODEV;
@@ -2091,9 +2089,8 @@ swapmount()
return;
}
- sdp = malloc(sizeof(*sdp), M_VMSWAP, M_WAITOK);
+ sdp = malloc(sizeof(*sdp), M_VMSWAP, M_WAITOK|M_ZERO);
spp = malloc(sizeof(*spp), M_VMSWAP, M_WAITOK);
- memset(sdp, 0, sizeof(*sdp));
sdp->swd_flags = SWF_FAKE;
sdp->swd_dev = swap_dev;