diff options
author | Charles Longeau <chl@cvs.openbsd.org> | 2007-09-17 15:34:39 +0000 |
---|---|---|
committer | Charles Longeau <chl@cvs.openbsd.org> | 2007-09-17 15:34:39 +0000 |
commit | 32edbddb7c4f4dab431a8576907f802b3848c355 (patch) | |
tree | 2866a513878e0564f5ef12e2b343073d173f4020 /sys | |
parent | 1d9168709cd84e6ee98534bb1b51d58498dd71ca (diff) |
MALLOC/FREE -> malloc/free and M_ZERO changes
ok krw@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/bus_dma.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/cpu.c | 5 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/intr.c | 37 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/mem.c | 8 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/mpbios.c | 5 | ||||
-rw-r--r-- | sys/arch/amd64/isa/isa_machdep.c | 6 | ||||
-rw-r--r-- | sys/arch/amd64/pci/iommu.c | 5 |
7 files changed, 27 insertions, 45 deletions
diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c index dcdc80dff38..b09e63dc11d 100644 --- a/sys/arch/amd64/amd64/bus_dma.c +++ b/sys/arch/amd64/amd64/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.9 2007/09/03 01:09:09 krw Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.10 2007/09/17 15:34:38 chl Exp $ */ /* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -153,10 +153,10 @@ _bus_dmamap_create(bus_dma_tag_t t, bus_size_t size, int nsegments, mapsize = sizeof(struct x86_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_ZERO) : (M_WAITOK|M_ZERO))) == NULL) return (ENOMEM); - bzero(mapstore, mapsize); map = (struct x86_bus_dmamap *)mapstore; map->_dm_size = size; map->_dm_segcnt = nsegments; diff --git a/sys/arch/amd64/amd64/cpu.c b/sys/arch/amd64/amd64/cpu.c index 2cba6925e0a..2f29892d219 100644 --- a/sys/arch/amd64/amd64/cpu.c +++ b/sys/arch/amd64/amd64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.13 2007/08/02 16:40:27 deraadt Exp $ */ +/* $OpenBSD: cpu.c,v 1.14 2007/09/17 15:34:38 chl Exp $ */ /* $NetBSD: cpu.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */ /*- @@ -244,8 +244,7 @@ cpu_attach(struct device *parent, struct device *self, void *aux) * structure, otherwise use the primary's. */ if (caa->cpu_role == CPU_ROLE_AP) { - ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK); - memset(ci, 0, sizeof(*ci)); + ci = malloc(sizeof(*ci), M_DEVBUF, M_WAITOK|M_ZERO); #if defined(MULTIPROCESSOR) if (cpu_info[cpunum] != NULL) panic("cpu at apic id %d already attached?", cpunum); diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c index c127cdbf12b..8455a9af1a7 100644 --- a/sys/arch/amd64/amd64/intr.c +++ b/sys/arch/amd64/amd64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.14 2007/05/10 17:59:23 deraadt Exp $ */ +/* $OpenBSD: intr.c,v 1.15 2007/09/17 15:34:38 chl Exp $ */ /* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */ /* @@ -223,13 +223,12 @@ intr_allocate_slot_cpu(struct cpu_info *ci, struct pic *pic, int pin, isp = ci->ci_isources[slot]; if (isp == NULL) { - MALLOC(isp, struct intrsource *, sizeof (struct intrsource), - M_DEVBUF, M_NOWAIT); + isp = malloc(sizeof (struct intrsource), M_DEVBUF, + M_NOWAIT|M_ZERO); if (isp == NULL) { simple_unlock(&ci->ci_slock); return ENOMEM; } - memset(isp, 0, sizeof(struct intrsource)); snprintf(isp->is_evname, sizeof (isp->is_evname), "pin %d", pin); ci->ci_isources[slot] = isp; @@ -273,12 +272,10 @@ intr_allocate_slot(struct pic *pic, int legacy_irq, int pin, int level, slot = legacy_irq; isp = ci->ci_isources[slot]; if (isp == NULL) { - MALLOC(isp, struct intrsource *, - sizeof (struct intrsource), M_DEVBUF, - M_NOWAIT); + isp = malloc(sizeof (struct intrsource), M_DEVBUF, + M_NOWAIT|M_ZERO); if (isp == NULL) return ENOMEM; - memset(isp, 0, sizeof(struct intrsource)); snprintf(isp->is_evname, sizeof (isp->is_evname), "pin %d", pin); @@ -334,7 +331,7 @@ found: idtvec = idt_vec_alloc(APIC_LEVEL(level), IDT_INTR_HIGH); if (idtvec == 0) { simple_lock(&ci->ci_slock); - FREE(ci->ci_isources[slot], M_DEVBUF); + free(ci->ci_isources[slot], M_DEVBUF); ci->ci_isources[slot] = NULL; simple_unlock(&ci->ci_slock); return EBUSY; @@ -520,7 +517,7 @@ intr_disestablish(struct intrhand *ih) #endif if (source->is_handlers == NULL) { - FREE(source, M_DEVBUF); + free(source, M_DEVBUF); ci->ci_isources[ih->ih_slot] = NULL; if (pic != &i8259_pic) idt_vec_free(idtvec); @@ -560,33 +557,27 @@ cpu_intr_init(struct cpu_info *ci) int i; #endif - MALLOC(isp, struct intrsource *, sizeof (struct intrsource), M_DEVBUF, - M_WAITOK); + isp = malloc(sizeof (struct intrsource), M_DEVBUF, M_WAITOK|M_ZERO); if (isp == NULL) panic("can't allocate fixed interrupt source"); - memset(isp, 0, sizeof(struct intrsource)); isp->is_recurse = Xsoftclock; isp->is_resume = Xsoftclock; fake_softclock_intrhand.ih_level = IPL_SOFTCLOCK; isp->is_handlers = &fake_softclock_intrhand; isp->is_pic = &softintr_pic; ci->ci_isources[SIR_CLOCK] = isp; - MALLOC(isp, struct intrsource *, sizeof (struct intrsource), M_DEVBUF, - M_WAITOK); + isp = malloc(sizeof (struct intrsource), M_DEVBUF, M_WAITOK|M_ZERO); if (isp == NULL) panic("can't allocate fixed interrupt source"); - memset(isp, 0, sizeof(struct intrsource)); isp->is_recurse = Xsoftnet; isp->is_resume = Xsoftnet; fake_softnet_intrhand.ih_level = IPL_SOFTNET; isp->is_handlers = &fake_softnet_intrhand; isp->is_pic = &softintr_pic; ci->ci_isources[SIR_NET] = isp; - MALLOC(isp, struct intrsource *, sizeof (struct intrsource), M_DEVBUF, - M_WAITOK); + isp = malloc(sizeof (struct intrsource), M_DEVBUF, M_WAITOK|M_ZERO); if (isp == NULL) panic("can't allocate fixed interrupt source"); - memset(isp, 0, sizeof(struct intrsource)); isp->is_recurse = Xsoftserial; isp->is_resume = Xsoftserial; fake_softserial_intrhand.ih_level = IPL_SOFTSERIAL; @@ -594,11 +585,9 @@ cpu_intr_init(struct cpu_info *ci) isp->is_pic = &softintr_pic; ci->ci_isources[SIR_SERIAL] = isp; #if NLAPIC > 0 - MALLOC(isp, struct intrsource *, sizeof (struct intrsource), M_DEVBUF, - M_WAITOK); + isp = malloc(sizeof (struct intrsource), M_DEVBUF, M_WAITOK|M_ZERO); if (isp == NULL) panic("can't allocate fixed interrupt source"); - memset(isp, 0, sizeof(struct intrsource)); isp->is_recurse = Xrecurse_lapic_ltimer; isp->is_resume = Xresume_lapic_ltimer; fake_timer_intrhand.ih_level = IPL_CLOCK; @@ -606,11 +595,9 @@ cpu_intr_init(struct cpu_info *ci) isp->is_pic = &local_pic; ci->ci_isources[LIR_TIMER] = isp; #ifdef MULTIPROCESSOR - MALLOC(isp, struct intrsource *, sizeof (struct intrsource), M_DEVBUF, - M_WAITOK); + isp = malloc(sizeof (struct intrsource), M_DEVBUF, M_WAITOK|M_ZERO); if (isp == NULL) panic("can't allocate fixed interrupt source"); - memset(isp, 0, sizeof(struct intrsource)); isp->is_recurse = Xrecurse_lapic_ipi; isp->is_resume = Xresume_lapic_ipi; fake_ipi_intrhand.ih_level = IPL_IPI; diff --git a/sys/arch/amd64/amd64/mem.c b/sys/arch/amd64/amd64/mem.c index 8b868e5ac99..2fbcf0d1494 100644 --- a/sys/arch/amd64/amd64/mem.c +++ b/sys/arch/amd64/amd64/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.6 2007/01/15 23:19:05 jsg Exp $ */ +/* $OpenBSD: mem.c,v 1.7 2007/09/17 15:34:38 chl Exp $ */ /* * Copyright (c) 1988 University of Utah. * Copyright (c) 1982, 1986, 1990, 1993 @@ -162,11 +162,9 @@ mmrw(dev_t dev, struct uio *uio, int flags) c = iov->iov_len; break; } - if (zeropage == NULL) { + if (zeropage == NULL) zeropage = (caddr_t) - malloc(PAGE_SIZE, M_TEMP, M_WAITOK); - bzero(zeropage, PAGE_SIZE); - } + malloc(PAGE_SIZE, M_TEMP, M_WAITOK|M_ZERO); c = min(iov->iov_len, PAGE_SIZE); error = uiomove(zeropage, c, uio); continue; diff --git a/sys/arch/amd64/amd64/mpbios.c b/sys/arch/amd64/amd64/mpbios.c index dfd0ac7d5fb..ee0c7e2a7a6 100644 --- a/sys/arch/amd64/amd64/mpbios.c +++ b/sys/arch/amd64/amd64/mpbios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpbios.c,v 1.9 2007/01/15 23:19:05 jsg Exp $ */ +/* $OpenBSD: mpbios.c,v 1.10 2007/09/17 15:34:38 chl Exp $ */ /* $NetBSD: mpbios.c,v 1.7 2003/05/15 16:32:50 fvdl Exp $ */ /*- @@ -589,8 +589,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/amd64/isa/isa_machdep.c b/sys/arch/amd64/isa/isa_machdep.c index 29a42bc0cac..e28f9e81fe0 100644 --- a/sys/arch/amd64/isa/isa_machdep.c +++ b/sys/arch/amd64/isa/isa_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isa_machdep.c,v 1.12 2007/04/28 03:55:40 jsg Exp $ */ +/* $OpenBSD: isa_machdep.c,v 1.13 2007/09/17 15:34:38 chl Exp $ */ /* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */ #define ISA_DMA_STATS @@ -444,11 +444,11 @@ _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_ZERO) : (M_WAITOK|M_ZERO))) == NULL) { error = ENOMEM; goto out; } - bzero(cookiestore, cookiesize); cookie = (struct x86_isa_dma_cookie *)cookiestore; cookie->id_flags = cookieflags; map->_dm_cookie = cookie; diff --git a/sys/arch/amd64/pci/iommu.c b/sys/arch/amd64/pci/iommu.c index 12be8ffc510..7ff85ca8384 100644 --- a/sys/arch/amd64/pci/iommu.c +++ b/sys/arch/amd64/pci/iommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iommu.c,v 1.20 2007/05/27 21:44:23 jason Exp $ */ +/* $OpenBSD: iommu.c,v 1.21 2007/09/17 15:34:38 chl Exp $ */ /* * Copyright (c) 2005 Jason L. Wright (jason@thought.net) @@ -301,12 +301,11 @@ amdgart_probe(struct pcibus_attach_args *pba) goto err; } - scrib = malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT); + scrib = malloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT|M_ZERO); if (scrib == NULL) { printf("\nGART: didn't get scribble page"); goto err; } - bzero(scrib, PAGE_SIZE); for (count = 0, dev = 24; dev < 32; dev++) { for (func = 0; func < 8; func++) { |