From f5461d41b129fefc48ff4c9ded82554394de9bf0 Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Sat, 6 Oct 2007 23:50:56 +0000 Subject: Simpliest memset(,0,) -> M_ZERO changes. One (caddr *) cast removal, otherwise just adding M_ZERO to malloc() and removing the immediately adjacent memset(,0,). --- sys/arch/alpha/tc/tc_dma_3000_500.c | 5 ++--- sys/arch/arm/arm/mem.c | 10 ++++------ sys/arch/hppa/dev/apic.c | 6 +++--- sys/arch/hppa/dev/astro.c | 6 ++---- sys/arch/sh/sh/mem.c | 9 ++++----- 5 files changed, 15 insertions(+), 21 deletions(-) (limited to 'sys/arch') 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; -- cgit v1.2.3