diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-10-06 23:50:56 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2007-10-06 23:50:56 +0000 |
commit | f5461d41b129fefc48ff4c9ded82554394de9bf0 (patch) | |
tree | 86f9d97cdbd7712121debe572c568e72070e2559 | |
parent | fd70724e0c6df0ffd868e0c7d80b8f683072b49a (diff) |
Simpliest memset(,0,) -> M_ZERO changes. One (caddr *) cast removal,
otherwise just adding M_ZERO to malloc() and removing the immediately
adjacent memset(,0,).
-rw-r--r-- | sys/arch/alpha/tc/tc_dma_3000_500.c | 5 | ||||
-rw-r--r-- | sys/arch/arm/arm/mem.c | 10 | ||||
-rw-r--r-- | sys/arch/hppa/dev/apic.c | 6 | ||||
-rw-r--r-- | sys/arch/hppa/dev/astro.c | 6 | ||||
-rw-r--r-- | sys/arch/sh/sh/mem.c | 9 | ||||
-rw-r--r-- | sys/dev/pci/agp_amd.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/agp_i810.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/agp_intel.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/agp_via.c | 5 | ||||
-rw-r--r-- | sys/dev/pci/cz.c | 6 | ||||
-rw-r--r-- | sys/dev/sequencer.c | 5 | ||||
-rw-r--r-- | sys/dev/usb/umidi.c | 7 | ||||
-rw-r--r-- | sys/dev/usb/usb_subr.c | 5 | ||||
-rw-r--r-- | sys/ufs/ext2fs/ext2fs_vfsops.c | 9 |
14 files changed, 36 insertions, 52 deletions
diff --git a/sys/arch/alpha/tc/tc_dma_3000_500.c b/sys/arch/alpha/tc/tc_dma_3000_500.c index 51faf6d9262..cc3ca7db769 100644 --- a/sys/arch/alpha/tc/tc_dma_3000_500.c +++ b/sys/arch/alpha/tc/tc_dma_3000_500.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tc_dma_3000_500.c,v 1.2 2006/04/04 21:20:40 brad Exp $ */ +/* $OpenBSD: tc_dma_3000_500.c,v 1.3 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: tc_dma_3000_500.c,v 1.13 2001/07/19 06:40:03 thorpej Exp $ */ /*- @@ -94,10 +94,9 @@ tc_dma_init_3000_500(nslots) /* Allocate per-slot DMA info. */ sisize = nslots * sizeof(struct tc_dma_slot_info); - tc_dma_slot_info = malloc(sisize, M_DEVBUF, M_NOWAIT); + tc_dma_slot_info = malloc(sisize, M_DEVBUF, M_NOWAIT | M_ZERO); if (tc_dma_slot_info == NULL) panic("tc_dma_init: can't allocate per-slot DMA info"); - memset(tc_dma_slot_info, 0, sisize); /* Default all slots to direct-mapped. */ for (i = 0; i < nslots; i++) diff --git a/sys/arch/arm/arm/mem.c b/sys/arch/arm/arm/mem.c index 8375052531f..bcf8367e212 100644 --- a/sys/arch/arm/arm/mem.c +++ b/sys/arch/arm/arm/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.6 2006/11/29 13:28:45 miod Exp $ */ +/* $OpenBSD: mem.c,v 1.7 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: mem.c,v 1.11 2003/10/16 12:02:58 jdolecek Exp $ */ /* @@ -215,11 +215,9 @@ mmrw(dev, uio, flags) uio->uio_resid = 0; return (0); } - if (zeropage == NULL) { - zeropage = (caddr_t) - malloc(PAGE_SIZE, M_TEMP, M_WAITOK); - memset(zeropage, 0, PAGE_SIZE); - } + if (zeropage == NULL) + zeropage = malloc(PAGE_SIZE, M_TEMP, + M_WAITOK | M_ZERO); c = min(iov->iov_len, PAGE_SIZE); error = uiomove(zeropage, c, uio); break; diff --git a/sys/arch/hppa/dev/apic.c b/sys/arch/hppa/dev/apic.c index 631ac9cf259..7e8bc7f684d 100644 --- a/sys/arch/hppa/dev/apic.c +++ b/sys/arch/hppa/dev/apic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apic.c,v 1.6 2007/07/01 14:20:50 kettenis Exp $ */ +/* $OpenBSD: apic.c,v 1.7 2007/10/06 23:50:54 krw Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -103,10 +103,10 @@ apic_attach(struct elroy_softc *sc) printf(" APIC ver %x, %d pins", data & APIC_VERSION_MASK, sc->sc_nints); - sc->sc_irq = malloc(sc->sc_nints * sizeof(int), M_DEVBUF, M_NOWAIT); + sc->sc_irq = malloc(sc->sc_nints * sizeof(int), M_DEVBUF, + M_NOWAIT | M_ZERO); if (sc->sc_irq == NULL) panic("apic_attach: cannot allocate irq table\n"); - memset(sc->sc_irq, 0, sc->sc_nints * sizeof(int)); apic_get_int_tbl(sc); diff --git a/sys/arch/hppa/dev/astro.c b/sys/arch/hppa/dev/astro.c index d87a63a4b0e..13c18a086ee 100644 --- a/sys/arch/hppa/dev/astro.c +++ b/sys/arch/hppa/dev/astro.c @@ -1,4 +1,4 @@ -/* $OpenBSD: astro.c,v 1.7 2007/07/01 12:53:52 kettenis Exp $ */ +/* $OpenBSD: astro.c,v 1.8 2007/10/06 23:50:54 krw Exp $ */ /* * Copyright (c) 2007 Mark Kettenis @@ -589,12 +589,10 @@ iommu_iomap_create(int n) n = 16; ims = malloc(sizeof(*ims) + (n - 1) * sizeof(ims->ims_map.ipm_map[0]), - M_DEVBUF, M_NOWAIT); + M_DEVBUF, M_NOWAIT | M_ZERO); if (ims == NULL) return (NULL); - memset(ims, 0, sizeof *ims); - /* Initialize the map. */ ims->ims_map.ipm_maxpage = n; SPLAY_INIT(&ims->ims_map.ipm_tree); diff --git a/sys/arch/sh/sh/mem.c b/sys/arch/sh/sh/mem.c index 1ad93907c59..606376cb231 100644 --- a/sys/arch/sh/sh/mem.c +++ b/sys/arch/sh/sh/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.2 2006/12/05 19:55:43 drahn Exp $ */ +/* $OpenBSD: mem.c,v 1.3 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: mem.c,v 1.21 2006/07/23 22:06:07 ad Exp $ */ /* @@ -193,10 +193,9 @@ mmrw(dev_t dev, struct uio *uio, int flags) uio->uio_resid = 0; return (0); } - if (zeropage == NULL) { - zeropage = malloc(PAGE_SIZE, M_TEMP, M_WAITOK); - memset(zeropage, 0, PAGE_SIZE); - } + if (zeropage == NULL) + zeropage = malloc(PAGE_SIZE, M_TEMP, + M_WAITOK | M_ZERO); c = min(iov->iov_len, PAGE_SIZE); error = uiomove(zeropage, c, uio); break; diff --git a/sys/dev/pci/agp_amd.c b/sys/dev/pci/agp_amd.c index 7766ba8b5b2..d09027a3183 100644 --- a/sys/dev/pci/agp_amd.c +++ b/sys/dev/pci/agp_amd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_amd.c,v 1.3 2007/08/04 19:40:25 reyk Exp $ */ +/* $OpenBSD: agp_amd.c,v 1.4 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: agp_amd.c,v 1.6 2001/10/06 02:48:50 thorpej Exp $ */ @@ -162,13 +162,12 @@ agp_amd_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct pci_ pcireg_t reg; int error; - asc = malloc(sizeof *asc, M_DEVBUF, M_NOWAIT); + asc = malloc(sizeof *asc, M_DEVBUF, M_NOWAIT | M_ZERO); if (asc == NULL) { printf(": can't allocate softc\n"); /* agp_generic_detach(sc) */ return (ENOMEM); } - memset(asc, 0, sizeof *asc); error = pci_mapreg_map(pchb_pa, AGP_AMD751_REGISTERS, PCI_MAPREG_TYPE_MEM,0, &asc->iot, &asc->ioh, NULL, NULL, 0); diff --git a/sys/dev/pci/agp_i810.c b/sys/dev/pci/agp_i810.c index d405e3d4e89..4af86c1db1d 100644 --- a/sys/dev/pci/agp_i810.c +++ b/sys/dev/pci/agp_i810.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_i810.c,v 1.16 2007/09/17 01:33:33 krw Exp $ */ +/* $OpenBSD: agp_i810.c,v 1.17 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: agp_i810.c,v 1.15 2003/01/31 00:07:39 thorpej Exp $ */ /*- @@ -116,12 +116,11 @@ agp_i810_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, int error; u_int memtype = 0; - isc = malloc(sizeof *isc, M_DEVBUF, M_NOWAIT); + isc = malloc(sizeof *isc, M_DEVBUF, M_NOWAIT | M_ZERO); if (isc == NULL) { printf(": can't allocate chipset-specific softc\n"); return (ENOMEM); } - memset(isc, 0, sizeof *isc); sc->sc_chipc = isc; sc->sc_methods = &agp_i810_methods; memcpy(&isc->bridge_pa, pchb_pa, sizeof *pchb_pa); diff --git a/sys/dev/pci/agp_intel.c b/sys/dev/pci/agp_intel.c index a1110fb9344..722b0f8f982 100644 --- a/sys/dev/pci/agp_intel.c +++ b/sys/dev/pci/agp_intel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_intel.c,v 1.4 2007/08/04 19:40:25 reyk Exp $ */ +/* $OpenBSD: agp_intel.c,v 1.5 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: agp_intel.c,v 1.3 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -82,12 +82,11 @@ agp_intel_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct agp_gatt *gatt; pcireg_t reg; - isc = malloc(sizeof *isc, M_DEVBUF, M_NOWAIT); + isc = malloc(sizeof *isc, M_DEVBUF, M_NOWAIT | M_ZERO); if (isc == NULL) { printf(": can't allocate chipset-specific softc\n"); return (ENOMEM); } - memset(isc, 0, sizeof *isc); sc->sc_methods = &agp_intel_methods; sc->sc_chipc = isc; diff --git a/sys/dev/pci/agp_via.c b/sys/dev/pci/agp_via.c index ddee7cf101f..bb9c0114699 100644 --- a/sys/dev/pci/agp_via.c +++ b/sys/dev/pci/agp_via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: agp_via.c,v 1.3 2007/08/04 19:40:25 reyk Exp $ */ +/* $OpenBSD: agp_via.c,v 1.4 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: agp_via.c,v 1.2 2001/09/15 00:25:00 thorpej Exp $ */ /*- @@ -80,12 +80,11 @@ agp_via_attach(struct vga_pci_softc *sc, struct pci_attach_args *pa, struct agp_via_softc *asc; struct agp_gatt *gatt; - asc = malloc(sizeof *asc, M_DEVBUF, M_NOWAIT); + asc = malloc(sizeof *asc, M_DEVBUF, M_NOWAIT | M_ZERO); if (asc == NULL) { printf(": can't allocate chipset-specific softc\n"); return (ENOMEM); } - memset(asc, 0, sizeof *asc); sc->sc_chipc = asc; sc->sc_methods = &agp_via_methods; diff --git a/sys/dev/pci/cz.c b/sys/dev/pci/cz.c index 3b3929a1cc3..2776c396f31 100644 --- a/sys/dev/pci/cz.c +++ b/sys/dev/pci/cz.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cz.c,v 1.9 2003/10/03 16:44:51 miod Exp $ */ +/* $OpenBSD: cz.c,v 1.10 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: cz.c,v 1.15 2001/01/20 19:10:36 thorpej Exp $ */ /*- @@ -389,10 +389,8 @@ cz_attach(parent, self, aux) } cz->cz_ports = malloc(sizeof(struct cztty_softc) * cz->cz_nchannels, - M_DEVBUF, M_WAITOK); + M_DEVBUF, M_WAITOK | M_ZERO); cztty_attached_ttys += cz->cz_nchannels; - memset(cz->cz_ports, 0, - sizeof(struct cztty_softc) * cz->cz_nchannels); for (i = 0; i < cz->cz_nchannels; i++) { sc = &cz->cz_ports[i]; diff --git a/sys/dev/sequencer.c b/sys/dev/sequencer.c index e7df1b0de77..9e6106d4e3c 100644 --- a/sys/dev/sequencer.c +++ b/sys/dev/sequencer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sequencer.c,v 1.14 2007/09/05 23:36:12 jakemsr Exp $ */ +/* $OpenBSD: sequencer.c,v 1.15 2007/10/06 23:50:54 krw Exp $ */ /* $NetBSD: sequencer.c,v 1.13 1998/11/25 22:17:07 augustss Exp $ */ /* @@ -1041,9 +1041,8 @@ midiseq_open(int unit, int flags) return (0); sc = midi_cd.cd_devs[unit]; sc->seqopen = 1; - md = malloc(sizeof *md, M_DEVBUF, M_WAITOK); + md = malloc(sizeof *md, M_DEVBUF, M_WAITOK | M_ZERO); sc->seq_md = md; - memset(md, 0, sizeof *md); md->msc = sc; midi_getinfo(makedev(0, unit), &mi); md->unit = unit; diff --git a/sys/dev/usb/umidi.c b/sys/dev/usb/umidi.c index b0282d82961..7cb708d5ba7 100644 --- a/sys/dev/usb/umidi.c +++ b/sys/dev/usb/umidi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umidi.c,v 1.22 2007/06/14 10:11:16 mbalmer Exp $ */ +/* $OpenBSD: umidi.c,v 1.23 2007/10/06 23:50:55 krw Exp $ */ /* $NetBSD: umidi.c,v 1.16 2002/07/11 21:14:32 augustss Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -993,11 +993,10 @@ static usbd_status alloc_all_mididevs(struct umidi_softc *sc, int nmidi) { sc->sc_num_mididevs = nmidi; - sc->sc_mididevs = malloc(sizeof(*sc->sc_mididevs)*nmidi, - M_USBDEV, M_WAITOK); + sc->sc_mididevs = malloc(sizeof(*sc->sc_mididevs)*nmidi, M_USBDEV, + M_WAITOK | M_ZERO); if (!sc->sc_mididevs) return USBD_NOMEM; - memset(sc->sc_mididevs, 0, sizeof(*sc->sc_mididevs)*nmidi); return USBD_NORMAL_COMPLETION; } diff --git a/sys/dev/usb/usb_subr.c b/sys/dev/usb/usb_subr.c index c3dacfe467e..c30b6b5c70b 100644 --- a/sys/dev/usb/usb_subr.c +++ b/sys/dev/usb/usb_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: usb_subr.c,v 1.60 2007/09/11 13:39:34 gilles Exp $ */ +/* $OpenBSD: usb_subr.c,v 1.61 2007/10/06 23:50:55 krw Exp $ */ /* $NetBSD: usb_subr.c,v 1.103 2003/01/10 11:19:13 augustss Exp $ */ /* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */ @@ -976,10 +976,9 @@ usbd_new_device(struct device *parent, usbd_bus_handle bus, int depth, return (USBD_NO_ADDR); } - dev = malloc(sizeof *dev, M_USB, M_NOWAIT); + dev = malloc(sizeof *dev, M_USB, M_NOWAIT | M_ZERO); if (dev == NULL) return (USBD_NOMEM); - memset(dev, 0, sizeof *dev); dev->bus = bus; diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 5576f7115b4..163923c8d38 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ext2fs_vfsops.c,v 1.48 2007/06/17 20:15:25 jasper Exp $ */ +/* $OpenBSD: ext2fs_vfsops.c,v 1.49 2007/10/06 23:50:55 krw Exp $ */ /* $NetBSD: ext2fs_vfsops.c,v 1.1 1997/06/11 09:34:07 bouyer Exp $ */ /* @@ -522,10 +522,9 @@ ext2fs_mountfs(struct vnode *devvp, struct mount *mp, struct proc *p) error = ext2fs_checksb(fs, ronly); if (error) goto out; - ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK); - memset((caddr_t)ump, 0, sizeof *ump); - ump->um_e2fs = malloc(sizeof(struct m_ext2fs), M_UFSMNT, M_WAITOK); - memset((caddr_t)ump->um_e2fs, 0, sizeof(struct m_ext2fs)); + ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK | M_ZERO); + ump->um_e2fs = malloc(sizeof(struct m_ext2fs), M_UFSMNT, + M_WAITOK | M_ZERO); e2fs_sbload((struct ext2fs*)bp->b_data, &ump->um_e2fs->e2fs); brelse(bp); bp = NULL; |