diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2000-12-08 21:51:06 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2000-12-08 21:51:06 +0000 |
commit | dd75d1d73b4f3034c1d9f621a49fff58b1d71eb1 (patch) | |
tree | 197ae73617ae75afe008897f6906b84835589ea2 | |
parent | ed5dbfbd3cd619638a7baac288f548aa1398edac (diff) | |
download | FreeBSD-src-dd75d1d73b4f3034c1d9f621a49fff58b1d71eb1.zip FreeBSD-src-dd75d1d73b4f3034c1d9f621a49fff58b1d71eb1.tar.gz |
Convert more malloc+bzero to malloc+M_ZERO.
Submitted by: josh@zipperup.org
Submitted by: Robert Drehmel <robd@gmx.net>
158 files changed, 362 insertions, 601 deletions
diff --git a/sys/amd64/amd64/amd64_mem.c b/sys/amd64/amd64/amd64_mem.c index 9d49949..c3929bc 100644 --- a/sys/amd64/amd64/amd64_mem.c +++ b/sys/amd64/amd64/amd64_mem.c @@ -522,8 +522,7 @@ i686_mrinit(struct mem_range_softc *sc) sc->mr_desc = (struct mem_range_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/amd64/amd64/busdma_machdep.c b/sys/amd64/amd64/busdma_machdep.c index 63c4038..9f0f7c37b 100644 --- a/sys/amd64/amd64/busdma_machdep.c +++ b/sys/amd64/amd64/busdma_machdep.c @@ -250,14 +250,13 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) int maxpages; *mapp = (bus_dmamap_t)malloc(sizeof(**mapp), M_DEVBUF, - M_NOWAIT); - if (*mapp == NULL) { + M_NOWAIT | M_ZERO); + if (*mapp == NULL) return (ENOMEM); - } else { - /* Initialize the new map */ - bzero(*mapp, sizeof(**mapp)); - STAILQ_INIT(&((*mapp)->bpages)); - } + + /* Initialize the new map */ + STAILQ_INIT(&((*mapp)->bpages)); + /* * Attempt to add pages to our pool on a per-instance * basis up to a sane limit. @@ -551,11 +550,10 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages) int s; bpage = (struct bounce_page *)malloc(sizeof(*bpage), M_DEVBUF, - M_NOWAIT); + M_NOWAIT | M_ZERO); if (bpage == NULL) break; - bzero(bpage, sizeof(*bpage)); bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT, 0ul, dmat->lowaddr, diff --git a/sys/amd64/amd64/legacy.c b/sys/amd64/amd64/legacy.c index d648848..76c41ae 100644 --- a/sys/amd64/amd64/legacy.c +++ b/sys/amd64/amd64/legacy.c @@ -331,10 +331,9 @@ nexus_add_child(device_t bus, int order, const char *name, int unit) device_t child; struct nexus_device *ndev; - ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT); + ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT|M_ZERO); if (!ndev) return(0); - bzero(ndev, sizeof(struct nexus_device)); resource_list_init(&ndev->nx_resources); ndev->nx_pcibus = -1; diff --git a/sys/amd64/amd64/nexus.c b/sys/amd64/amd64/nexus.c index d648848..76c41ae 100644 --- a/sys/amd64/amd64/nexus.c +++ b/sys/amd64/amd64/nexus.c @@ -331,10 +331,9 @@ nexus_add_child(device_t bus, int order, const char *name, int unit) device_t child; struct nexus_device *ndev; - ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT); + ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT|M_ZERO); if (!ndev) return(0); - bzero(ndev, sizeof(struct nexus_device)); resource_list_init(&ndev->nx_resources); ndev->nx_pcibus = -1; diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 294a583..dcf4986 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -287,11 +287,10 @@ cpu_coredump(p, vp, cred) int error; caddr_t tempuser; - tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK); + tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK | M_ZERO); if (!tempuser) return EINVAL; - bzero(tempuser, ctob(UPAGES)); bcopy(p->p_addr, tempuser, sizeof(struct user)); bcopy(p->p_md.md_regs, tempuser + ((caddr_t) p->p_md.md_regs - (caddr_t) p->p_addr), diff --git a/sys/amd64/isa/intr_machdep.c b/sys/amd64/isa/intr_machdep.c index ffdcfc4..6f76185 100644 --- a/sys/amd64/isa/intr_machdep.c +++ b/sys/amd64/isa/intr_machdep.c @@ -546,10 +546,10 @@ inthand_add(const char *name, int irq, driver_intr_t handler, void *arg, if (ithd == NULL || ithd->it_ih == NULL) { /* first handler for this irq. */ if (ithd == NULL) { - ithd = malloc(sizeof (struct ithd), M_DEVBUF, M_WAITOK); + ithd = malloc(sizeof (struct ithd), M_DEVBUF, + M_WAITOK | M_ZERO); if (ithd == NULL) return (NULL); - bzero(ithd, sizeof(struct ithd)); ithd->irq = irq; ithds[irq] = ithd; } @@ -620,10 +620,9 @@ inthand_add(const char *name, int irq, driver_intr_t handler, void *arg, else strcat(p->p_comm, "+"); } - idesc = malloc(sizeof (struct intrhand), M_DEVBUF, M_WAITOK); + idesc = malloc(sizeof (struct intrhand), M_DEVBUF, M_WAITOK | M_ZERO); if (idesc == NULL) return (NULL); - bzero(idesc, sizeof (struct intrhand)); idesc->ih_handler = handler; idesc->ih_argument = arg; diff --git a/sys/amd64/isa/nmi.c b/sys/amd64/isa/nmi.c index ffdcfc4..6f76185 100644 --- a/sys/amd64/isa/nmi.c +++ b/sys/amd64/isa/nmi.c @@ -546,10 +546,10 @@ inthand_add(const char *name, int irq, driver_intr_t handler, void *arg, if (ithd == NULL || ithd->it_ih == NULL) { /* first handler for this irq. */ if (ithd == NULL) { - ithd = malloc(sizeof (struct ithd), M_DEVBUF, M_WAITOK); + ithd = malloc(sizeof (struct ithd), M_DEVBUF, + M_WAITOK | M_ZERO); if (ithd == NULL) return (NULL); - bzero(ithd, sizeof(struct ithd)); ithd->irq = irq; ithds[irq] = ithd; } @@ -620,10 +620,9 @@ inthand_add(const char *name, int irq, driver_intr_t handler, void *arg, else strcat(p->p_comm, "+"); } - idesc = malloc(sizeof (struct intrhand), M_DEVBUF, M_WAITOK); + idesc = malloc(sizeof (struct intrhand), M_DEVBUF, M_WAITOK | M_ZERO); if (idesc == NULL) return (NULL); - bzero(idesc, sizeof (struct intrhand)); idesc->ih_handler = handler; idesc->ih_argument = arg; diff --git a/sys/contrib/dev/oltr/if_oltr.c b/sys/contrib/dev/oltr/if_oltr.c index dd4f112..c6c0433 100644 --- a/sys/contrib/dev/oltr/if_oltr.c +++ b/sys/contrib/dev/oltr/if_oltr.c @@ -553,12 +553,11 @@ oltr_pci_attach(pcici_t config_id, int unit) s = splimp(); - sc = malloc(sizeof(struct oltr_softc), M_DEVBUF, M_NOWAIT); + sc = malloc(sizeof(struct oltr_softc), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc == NULL) { printf("oltr%d: no memory for softc struct!\n", unit); goto config_failed; } - bzero(sc, sizeof(struct oltr_softc)); sc->unit = unit; sc->state = OL_UNKNOWN; ifp = &sc->arpcom.ac_if; diff --git a/sys/dev/ar/if_ar.c b/sys/dev/ar/if_ar.c index dfbc3ac..9acc402 100644 --- a/sys/dev/ar/if_ar.c +++ b/sys/dev/ar/if_ar.c @@ -397,8 +397,7 @@ arattach_pci(int unit, vm_offset_t mem_addr) struct ar_hardc *hc; u_int i, tmp; - hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK); - bzero(hc, sizeof(struct ar_hardc)); + hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK | M_ZERO); hc->cunit = unit; hc->mem_start = (caddr_t)mem_addr; @@ -1139,11 +1138,10 @@ arc_init(struct ar_hardc *hc) u_int descneeded; u_char isr, mar; - MALLOC(sc, struct ar_softc *, - hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK); + MALLOC(sc, struct ar_softc *, hc->numports * sizeof(struct ar_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (sc == NULL) return; - bzero(sc, hc->numports * sizeof(struct ar_softc)); hc->sc = sc; hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET | @@ -2234,12 +2232,11 @@ ngar_rcvmsg(node_p node, struct ng_mesg *msg, int pos = 0; int resplen = sizeof(struct ng_mesg) + 512; MALLOC(*resp, struct ng_mesg *, resplen, - M_NETGRAPH, M_NOWAIT); + M_NETGRAPH, M_NOWAIT | M_ZERO); if (*resp == NULL) { error = ENOMEM; break; } - bzero(*resp, resplen); arg = (*resp)->data; /* diff --git a/sys/dev/ar/if_ar_isa.c b/sys/dev/ar/if_ar_isa.c index dfbc3ac..9acc402 100644 --- a/sys/dev/ar/if_ar_isa.c +++ b/sys/dev/ar/if_ar_isa.c @@ -397,8 +397,7 @@ arattach_pci(int unit, vm_offset_t mem_addr) struct ar_hardc *hc; u_int i, tmp; - hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK); - bzero(hc, sizeof(struct ar_hardc)); + hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK | M_ZERO); hc->cunit = unit; hc->mem_start = (caddr_t)mem_addr; @@ -1139,11 +1138,10 @@ arc_init(struct ar_hardc *hc) u_int descneeded; u_char isr, mar; - MALLOC(sc, struct ar_softc *, - hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK); + MALLOC(sc, struct ar_softc *, hc->numports * sizeof(struct ar_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (sc == NULL) return; - bzero(sc, hc->numports * sizeof(struct ar_softc)); hc->sc = sc; hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET | @@ -2234,12 +2232,11 @@ ngar_rcvmsg(node_p node, struct ng_mesg *msg, int pos = 0; int resplen = sizeof(struct ng_mesg) + 512; MALLOC(*resp, struct ng_mesg *, resplen, - M_NETGRAPH, M_NOWAIT); + M_NETGRAPH, M_NOWAIT | M_ZERO); if (*resp == NULL) { error = ENOMEM; break; } - bzero(*resp, resplen); arg = (*resp)->data; /* diff --git a/sys/dev/atkbdc/atkbd.c b/sys/dev/atkbdc/atkbd.c index de5d17f..b14cfdb 100644 --- a/sys/dev/atkbdc/atkbd.c +++ b/sys/dev/atkbdc/atkbd.c @@ -356,17 +356,14 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) fkeymap_size = sizeof(default_fkeytab)/sizeof(default_fkeytab[0]); } else if (*kbdp == NULL) { - *kbdp = kbd = malloc(sizeof(*kbd), M_DEVBUF, M_NOWAIT); - if (kbd == NULL) - return ENOMEM; - bzero(kbd, sizeof(*kbd)); - state = malloc(sizeof(*state), M_DEVBUF, M_NOWAIT); + *kbdp = kbd = malloc(sizeof(*kbd), M_DEVBUF, M_NOWAIT | M_ZERO); + state = malloc(sizeof(*state), M_DEVBUF, M_NOWAIT | M_ZERO); keymap = malloc(sizeof(key_map), M_DEVBUF, M_NOWAIT); accmap = malloc(sizeof(accent_map), M_DEVBUF, M_NOWAIT); fkeymap = malloc(sizeof(fkey_tab), M_DEVBUF, M_NOWAIT); fkeymap_size = sizeof(fkey_tab)/sizeof(fkey_tab[0]); - if ((state == NULL) || (keymap == NULL) || (accmap == NULL) - || (fkeymap == NULL)) { + if ((kbd == NULL) || (state == NULL) || (keymap == NULL) + || (accmap == NULL) || (fkeymap == NULL)) { if (state != NULL) free(state, M_DEVBUF); if (keymap != NULL) @@ -375,10 +372,10 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) free(accmap, M_DEVBUF); if (fkeymap != NULL) free(fkeymap, M_DEVBUF); - free(kbd, M_DEVBUF); + if (kbd == NULL) + free(kbd, M_DEVBUF); return ENOMEM; } - bzero(state, sizeof(*state)); } else if (KBD_IS_INITIALIZED(*kbdp) && KBD_IS_CONFIGURED(*kbdp)) { return 0; } else { diff --git a/sys/dev/atkbdc/atkbdc.c b/sys/dev/atkbdc/atkbdc.c index 7db3d8d..fdf5bf8 100644 --- a/sys/dev/atkbdc/atkbdc.c +++ b/sys/dev/atkbdc/atkbdc.c @@ -111,10 +111,9 @@ atkbdc_softc_t sc = atkbdc_softc[unit]; if (sc == NULL) { sc = atkbdc_softc[unit] - = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); + = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc == NULL) return NULL; - bzero(sc, sizeof(*sc)); } return sc; } diff --git a/sys/dev/atkbdc/atkbdc_isa.c b/sys/dev/atkbdc/atkbdc_isa.c index e8c3e4c..d99b648 100644 --- a/sys/dev/atkbdc/atkbdc_isa.c +++ b/sys/dev/atkbdc/atkbdc_isa.c @@ -146,10 +146,10 @@ atkbdc_add_device(device_t dev, const char *name, int unit) if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0) return; - kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT); + kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, + M_NOWAIT | M_ZERO); if (!kdev) return; - bzero(kdev, sizeof *kdev); if (resource_int_value(name, unit, "irq", &t) == 0) kdev->irq = t; diff --git a/sys/dev/atkbdc/atkbdc_subr.c b/sys/dev/atkbdc/atkbdc_subr.c index e8c3e4c..d99b648 100644 --- a/sys/dev/atkbdc/atkbdc_subr.c +++ b/sys/dev/atkbdc/atkbdc_subr.c @@ -146,10 +146,10 @@ atkbdc_add_device(device_t dev, const char *name, int unit) if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0) return; - kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT); + kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, + M_NOWAIT | M_ZERO); if (!kdev) return; - bzero(kdev, sizeof *kdev); if (resource_int_value(name, unit, "irq", &t) == 0) kdev->irq = t; diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c index 7b06a89..cdd07ce 100644 --- a/sys/dev/ccd/ccd.c +++ b/sys/dev/ccd/ccd.c @@ -598,8 +598,8 @@ ccdinterleave(cs, unit) * 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). diff --git a/sys/dev/cy/cy.c b/sys/dev/cy/cy.c index 4006807..18245e3 100644 --- a/sys/dev/cy/cy.c +++ b/sys/dev/cy/cy.c @@ -553,10 +553,9 @@ cyattach_common(cy_iobase, cy_align) struct com_s *com; int s; - com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT); + com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT | M_ZERO); if (com == NULL) break; - bzero(com, sizeof *com); com->unit = unit; com->gfrcr_image = firmware_version; if (CY_RTS_DTR_SWAPPED(firmware_version)) { diff --git a/sys/dev/cy/cy_isa.c b/sys/dev/cy/cy_isa.c index 4006807..18245e3 100644 --- a/sys/dev/cy/cy_isa.c +++ b/sys/dev/cy/cy_isa.c @@ -553,10 +553,9 @@ cyattach_common(cy_iobase, cy_align) struct com_s *com; int s; - com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT); + com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT | M_ZERO); if (com == NULL) break; - bzero(com, sizeof *com); com->unit = unit; com->gfrcr_image = firmware_version; if (CY_RTS_DTR_SWAPPED(firmware_version)) { diff --git a/sys/dev/eisa/eisaconf.c b/sys/dev/eisa/eisaconf.c index 1e9dcda..a781251 100644 --- a/sys/dev/eisa/eisaconf.c +++ b/sys/dev/eisa/eisaconf.c @@ -173,12 +173,11 @@ eisa_probe(device_t dev) /* Prepare an eisa_device_node for this slot */ e_dev = (struct eisa_device *)malloc(sizeof(*e_dev), - M_DEVBUF, M_NOWAIT); + M_DEVBUF, M_NOWAIT|M_ZERO); if (!e_dev) { device_printf(dev, "cannot malloc eisa_device"); break; /* Try to attach what we have already */ } - bzero(e_dev, sizeof(*e_dev)); e_dev->id = eisa_id; diff --git a/sys/dev/fb/fb.c b/sys/dev/fb/fb.c index 72d63d9..0c354c1 100644 --- a/sys/dev/fb/fb.c +++ b/sys/dev/fb/fb.c @@ -82,17 +82,16 @@ vid_realloc_array(void) s = spltty(); newsize = ((adapters + ARRAY_DELTA)/ARRAY_DELTA)*ARRAY_DELTA; - new_adp = malloc(sizeof(*new_adp)*newsize, M_DEVBUF, M_WAITOK); - new_vidsw = malloc(sizeof(*new_vidsw)*newsize, M_DEVBUF, M_WAITOK); + new_adp = malloc(sizeof(*new_adp)*newsize, M_DEVBUF, M_WAITOK | M_ZERO); + new_vidsw = malloc(sizeof(*new_vidsw)*newsize, M_DEVBUF, + M_WAITOK | M_ZERO); #ifdef FB_INSTALL_CDEV - new_cdevsw = malloc(sizeof(*new_cdevsw)*newsize, M_DEVBUF, M_WAITOK); + new_cdevsw = malloc(sizeof(*new_cdevsw)*newsize, M_DEVBUF, + M_WAITOK | M_ZERO); #endif - bzero(new_adp, sizeof(*new_adp)*newsize); - bzero(new_vidsw, sizeof(*new_vidsw)*newsize); bcopy(adapter, new_adp, sizeof(*adapter)*adapters); bcopy(vidsw, new_vidsw, sizeof(*vidsw)*adapters); #ifdef FB_INSTALL_CDEV - bzero(new_cdevsw, sizeof(*new_cdevsw)*newsize); bcopy(vidcdevsw, new_cdevsw, sizeof(*vidcdevsw)*adapters); #endif if (adapters > 1) { diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index e82bbd5..4fee4f5 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -818,10 +818,9 @@ fdc_add_child(device_t dev, const char *name, int unit) struct fdc_ivars *ivar; device_t child; - ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT); + ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT | M_ZERO); if (ivar == NULL) return; - bzero(ivar, sizeof *ivar); if (resource_int_value(name, unit, "drive", &ivar->fdunit) != 0) ivar->fdunit = 0; child = device_add_child(dev, name, unit); diff --git a/sys/dev/fxp/if_fxp.c b/sys/dev/fxp/if_fxp.c index 6544f56..13cd0fd 100644 --- a/sys/dev/fxp/if_fxp.c +++ b/sys/dev/fxp/if_fxp.c @@ -587,15 +587,14 @@ fxp_attach_common(sc, enaddr) DELAY(10); sc->cbl_base = malloc(sizeof(struct fxp_cb_tx) * FXP_NTXCB, - M_DEVBUF, M_NOWAIT); + M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->cbl_base == NULL) goto fail; - bzero(sc->cbl_base, sizeof(struct fxp_cb_tx) * FXP_NTXCB); - sc->fxp_stats = malloc(sizeof(struct fxp_stats), M_DEVBUF, M_NOWAIT); + sc->fxp_stats = malloc(sizeof(struct fxp_stats), M_DEVBUF, + M_NOWAIT | M_ZERO); if (sc->fxp_stats == NULL) goto fail; - bzero(sc->fxp_stats, sizeof(struct fxp_stats)); sc->mcsp = malloc(sizeof(struct fxp_cb_mcs), M_DEVBUF, M_NOWAIT); if (sc->mcsp == NULL) diff --git a/sys/dev/ida/ida.c b/sys/dev/ida/ida.c index 8b8d2a4..83396ae 100644 --- a/sys/dev/ida/ida.c +++ b/sys/dev/ida/ida.c @@ -191,10 +191,10 @@ ida_init(struct ida_softc *ida) bioq_init(&ida->bio_queue); ida->qcbs = (struct ida_qcb *) - malloc(IDA_QCB_MAX * sizeof(struct ida_qcb), M_DEVBUF, M_NOWAIT); + malloc(IDA_QCB_MAX * sizeof(struct ida_qcb), M_DEVBUF, + M_NOWAIT | M_ZERO); if (ida->qcbs == NULL) return (ENOMEM); - bzero(ida->qcbs, IDA_QCB_MAX * sizeof(struct ida_qcb)); /* * Create our DMA tags diff --git a/sys/dev/isp/isp_pci.c b/sys/dev/isp/isp_pci.c index 683ac4a..b559906 100644 --- a/sys/dev/isp/isp_pci.c +++ b/sys/dev/isp/isp_pci.c @@ -317,12 +317,11 @@ isp_pci_attach(device_t dev) } } - pcs = malloc(sizeof (struct isp_pcisoftc), M_DEVBUF, M_NOWAIT); + pcs = malloc(sizeof (struct isp_pcisoftc), M_DEVBUF, M_NOWAIT | M_ZERO); if (pcs == NULL) { device_printf(dev, "cannot allocate softc\n"); return (ENOMEM); } - bzero(pcs, sizeof (struct isp_pcisoftc)); /* * Figure out which we should try first - memory mapping or i/o mapping? @@ -443,12 +442,11 @@ isp_pci_attach(device_t dev) PCI_MBOX_REGS2100_OFF; } isp = &pcs->pci_isp; - isp->isp_param = malloc(psize, M_DEVBUF, M_NOWAIT); + isp->isp_param = malloc(psize, M_DEVBUF, M_NOWAIT | M_ZERO); if (isp->isp_param == NULL) { device_printf(dev, "cannot allocate parameter data\n"); goto bad; } - bzero(isp->isp_param, psize); isp->isp_mdvec = mdvp; isp->isp_type = basetype; isp->isp_revision = pci_get_revid(dev); @@ -850,12 +848,11 @@ isp_pci_mbxdma(struct ispsoftc *isp) } len = sizeof (XS_T **) * isp->isp_maxcmds; - isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK); + isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); if (isp->isp_xflist == NULL) { isp_prt(isp, ISP_LOGERR, "cannot alloc xflist array"); return (1); } - bzero(isp->isp_xflist, len); len = sizeof (bus_dmamap_t) * isp->isp_maxcmds; pci->dmaps = (bus_dmamap_t *) malloc(len, M_DEVBUF, M_WAITOK); if (pci->dmaps == NULL) { diff --git a/sys/dev/kbd/atkbd.c b/sys/dev/kbd/atkbd.c index de5d17f..b14cfdb 100644 --- a/sys/dev/kbd/atkbd.c +++ b/sys/dev/kbd/atkbd.c @@ -356,17 +356,14 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) fkeymap_size = sizeof(default_fkeytab)/sizeof(default_fkeytab[0]); } else if (*kbdp == NULL) { - *kbdp = kbd = malloc(sizeof(*kbd), M_DEVBUF, M_NOWAIT); - if (kbd == NULL) - return ENOMEM; - bzero(kbd, sizeof(*kbd)); - state = malloc(sizeof(*state), M_DEVBUF, M_NOWAIT); + *kbdp = kbd = malloc(sizeof(*kbd), M_DEVBUF, M_NOWAIT | M_ZERO); + state = malloc(sizeof(*state), M_DEVBUF, M_NOWAIT | M_ZERO); keymap = malloc(sizeof(key_map), M_DEVBUF, M_NOWAIT); accmap = malloc(sizeof(accent_map), M_DEVBUF, M_NOWAIT); fkeymap = malloc(sizeof(fkey_tab), M_DEVBUF, M_NOWAIT); fkeymap_size = sizeof(fkey_tab)/sizeof(fkey_tab[0]); - if ((state == NULL) || (keymap == NULL) || (accmap == NULL) - || (fkeymap == NULL)) { + if ((kbd == NULL) || (state == NULL) || (keymap == NULL) + || (accmap == NULL) || (fkeymap == NULL)) { if (state != NULL) free(state, M_DEVBUF); if (keymap != NULL) @@ -375,10 +372,10 @@ atkbd_init(int unit, keyboard_t **kbdp, void *arg, int flags) free(accmap, M_DEVBUF); if (fkeymap != NULL) free(fkeymap, M_DEVBUF); - free(kbd, M_DEVBUF); + if (kbd == NULL) + free(kbd, M_DEVBUF); return ENOMEM; } - bzero(state, sizeof(*state)); } else if (KBD_IS_INITIALIZED(*kbdp) && KBD_IS_CONFIGURED(*kbdp)) { return 0; } else { diff --git a/sys/dev/kbd/atkbdc.c b/sys/dev/kbd/atkbdc.c index 7db3d8d..fdf5bf8 100644 --- a/sys/dev/kbd/atkbdc.c +++ b/sys/dev/kbd/atkbdc.c @@ -111,10 +111,9 @@ atkbdc_softc_t sc = atkbdc_softc[unit]; if (sc == NULL) { sc = atkbdc_softc[unit] - = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); + = malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc == NULL) return NULL; - bzero(sc, sizeof(*sc)); } return sc; } diff --git a/sys/dev/kbd/kbd.c b/sys/dev/kbd/kbd.c index 3dc4861..777e6f1 100644 --- a/sys/dev/kbd/kbd.c +++ b/sys/dev/kbd/kbd.c @@ -80,19 +80,18 @@ kbd_realloc_array(void) s = spltty(); newsize = ((keyboards + ARRAY_DELTA)/ARRAY_DELTA)*ARRAY_DELTA; - new_kbd = malloc(sizeof(*new_kbd)*newsize, M_DEVBUF, M_NOWAIT); + new_kbd = malloc(sizeof(*new_kbd)*newsize, M_DEVBUF, M_NOWAIT|M_ZERO); if (new_kbd == NULL) { splx(s); return ENOMEM; } - new_kbdsw = malloc(sizeof(*new_kbdsw)*newsize, M_DEVBUF, M_NOWAIT); + new_kbdsw = malloc(sizeof(*new_kbdsw)*newsize, M_DEVBUF, + M_NOWAIT|M_ZERO); if (new_kbdsw == NULL) { free(new_kbd, M_DEVBUF); splx(s); return ENOMEM; } - bzero(new_kbd, sizeof(*new_kbd)*newsize); - bzero(new_kbdsw, sizeof(*new_kbdsw)*newsize); bcopy(keyboard, new_kbd, sizeof(*keyboard)*keyboards); bcopy(kbdsw, new_kbdsw, sizeof(*kbdsw)*keyboards); if (keyboards > 1) { diff --git a/sys/dev/lmc/if_lmc.c b/sys/dev/lmc/if_lmc.c index a6c91a9..cf220f7 100644 --- a/sys/dev/lmc/if_lmc.c +++ b/sys/dev/lmc/if_lmc.c @@ -1342,12 +1342,11 @@ ng_lmc_rcvmsg(node_p node, struct ng_mesg *msg, int pos = 0; int resplen = sizeof(struct ng_mesg) + 512; MALLOC(resp, struct ng_mesg *, resplen, M_NETGRAPH, - M_NOWAIT); + M_NOWAIT | M_ZERO); if (resp == NULL) { error = ENOMEM; break; } - bzero(resp, resplen); arg = (resp)->data; /* diff --git a/sys/dev/lmc/if_lmc_fbsd3.c b/sys/dev/lmc/if_lmc_fbsd3.c index ce7c947..f6f9bf9 100644 --- a/sys/dev/lmc/if_lmc_fbsd3.c +++ b/sys/dev/lmc/if_lmc_fbsd3.c @@ -137,10 +137,9 @@ lmc_pci_attach(pcici_t config_id, int unit) /* * allocate memory for the softc */ - sc = (lmc_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); + sc = (lmc_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc == NULL) return; - bzero(sc, sizeof(*sc)); /* Zero out the softc*/ revinfo = PCI_CONF_READ(PCI_CFRV) & 0xFF; id = PCI_CONF_READ(PCI_CFID); diff --git a/sys/dev/lnc/if_lnc_pci.c b/sys/dev/lnc/if_lnc_pci.c index 2c49264..c69716d 100644 --- a/sys/dev/lnc/if_lnc_pci.c +++ b/sys/dev/lnc/if_lnc_pci.c @@ -104,11 +104,9 @@ lnc_pci_attach(config_id, unit) data |= PCIM_CMD_PORTEN | PCIM_CMD_BUSMASTEREN; pci_cfgwrite(config_id, PCIR_COMMAND, data, 4); - sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT); + sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT | M_ZERO); if (sc) { - bzero (sc, sizeof *sc); - sc->rap = iobase + PCNET_RAP; sc->rdp = iobase + PCNET_RDP; sc->bdp = iobase + PCNET_BDP; diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 9314af8..170ed72 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -257,8 +257,7 @@ mdstrategy_malloc(struct bio *bp) *secpp = (u_char *)(uintptr_t)uc; } else { if (!secpp) { - MALLOC(secpp, u_char **, (secno + nsec + 1) * sizeof(u_char *), M_MD, M_WAITOK); - bzero(secpp, (secno + nsec + 1) * sizeof(u_char *)); + MALLOC(secpp, u_char **, (secno + nsec + 1) * sizeof(u_char *), M_MD, M_WAITOK | M_ZERO); bcopy(sc->secp, secpp, sc->nsecp * sizeof(u_char *)); FREE(sc->secp, M_MD); sc->secp = secpp; @@ -356,8 +355,7 @@ mdcreate(int unit) if (sc->unit == unit) return (NULL); } - MALLOC(sc, struct md_s *,sizeof(*sc), M_MD, M_WAITOK); - bzero(sc, sizeof(*sc)); + MALLOC(sc, struct md_s *,sizeof(*sc), M_MD, M_WAITOK | M_ZERO); LIST_INSERT_HEAD(&md_softc_list, sc, list); sc->unit = unit; bioq_init(&sc->bio_queue); @@ -397,8 +395,7 @@ mdcreate_malloc(int unit) sc->type = MD_MALLOC; sc->nsect = MD_NSECT; /* for now */ - MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK); - bzero(sc->secp, sizeof(u_char *)); + MALLOC(sc->secp, u_char **, sizeof(u_char *), M_MD, M_WAITOK | M_ZERO); sc->nsecp = 1; printf("md%d: Malloc disk\n", sc->unit); } diff --git a/sys/dev/musycc/musycc.c b/sys/dev/musycc/musycc.c index 76ed767..fa11689 100644 --- a/sys/dev/musycc/musycc.c +++ b/sys/dev/musycc/musycc.c @@ -1012,8 +1012,7 @@ musycc_newhook(node_p node, hook_p hook, const char *name) return (EINVAL); if (sc->chan[chan] == NULL) { - MALLOC(sch, struct schan *, sizeof(*sch), M_MUSYCC, M_WAITOK); - bzero(sch, sizeof(*sch)); + MALLOC(sch, struct schan *, sizeof(*sch), M_MUSYCC, M_WAITOK | M_ZERO); sch->sc = sc; sch->state = DOWN; sch->chan = chan; @@ -1340,8 +1339,7 @@ musycc_attach(device_t self) f = pci_get_function(self); /* For function zero allocate a csoftc */ if (f == 0) { - MALLOC(csc, struct csoftc *, sizeof(*csc), M_MUSYCC, M_WAITOK); - bzero(csc, sizeof(*csc)); + MALLOC(csc, struct csoftc *, sizeof(*csc), M_MUSYCC, M_WAITOK | M_ZERO); csc->bus = pci_get_bus(self); csc->slot = pci_get_slot(self); LIST_INSERT_HEAD(&sc_list, csc, list); @@ -1415,8 +1413,7 @@ musycc_attach(device_t self) sc->reg = (struct globalr *) (csc->virbase[0] + i * 0x800); MALLOC(sc->mycg, struct mycg *, - sizeof(struct mycg), M_MUSYCC, M_WAITOK); - bzero(sc->mycg, sizeof(struct mycg)); + sizeof(struct mycg), M_MUSYCC, M_WAITOK | M_ZERO); sc->ram = &sc->mycg->cg; error = ng_make_node_common(&ngtypestruct, &sc->node); diff --git a/sys/dev/null/null.c b/sys/dev/null/null.c index 865ee5c..4ec97a9 100644 --- a/sys/dev/null/null.c +++ b/sys/dev/null/null.c @@ -112,8 +112,7 @@ null_modevent(module_t mod, int type, void *data) case MOD_LOAD: if (bootverbose) printf("null: <null device, zero device>\n"); - zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK); - bzero(zbuf, PAGE_SIZE); + zbuf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK | M_ZERO); zero_dev = make_dev(&zero_cdevsw, ZERO_MINOR, UID_ROOT, GID_WHEEL, 0666, "zero"); null_dev = make_dev(&null_cdevsw, NULL_MINOR, UID_ROOT, diff --git a/sys/dev/pdq/if_fpa.c b/sys/dev/pdq/if_fpa.c index d70628a..a5eea3c 100644 --- a/sys/dev/pdq/if_fpa.c +++ b/sys/dev/pdq/if_fpa.c @@ -169,11 +169,10 @@ pdq_pci_attach( pci_conf_write(config_id, PCI_CFLT, data); } - sc = (pdq_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT); + sc = (pdq_softc_t *) malloc(sizeof(*sc), M_DEVBUF, M_NOWAIT | M_ZERO); if (sc == NULL) return; - bzero(sc, sizeof(pdq_softc_t)); /* Zero out the softc*/ if (!pci_map_mem(config_id, PCI_CBMA, &va_csrs, &pa_csrs)) { free((void *) sc, M_DEVBUF); return; diff --git a/sys/dev/ppbus/ppbconf.c b/sys/dev/ppbus/ppbconf.c index 6f6bf95..b494405 100644 --- a/sys/dev/ppbus/ppbconf.c +++ b/sys/dev/ppbus/ppbconf.c @@ -86,10 +86,10 @@ ppbus_add_child(device_t dev, int order, const char *name, int unit) device_t child; /* allocate ivars for the new ppbus child */ - ppbdev = malloc(sizeof(struct ppb_device), M_PPBUSDEV, M_NOWAIT); + ppbdev = malloc(sizeof(struct ppb_device), M_PPBUSDEV, + M_NOWAIT | M_ZERO); if (!ppbdev) return NULL; - bzero(ppbdev, sizeof *ppbdev); /* initialize the ivars */ ppbdev->name = name; diff --git a/sys/dev/ppbus/vpo.c b/sys/dev/ppbus/vpo.c index fafc3f1..1c409d5 100644 --- a/sys/dev/ppbus/vpo.c +++ b/sys/dev/ppbus/vpo.c @@ -186,9 +186,7 @@ static void vpo_cam_rescan(struct vpo_data *vpo) { struct cam_path *path; - union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK); - - bzero(ccb, sizeof(union ccb)); + union ccb *ccb = malloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO); if (xpt_create_path(&path, xpt_periph, cam_sim_path(vpo->sim), 0, 0) != CAM_REQ_CMP) { diff --git a/sys/dev/rp/rp.c b/sys/dev/rp/rp.c index a12110e..d3a3399 100644 --- a/sys/dev/rp/rp.c +++ b/sys/dev/rp/rp.c @@ -831,25 +831,24 @@ rp_attachcommon(CONTROLLER_T *ctlp, int num_aiops, int num_ports) bzero(rp, sizeof(struct rp_port) * num_ports); ctlp->tty = tty = (struct tty *) - malloc(sizeof(struct tty) * num_ports, M_TTYS, M_NOWAIT); + malloc(sizeof(struct tty) * num_ports, M_TTYS, + M_NOWAIT | M_ZERO); if(tty == NULL) { device_printf(ctlp->dev, "rp_attachcommon: Could not malloc tty structures.\n"); retval = ENOMEM; goto nogo; } - bzero(tty, sizeof(struct tty) * num_ports); oldspl = spltty(); rp_addr(unit) = rp; splx(oldspl); - dev_nodes = ctlp->dev_nodes = malloc(sizeof(*(ctlp->dev_nodes)) * rp_num_ports[unit] * 6, M_DEVBUF, M_NOWAIT); + dev_nodes = ctlp->dev_nodes = malloc(sizeof(*(ctlp->dev_nodes)) * rp_num_ports[unit] * 6, M_DEVBUF, M_NOWAIT | M_ZERO); if(ctlp->dev_nodes == NULL) { device_printf(ctlp->dev, "rp_attachcommon: Could not malloc device node structures.\n"); retval = ENOMEM; goto nogo; } - bzero(dev_nodes, sizeof(*(ctlp->dev_nodes)) * rp_num_ports[unit] * 6); for (i = 0 ; i < rp_num_ports[unit] ; i++) { *(dev_nodes++) = make_dev(&rp_cdevsw, ((unit + 1) << 16) | i, diff --git a/sys/dev/rp/rp_isa.c b/sys/dev/rp/rp_isa.c index 0dc001b..bbbdcb2 100644 --- a/sys/dev/rp/rp_isa.c +++ b/sys/dev/rp/rp_isa.c @@ -173,23 +173,20 @@ rp_probe(device_t dev) /* The IO ports of AIOPs for an ISA controller are discrete. */ ctlp->io_num = 1; - ctlp->io_rid = malloc(sizeof(*(ctlp->io_rid)) * MAX_AIOPS_PER_BOARD, M_DEVBUF, M_NOWAIT); - ctlp->io = malloc(sizeof(*(ctlp->io)) * MAX_AIOPS_PER_BOARD, M_DEVBUF, M_NOWAIT); + ctlp->io_rid = malloc(sizeof(*(ctlp->io_rid)) * MAX_AIOPS_PER_BOARD, M_DEVBUF, M_NOWAIT | M_ZERO); + ctlp->io = malloc(sizeof(*(ctlp->io)) * MAX_AIOPS_PER_BOARD, M_DEVBUF, M_NOWAIT | M_ZERO); if (ctlp->io_rid == NULL || ctlp->io == NULL) { device_printf(dev, "rp_attach: Out of memory.\n"); retval = ENOMEM; goto nogo; } - bzero(ctlp->io_rid, sizeof(*(ctlp->io_rid)) * MAX_AIOPS_PER_BOARD); - bzero(ctlp->io, sizeof(*(ctlp->io)) * MAX_AIOPS_PER_BOARD); - ctlp->bus_ctlp = malloc(sizeof(ISACONTROLLER_t) * 1, M_DEVBUF, M_NOWAIT); + ctlp->bus_ctlp = malloc(sizeof(ISACONTROLLER_t) * 1, M_DEVBUF, M_NOWAIT | M_ZERO); if (ctlp->bus_ctlp == NULL) { device_printf(dev, "rp_attach: Out of memory.\n"); retval = ENOMEM; goto nogo; } - bzero(ctlp->bus_ctlp, sizeof(ISACONTROLLER_t) * 1); ctlp->io_rid[0] = 0; if (rp_controller != NULL) { diff --git a/sys/dev/rp/rp_pci.c b/sys/dev/rp/rp_pci.c index 7f2d60c..fa25dea 100644 --- a/sys/dev/rp/rp_pci.c +++ b/sys/dev/rp/rp_pci.c @@ -165,15 +165,13 @@ rp_pciattach(device_t dev) /* The IO ports of AIOPs for a PCI controller are continuous. */ ctlp->io_num = 1; - ctlp->io_rid = malloc(sizeof(*(ctlp->io_rid)) * ctlp->io_num, M_DEVBUF, M_NOWAIT); - ctlp->io = malloc(sizeof(*(ctlp->io)) * ctlp->io_num, M_DEVBUF, M_NOWAIT); + ctlp->io_rid = malloc(sizeof(*(ctlp->io_rid)) * ctlp->io_num, M_DEVBUF, M_NOWAIT | M_ZERO); + ctlp->io = malloc(sizeof(*(ctlp->io)) * ctlp->io_num, M_DEVBUF, M_NOWAIT | M_ZERO); if (ctlp->io_rid == NULL || ctlp->io == NULL) { device_printf(dev, "rp_pciattach: Out of memory.\n"); retval = ENOMEM; goto nogo; } - bzero(ctlp->io_rid, sizeof(*(ctlp->io_rid)) * ctlp->io_num); - bzero(ctlp->io, sizeof(*(ctlp->io)) * ctlp->io_num); ctlp->bus_ctlp = NULL; diff --git a/sys/dev/si/si.c b/sys/dev/si/si.c index 28e6a42..cc61a17 100644 --- a/sys/dev/si/si.c +++ b/sys/dev/si/si.c @@ -497,23 +497,22 @@ try_next: (maddr + (unsigned)(modp->sm_next & 0x7fff)); } sc->sc_ports = (struct si_port *)malloc(sizeof(struct si_port) * nport, - M_DEVBUF, M_NOWAIT); + M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->sc_ports == 0) { mem_fail: printf("si%d: fail to malloc memory for port structs\n", unit); return EINVAL; } - bzero(sc->sc_ports, sizeof(struct si_port) * nport); sc->sc_nport = nport; /* * allocate tty structures for ports */ - tp = (struct tty *)malloc(sizeof(*tp) * nport, M_DEVBUF, M_NOWAIT); + tp = (struct tty *)malloc(sizeof(*tp) * nport, M_DEVBUF, + M_NOWAIT | M_ZERO); if (tp == 0) goto mem_fail; - bzero(tp, sizeof(*tp) * nport); si__tty = tp; /* diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 9950513..b448e30 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -291,8 +291,7 @@ snpopen(dev, flag, mode, p) if (dev->si_drv1 == NULL) { int mynor = minor(dev); - dev->si_drv1 = snp = malloc(sizeof(*snp), M_SNP, M_WAITOK); - bzero(snp, sizeof(*snp)); + dev->si_drv1 = snp = malloc(sizeof(*snp), M_SNP, M_WAITOK|M_ZERO); make_dev(&snp_cdevsw, mynor, 0, 0, 0600, "snp%d", mynor); } else return (EBUSY); diff --git a/sys/dev/sr/if_sr.c b/sys/dev/sr/if_sr.c index 89b2c99..b27d2f5 100644 --- a/sys/dev/sr/if_sr.c +++ b/sys/dev/sr/if_sr.c @@ -659,10 +659,10 @@ srattach_isa(struct isa_device *id) * Allocate the software interface table(s) */ MALLOC(hc->sc, struct sr_softc *, - hc->numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK); + hc->numports * sizeof(struct sr_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (hc->sc == NULL) return(0); - bzero(hc->sc, hc->numports * sizeof(struct sr_softc)); id->id_ointr = srintr; @@ -768,18 +768,16 @@ srattach_pci(int unit, vm_offset_t plx_vaddr, vm_offset_t sca_vaddr) hc = hc->next; } - MALLOC(hc, struct sr_hardc *, sizeof(*hc), M_DEVBUF, M_WAITOK); + MALLOC(hc, struct sr_hardc *, sizeof(*hc), M_DEVBUF, M_WAITOK | M_ZERO); if (hc == NULL) return NULL; - bzero(hc, sizeof(*hc)); - MALLOC(hc->sc, struct sr_softc *, - numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK); + MALLOC(hc->sc, struct sr_softc *, numports * sizeof(struct sr_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (hc->sc == NULL) { FREE(hc, M_DEVBUF); return NULL; } - bzero(hc->sc, numports * sizeof(struct sr_softc)); *hcp = hc; hc->numports = numports; @@ -3188,12 +3186,11 @@ ngsr_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr, int pos = 0; int resplen = sizeof(struct ng_mesg) + 512; MALLOC(*resp, struct ng_mesg *, resplen, - M_NETGRAPH, M_NOWAIT); + M_NETGRAPH, M_NOWAIT | M_ZERO); if (*resp == NULL) { error = ENOMEM; break; } - bzero(*resp, resplen); arg = (*resp)->data; /* diff --git a/sys/dev/sr/if_sr_isa.c b/sys/dev/sr/if_sr_isa.c index 89b2c99..b27d2f5 100644 --- a/sys/dev/sr/if_sr_isa.c +++ b/sys/dev/sr/if_sr_isa.c @@ -659,10 +659,10 @@ srattach_isa(struct isa_device *id) * Allocate the software interface table(s) */ MALLOC(hc->sc, struct sr_softc *, - hc->numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK); + hc->numports * sizeof(struct sr_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (hc->sc == NULL) return(0); - bzero(hc->sc, hc->numports * sizeof(struct sr_softc)); id->id_ointr = srintr; @@ -768,18 +768,16 @@ srattach_pci(int unit, vm_offset_t plx_vaddr, vm_offset_t sca_vaddr) hc = hc->next; } - MALLOC(hc, struct sr_hardc *, sizeof(*hc), M_DEVBUF, M_WAITOK); + MALLOC(hc, struct sr_hardc *, sizeof(*hc), M_DEVBUF, M_WAITOK | M_ZERO); if (hc == NULL) return NULL; - bzero(hc, sizeof(*hc)); - MALLOC(hc->sc, struct sr_softc *, - numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK); + MALLOC(hc->sc, struct sr_softc *, numports * sizeof(struct sr_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (hc->sc == NULL) { FREE(hc, M_DEVBUF); return NULL; } - bzero(hc->sc, numports * sizeof(struct sr_softc)); *hcp = hc; hc->numports = numports; @@ -3188,12 +3186,11 @@ ngsr_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr, int pos = 0; int resplen = sizeof(struct ng_mesg) + 512; MALLOC(*resp, struct ng_mesg *, resplen, - M_NETGRAPH, M_NOWAIT); + M_NETGRAPH, M_NOWAIT | M_ZERO); if (*resp == NULL) { error = ENOMEM; break; } - bzero(*resp, resplen); arg = (*resp)->data; /* diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c index d622613..a1137ff 100644 --- a/sys/dev/syscons/syscons.c +++ b/sys/dev/syscons/syscons.c @@ -2541,8 +2541,7 @@ scinit(int unit, int flags) kernel_default.rev_color); } else { /* assert(sc_malloc) */ - sc->dev = malloc(sizeof(dev_t)*sc->vtys, M_DEVBUF, M_WAITOK); - bzero(sc->dev, sizeof(dev_t)*sc->vtys); + sc->dev = malloc(sizeof(dev_t)*sc->vtys, M_DEVBUF, M_WAITOK|M_ZERO); sc->dev[0] = makedev(CDEV_MAJOR, unit*MAXCONS); sc->dev[0]->si_tty = ttymalloc(sc->dev[0]->si_tty); scp = alloc_scp(sc, sc->first_vty); diff --git a/sys/dev/tx/if_tx.c b/sys/dev/tx/if_tx.c index 0080611..ca2a89d 100644 --- a/sys/dev/tx/if_tx.c +++ b/sys/dev/tx/if_tx.c @@ -747,13 +747,12 @@ epic_common_attach(sc) i = sizeof(struct epic_frag_list)*TX_RING_SIZE + sizeof(struct epic_rx_desc)*RX_RING_SIZE + sizeof(struct epic_tx_desc)*TX_RING_SIZE + PAGE_SIZE, - sc->pool = (epic_softc_t *) malloc( i, M_DEVBUF, M_NOWAIT); + sc->pool = (epic_softc_t *) malloc(i, M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->pool == NULL) { printf(": can't allocate memory for buffers\n"); return -1; } - bzero(sc->pool, i); /* Align pool on PAGE_SIZE */ pool = (caddr_t)sc->pool; diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c index 217ed9e..96c861e 100644 --- a/sys/dev/vn/vn.c +++ b/sys/dev/vn/vn.c @@ -182,10 +182,9 @@ vnfindvn(dev_t dev) } } if (!vn) { - vn = malloc(sizeof *vn, M_DEVBUF, M_WAITOK); + vn = malloc(sizeof *vn, M_DEVBUF, M_WAITOK | M_ZERO); if (!vn) return (NULL); - bzero(vn, sizeof *vn); vn->sc_unit = unit; dev->si_drv1 = vn; make_dev(&vn_cdevsw, diff --git a/sys/fs/cd9660/cd9660_vfsops.c b/sys/fs/cd9660/cd9660_vfsops.c index 49e6169..aaefb78 100644 --- a/sys/fs/cd9660/cd9660_vfsops.c +++ b/sys/fs/cd9660/cd9660_vfsops.c @@ -401,8 +401,7 @@ iso_mountfs(devvp, mp, p, argp) pri_sierra->root_directory_record: pri->root_directory_record); - isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK); - bzero((caddr_t)isomp, sizeof *isomp); + isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK | M_ZERO); isomp->logical_block_size = logical_block_size; isomp->volume_space_size = isonum_733 (high_sierra? @@ -723,8 +722,7 @@ cd9660_vget_internal(mp, ino, vpp, relocated, isodir) return (error); } MALLOC(ip, struct iso_node *, sizeof(struct iso_node), M_ISOFSNODE, - M_WAITOK); - bzero((caddr_t)ip, sizeof(struct iso_node)); + M_WAITOK | M_ZERO); lockinit(&vp->v_lock, PINOD, "isonode", 0, 0); /* * ISOFS uses stdlock and can share lock structure diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index ee4697d..bb6b316 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -149,15 +149,13 @@ devfs_attemptoverflow(int insist) or = NULL; n = devfs_noverflowwant; nb = sizeof (struct dev_t *) * n; - MALLOC(ot, dev_t **, nb, M_DEVFS, insist ? M_WAITOK : M_NOWAIT); + MALLOC(ot, dev_t **, nb, M_DEVFS, (insist ? M_WAITOK : M_NOWAIT) | M_ZERO); if (ot == NULL) goto bail; - bzero(ot, nb); nb = sizeof (int) * n; - MALLOC(or, int *, nb, M_DEVFS, insist ? M_WAITOK : M_NOWAIT); + MALLOC(or, int *, nb, M_DEVFS, (insist ? M_WAITOK : M_NOWAIT) | M_ZERO); if (or == NULL) goto bail; - bzero(or, nb); if (!atomic_cmpset_ptr(&devfs_overflow, NULL, ot)) goto bail; devfs_refoverflow = or; @@ -198,8 +196,7 @@ devfs_newdirent(char *name, int namelen) d.d_namlen = namelen; i = sizeof (*de) + GENERIC_DIRSIZ(&d); - MALLOC(de, struct devfs_dirent *, i, M_DEVFS, M_WAITOK); - bzero(de, i); + MALLOC(de, struct devfs_dirent *, i, M_DEVFS, M_WAITOK | M_ZERO); de->de_dirent = (struct dirent *)(de + 1); de->de_dirent->d_namlen = namelen; de->de_dirent->d_reclen = GENERIC_DIRSIZ(&d); @@ -287,8 +284,7 @@ devfs_populate(struct devfs_mount *dm) if (devfs_noverflow && dm->dm_overflow == NULL) { i = devfs_noverflow * sizeof (struct devfs_dirent *); MALLOC(dm->dm_overflow, struct devfs_dirent **, i, - M_DEVFS, M_WAITOK); - bzero(dm->dm_overflow, i); + M_DEVFS, M_WAITOK | M_ZERO); } while (dm->dm_generation != devfs_generation) { dm->dm_generation = devfs_generation; diff --git a/sys/fs/devfs/devfs_vfsops.c b/sys/fs/devfs/devfs_vfsops.c index 1ff3955..eb13d8f 100644 --- a/sys/fs/devfs/devfs_vfsops.c +++ b/sys/fs/devfs/devfs_vfsops.c @@ -79,8 +79,7 @@ devfs_mount(mp, path, data, ndp, p) return (EOPNOTSUPP); MALLOC(fmp, struct devfs_mount *, sizeof(struct devfs_mount), - M_DEVFS, M_WAITOK); - bzero(fmp, sizeof(*fmp)); + M_DEVFS, M_WAITOK | M_ZERO); lockinit(&fmp->dm_lock, PVFS, "devfs", 0, LK_NOPAUSE); mp->mnt_flag |= MNT_LOCAL; diff --git a/sys/fs/hpfs/hpfs_vfsops.c b/sys/fs/hpfs/hpfs_vfsops.c index a5be4d8..628ec25 100644 --- a/sys/fs/hpfs/hpfs_vfsops.c +++ b/sys/fs/hpfs/hpfs_vfsops.c @@ -371,8 +371,7 @@ hpfs_mountfs(devvp, mp, argsp, p) /* * Do actual mount */ - hpmp = malloc(sizeof(struct hpfsmount), M_HPFSMNT, M_WAITOK); - bzero(hpmp, sizeof(struct hpfsmount)); + hpmp = malloc(sizeof(struct hpfsmount), M_HPFSMNT, M_WAITOK | M_ZERO); /* Read in SuperBlock */ error = bread(devvp, SUBLOCK, SUSIZE, NOCRED, &bp); diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 823eb36..30b5522 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -176,8 +176,7 @@ msdosfs_mountroot() if (bdevvp(rootdev, &rootvp)) panic("msdosfs_mountroot: can't setup rootvp"); - mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); - bzero((char *)mp, (u_long)sizeof(struct mount)); + mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); mp->mnt_op = &msdosfs_vfsops; mp->mnt_flag = 0; LIST_INIT(&mp->mnt_vnodelist); @@ -464,8 +463,7 @@ mountmsdosfs(devvp, mp, p, argp) } #endif - pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK); - bzero((caddr_t)pmp, sizeof *pmp); + pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK | M_ZERO); pmp->pm_mountp = mp; /* diff --git a/sys/fs/ntfs/ntfs_subr.c b/sys/fs/ntfs/ntfs_subr.c index 839f752..d9b38d4 100644 --- a/sys/fs/ntfs/ntfs_subr.c +++ b/sys/fs/ntfs/ntfs_subr.c @@ -394,10 +394,9 @@ ntfs_ntlookup( } } while (LOCKMGR(&ntfs_hashlock, LK_EXCLUSIVE | LK_SLEEPFAIL, NULL)); - MALLOC(ip, struct ntnode *, sizeof(struct ntnode), - M_NTFSNTNODE, M_WAITOK); + MALLOC(ip, struct ntnode *, sizeof(struct ntnode), M_NTFSNTNODE, + M_WAITOK | M_ZERO); ddprintf(("ntfs_ntlookup: allocating ntnode: %d: %p\n", ino, ip)); - bzero((caddr_t) ip, sizeof(struct ntnode)); /* Generic initialization */ ip->i_devvp = ntmp->ntm_devvp; @@ -544,8 +543,7 @@ ntfs_attrtontvattr( *rvapp = NULL; MALLOC(vap, struct ntvattr *, sizeof(struct ntvattr), - M_NTFSNTVATTR, M_WAITOK); - bzero(vap, sizeof(struct ntvattr)); + M_NTFSNTVATTR, M_WAITOK | M_ZERO); vap->va_ip = NULL; vap->va_flag = rap->a_hdr.a_flag; vap->va_type = rap->a_hdr.a_type; @@ -737,8 +735,8 @@ ntfs_fget( if (*fpp) return (0); - MALLOC(fp, struct fnode *, sizeof(struct fnode), M_NTFSFNODE, M_WAITOK); - bzero(fp, sizeof(struct fnode)); + MALLOC(fp, struct fnode *, sizeof(struct fnode), M_NTFSFNODE, + M_WAITOK | M_ZERO); dprintf(("ntfs_fget: allocating fnode: %p\n",fp)); fp->f_ip = ip; diff --git a/sys/fs/ntfs/ntfs_vfsops.c b/sys/fs/ntfs/ntfs_vfsops.c index e5a0216..7c6b2c0 100644 --- a/sys/fs/ntfs/ntfs_vfsops.c +++ b/sys/fs/ntfs/ntfs_vfsops.c @@ -478,8 +478,7 @@ ntfs_mountfs(devvp, mp, argsp, p) error = bread(devvp, BBLOCK, BBSIZE, NOCRED, &bp); if (error) goto out; - ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK ); - bzero( ntmp, sizeof *ntmp ); + ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK | M_ZERO); bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) ); brelse( bp ); bp = NULL; diff --git a/sys/fs/unionfs/union_vfsops.c b/sys/fs/unionfs/union_vfsops.c index 57a4e98..94cba85 100644 --- a/sys/fs/unionfs/union_vfsops.c +++ b/sys/fs/unionfs/union_vfsops.c @@ -179,9 +179,7 @@ union_mount(mp, path, data, ndp, p) */ um = (struct union_mount *) malloc(sizeof(struct union_mount), - M_UNIONFSMNT, M_WAITOK); - - bzero(um, sizeof(struct union_mount)); + M_UNIONFSMNT, M_WAITOK | M_ZERO); um->um_op = args.mntflags & UNMNT_OPMASK; diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index 7b06a89..cdd07ce 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -598,8 +598,8 @@ ccdinterleave(cs, unit) * 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). diff --git a/sys/i386/i386/busdma_machdep.c b/sys/i386/i386/busdma_machdep.c index 63c4038..9f0f7c37b 100644 --- a/sys/i386/i386/busdma_machdep.c +++ b/sys/i386/i386/busdma_machdep.c @@ -250,14 +250,13 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) int maxpages; *mapp = (bus_dmamap_t)malloc(sizeof(**mapp), M_DEVBUF, - M_NOWAIT); - if (*mapp == NULL) { + M_NOWAIT | M_ZERO); + if (*mapp == NULL) return (ENOMEM); - } else { - /* Initialize the new map */ - bzero(*mapp, sizeof(**mapp)); - STAILQ_INIT(&((*mapp)->bpages)); - } + + /* Initialize the new map */ + STAILQ_INIT(&((*mapp)->bpages)); + /* * Attempt to add pages to our pool on a per-instance * basis up to a sane limit. @@ -551,11 +550,10 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages) int s; bpage = (struct bounce_page *)malloc(sizeof(*bpage), M_DEVBUF, - M_NOWAIT); + M_NOWAIT | M_ZERO); if (bpage == NULL) break; - bzero(bpage, sizeof(*bpage)); bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT, 0ul, dmat->lowaddr, diff --git a/sys/i386/i386/i686_mem.c b/sys/i386/i386/i686_mem.c index 9d49949..c3929bc 100644 --- a/sys/i386/i386/i686_mem.c +++ b/sys/i386/i386/i686_mem.c @@ -522,8 +522,7 @@ i686_mrinit(struct mem_range_softc *sc) sc->mr_desc = (struct mem_range_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/i386/i386/k6_mem.c b/sys/i386/i386/k6_mem.c index 48af3dd..00f9b7f 100644 --- a/sys/i386/i386/k6_mem.c +++ b/sys/i386/i386/k6_mem.c @@ -100,10 +100,9 @@ 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++) { diff --git a/sys/i386/i386/legacy.c b/sys/i386/i386/legacy.c index d648848..76c41ae 100644 --- a/sys/i386/i386/legacy.c +++ b/sys/i386/i386/legacy.c @@ -331,10 +331,9 @@ nexus_add_child(device_t bus, int order, const char *name, int unit) device_t child; struct nexus_device *ndev; - ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT); + ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT|M_ZERO); if (!ndev) return(0); - bzero(ndev, sizeof(struct nexus_device)); resource_list_init(&ndev->nx_resources); ndev->nx_pcibus = -1; diff --git a/sys/i386/i386/nexus.c b/sys/i386/i386/nexus.c index d648848..76c41ae 100644 --- a/sys/i386/i386/nexus.c +++ b/sys/i386/i386/nexus.c @@ -331,10 +331,9 @@ nexus_add_child(device_t bus, int order, const char *name, int unit) device_t child; struct nexus_device *ndev; - ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT); + ndev = malloc(sizeof(struct nexus_device), M_NEXUSDEV, M_NOWAIT|M_ZERO); if (!ndev) return(0); - bzero(ndev, sizeof(struct nexus_device)); resource_list_init(&ndev->nx_resources); ndev->nx_pcibus = -1; diff --git a/sys/i386/i386/userconfig.c b/sys/i386/i386/userconfig.c index de19c23..a8a80fa 100644 --- a/sys/i386/i386/userconfig.c +++ b/sys/i386/i386/userconfig.c @@ -3228,8 +3228,8 @@ load_devtab(void) char *name; int unit; - uc_devtab = malloc(sizeof(struct uc_device)*(count + 1),M_DEVL,M_WAITOK); - bzero(uc_devtab, sizeof(struct uc_device) * (count + 1)); + uc_devtab = malloc(sizeof(struct uc_device) * (count + 1), M_DEVL, + M_WAITOK | M_ZERO); dt = 0; for (i = 0; i < count; i++) { name = resource_query_name(i); diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index 294a583..dcf4986 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -287,11 +287,10 @@ cpu_coredump(p, vp, cred) int error; caddr_t tempuser; - tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK); + tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK | M_ZERO); if (!tempuser) return EINVAL; - bzero(tempuser, ctob(UPAGES)); bcopy(p->p_addr, tempuser, sizeof(struct user)); bcopy(p->p_md.md_regs, tempuser + ((caddr_t) p->p_md.md_regs - (caddr_t) p->p_addr), diff --git a/sys/i386/isa/bs/bsfunc.c b/sys/i386/isa/bs/bsfunc.c index 42a636f..8800d3d 100644 --- a/sys/i386/isa/bs/bsfunc.c +++ b/sys/i386/isa/bs/bsfunc.c @@ -682,15 +682,13 @@ bs_init_target_info(bsc, target) { struct targ_info *ti; - ti = malloc(sizeof(struct targ_info), M_DEVBUF, M_NOWAIT); + ti = malloc(sizeof(struct targ_info), M_DEVBUF, M_NOWAIT | M_ZERO); if (ti == NULL) { bs_printf(NULL, "bs_init_targ_info", "no target info memory"); return ti; } - bzero(ti, sizeof(*ti)); - ti->ti_bsc = bsc; ti->ti_id = target; ti->sm_offset = 0; diff --git a/sys/i386/isa/bs/bsif.c b/sys/i386/isa/bs/bsif.c index 743fb39..d48469d 100644 --- a/sys/i386/isa/bs/bsif.c +++ b/sys/i386/isa/bs/bsif.c @@ -153,11 +153,11 @@ bsprobe(dev) printf("bs%d: memory already allocated\n", unit); return rv; } - if (!(bsc = malloc(sizeof(struct bs_softc), M_TEMP, M_NOWAIT))) { + if (!(bsc = malloc(sizeof(struct bs_softc), M_TEMP, M_NOWAIT | M_ZERO))) + { printf("bs%d cannot malloc!\n", unit); return rv; } - bzero(bsc, sizeof(struct bs_softc)); callout_handle_init(&bsc->timeout_ch); bscdata[unit] = bsc; bsc->unit = unit; diff --git a/sys/i386/isa/cy.c b/sys/i386/isa/cy.c index 4006807..18245e3 100644 --- a/sys/i386/isa/cy.c +++ b/sys/i386/isa/cy.c @@ -553,10 +553,9 @@ cyattach_common(cy_iobase, cy_align) struct com_s *com; int s; - com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT); + com = malloc(sizeof *com, M_DEVBUF, M_NOWAIT | M_ZERO); if (com == NULL) break; - bzero(com, sizeof *com); com->unit = unit; com->gfrcr_image = firmware_version; if (CY_RTS_DTR_SWAPPED(firmware_version)) { diff --git a/sys/i386/isa/if_ar.c b/sys/i386/isa/if_ar.c index dfbc3ac..9acc402 100644 --- a/sys/i386/isa/if_ar.c +++ b/sys/i386/isa/if_ar.c @@ -397,8 +397,7 @@ arattach_pci(int unit, vm_offset_t mem_addr) struct ar_hardc *hc; u_int i, tmp; - hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK); - bzero(hc, sizeof(struct ar_hardc)); + hc = malloc(sizeof(struct ar_hardc), M_DEVBUF, M_WAITOK | M_ZERO); hc->cunit = unit; hc->mem_start = (caddr_t)mem_addr; @@ -1139,11 +1138,10 @@ arc_init(struct ar_hardc *hc) u_int descneeded; u_char isr, mar; - MALLOC(sc, struct ar_softc *, - hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK); + MALLOC(sc, struct ar_softc *, hc->numports * sizeof(struct ar_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (sc == NULL) return; - bzero(sc, hc->numports * sizeof(struct ar_softc)); hc->sc = sc; hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET | @@ -2234,12 +2232,11 @@ ngar_rcvmsg(node_p node, struct ng_mesg *msg, int pos = 0; int resplen = sizeof(struct ng_mesg) + 512; MALLOC(*resp, struct ng_mesg *, resplen, - M_NETGRAPH, M_NOWAIT); + M_NETGRAPH, M_NOWAIT | M_ZERO); if (*resp == NULL) { error = ENOMEM; break; } - bzero(*resp, resplen); arg = (*resp)->data; /* diff --git a/sys/i386/isa/if_sr.c b/sys/i386/isa/if_sr.c index 89b2c99..b27d2f5 100644 --- a/sys/i386/isa/if_sr.c +++ b/sys/i386/isa/if_sr.c @@ -659,10 +659,10 @@ srattach_isa(struct isa_device *id) * Allocate the software interface table(s) */ MALLOC(hc->sc, struct sr_softc *, - hc->numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK); + hc->numports * sizeof(struct sr_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (hc->sc == NULL) return(0); - bzero(hc->sc, hc->numports * sizeof(struct sr_softc)); id->id_ointr = srintr; @@ -768,18 +768,16 @@ srattach_pci(int unit, vm_offset_t plx_vaddr, vm_offset_t sca_vaddr) hc = hc->next; } - MALLOC(hc, struct sr_hardc *, sizeof(*hc), M_DEVBUF, M_WAITOK); + MALLOC(hc, struct sr_hardc *, sizeof(*hc), M_DEVBUF, M_WAITOK | M_ZERO); if (hc == NULL) return NULL; - bzero(hc, sizeof(*hc)); - MALLOC(hc->sc, struct sr_softc *, - numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK); + MALLOC(hc->sc, struct sr_softc *, numports * sizeof(struct sr_softc), + M_DEVBUF, M_WAITOK | M_ZERO); if (hc->sc == NULL) { FREE(hc, M_DEVBUF); return NULL; } - bzero(hc->sc, numports * sizeof(struct sr_softc)); *hcp = hc; hc->numports = numports; @@ -3188,12 +3186,11 @@ ngsr_rcvmsg(node_p node, struct ng_mesg *msg, const char *retaddr, int pos = 0; int resplen = sizeof(struct ng_mesg) + 512; MALLOC(*resp, struct ng_mesg *, resplen, - M_NETGRAPH, M_NOWAIT); + M_NETGRAPH, M_NOWAIT | M_ZERO); if (*resp == NULL) { error = ENOMEM; break; } - bzero(*resp, resplen); arg = (*resp)->data; /* diff --git a/sys/i386/isa/intr_machdep.c b/sys/i386/isa/intr_machdep.c index ffdcfc4..6f76185 100644 --- a/sys/i386/isa/intr_machdep.c +++ b/sys/i386/isa/intr_machdep.c @@ -546,10 +546,10 @@ inthand_add(const char *name, int irq, driver_intr_t handler, void *arg, if (ithd == NULL || ithd->it_ih == NULL) { /* first handler for this irq. */ if (ithd == NULL) { - ithd = malloc(sizeof (struct ithd), M_DEVBUF, M_WAITOK); + ithd = malloc(sizeof (struct ithd), M_DEVBUF, + M_WAITOK | M_ZERO); if (ithd == NULL) return (NULL); - bzero(ithd, sizeof(struct ithd)); ithd->irq = irq; ithds[irq] = ithd; } @@ -620,10 +620,9 @@ inthand_add(const char *name, int irq, driver_intr_t handler, void *arg, else strcat(p->p_comm, "+"); } - idesc = malloc(sizeof (struct intrhand), M_DEVBUF, M_WAITOK); + idesc = malloc(sizeof (struct intrhand), M_DEVBUF, M_WAITOK | M_ZERO); if (idesc == NULL) return (NULL); - bzero(idesc, sizeof (struct intrhand)); idesc->ih_handler = handler; idesc->ih_argument = arg; diff --git a/sys/i386/isa/isa_compat.c b/sys/i386/isa/isa_compat.c index ef7d358..93d6dfa 100644 --- a/sys/i386/isa/isa_compat.c +++ b/sys/i386/isa/isa_compat.c @@ -269,10 +269,9 @@ compat_isa_handler(module_t mod, int type, void *data) switch (type) { case MOD_LOAD: - driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT); + driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT | M_ZERO); if (!driver) return ENOMEM; - bzero(driver, sizeof(driver_t)); driver->name = id->name; driver->methods = isa_compat_methods; driver->size = sizeof(struct isa_device); diff --git a/sys/i386/isa/istallion.c b/sys/i386/isa/istallion.c index a9341ff..36932b9 100644 --- a/sys/i386/isa/istallion.c +++ b/sys/i386/isa/istallion.c @@ -666,13 +666,12 @@ static stlibrd_t *stli_brdalloc(void) { stlibrd_t *brdp; - brdp = (stlibrd_t *) malloc(sizeof(stlibrd_t), M_TTYS, M_NOWAIT); + brdp = (stlibrd_t *) malloc(sizeof(stlibrd_t), M_TTYS, M_NOWAIT|M_ZERO); if (brdp == (stlibrd_t *) NULL) { printf("STALLION: failed to allocate memory (size=%d)\n", sizeof(stlibrd_t)); return((stlibrd_t *) NULL); } - bzero(brdp, sizeof(stlibrd_t)); return(brdp); } @@ -2513,12 +2512,11 @@ static int stli_initports(stlibrd_t *brdp) for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { portp = (stliport_t *) malloc(sizeof(stliport_t), M_TTYS, - M_NOWAIT); + M_NOWAIT | M_ZERO); if (portp == (stliport_t *) NULL) { printf("STALLION: failed to allocate port structure\n"); continue; } - bzero(portp, sizeof(stliport_t)); portp->portnr = i; portp->brdnr = brdp->brdnr; diff --git a/sys/i386/isa/nmi.c b/sys/i386/isa/nmi.c index ffdcfc4..6f76185 100644 --- a/sys/i386/isa/nmi.c +++ b/sys/i386/isa/nmi.c @@ -546,10 +546,10 @@ inthand_add(const char *name, int irq, driver_intr_t handler, void *arg, if (ithd == NULL || ithd->it_ih == NULL) { /* first handler for this irq. */ if (ithd == NULL) { - ithd = malloc(sizeof (struct ithd), M_DEVBUF, M_WAITOK); + ithd = malloc(sizeof (struct ithd), M_DEVBUF, + M_WAITOK | M_ZERO); if (ithd == NULL) return (NULL); - bzero(ithd, sizeof(struct ithd)); ithd->irq = irq; ithds[irq] = ithd; } @@ -620,10 +620,9 @@ inthand_add(const char *name, int irq, driver_intr_t handler, void *arg, else strcat(p->p_comm, "+"); } - idesc = malloc(sizeof (struct intrhand), M_DEVBUF, M_WAITOK); + idesc = malloc(sizeof (struct intrhand), M_DEVBUF, M_WAITOK | M_ZERO); if (idesc == NULL) return (NULL); - bzero(idesc, sizeof (struct intrhand)); idesc->ih_handler = handler; idesc->ih_argument = arg; diff --git a/sys/i386/isa/rp.c b/sys/i386/isa/rp.c index 7f5dd3a..21c30cc 100644 --- a/sys/i386/isa/rp.c +++ b/sys/i386/isa/rp.c @@ -1109,7 +1109,7 @@ rp_pciattach(pcici_t tag, int unit) rp_num_ports[unit] = num_ports; rp = (struct rp_port *) - malloc(sizeof(struct rp_port) * num_ports, M_TTYS, M_NOWAIT); + malloc(sizeof(struct rp_port) * num_ports, M_TTYS, M_NOWAIT|M_ZERO); if(rp == 0) { printf("rp_attach: Could not malloc rp_ports structures\n"); return; @@ -1119,14 +1119,12 @@ rp_pciattach(pcici_t tag, int unit) for(i=count;i < (count + rp_num_ports[unit]);i++) minor_to_unit[i] = unit; - bzero(rp, sizeof(struct rp_port) * num_ports); tty = (struct tty *) - malloc(sizeof(struct tty) * num_ports, M_TTYS, M_NOWAIT); + malloc(sizeof(struct tty) * num_ports, M_TTYS, M_NOWAIT|M_ZERO); if(tty == 0) { printf("rp_attach: Could not malloc tty structures\n"); return; } - bzero(tty, sizeof(struct tty) * num_ports); oldspl = spltty(); rp_addr(unit) = rp; @@ -1212,7 +1210,7 @@ struct isa_device *dev; rp_num_ports[unit] = num_ports; rp = (struct rp_port *) - malloc(sizeof(struct rp_port) * num_ports, M_TTYS, M_NOWAIT); + malloc(sizeof(struct rp_port) * num_ports, M_TTYS, M_NOWAIT|M_ZERO); if(rp == 0) { printf("rp_attach: Could not malloc rp_ports structures\n"); return(0); @@ -1222,14 +1220,12 @@ struct isa_device *dev; for(i=count;i < (count + rp_num_ports[unit]);i++) minor_to_unit[i] = unit; - bzero(rp, sizeof(struct rp_port) * num_ports); tty = (struct tty *) - malloc(sizeof(struct tty) * num_ports, M_TTYS, M_NOWAIT); + malloc(sizeof(struct tty) * num_ports, M_TTYS, M_NOWAIT|M_ZERO); if(tty == 0) { printf("rp_attach: Could not malloc tty structures\n"); return(0); } - bzero(tty, sizeof(struct tty) * num_ports); oldspl = spltty(); rp_addr(unit) = rp; diff --git a/sys/i386/isa/stallion.c b/sys/i386/isa/stallion.c index 8162a45..07528a0 100644 --- a/sys/i386/isa/stallion.c +++ b/sys/i386/isa/stallion.c @@ -635,13 +635,12 @@ static int stlattach(struct isa_device *idp) idp->id_ointr = stlintr; - brdp = (stlbrd_t *) malloc(sizeof(stlbrd_t), M_TTYS, M_NOWAIT); + brdp = (stlbrd_t *) malloc(sizeof(stlbrd_t), M_TTYS, M_NOWAIT | M_ZERO); if (brdp == (stlbrd_t *) NULL) { printf("STALLION: failed to allocate memory (size=%d)\n", sizeof(stlbrd_t)); return(0); } - bzero(brdp, sizeof(stlbrd_t)); if ((brdp->brdnr = stl_findfreeunit()) < 0) { printf("STALLION: too many boards found, max=%d\n", @@ -707,13 +706,12 @@ void stlpciattach(pcici_t tag, int unit) printf("stlpciattach(tag=%x,unit=%x)\n", (int) &tag, unit); #endif - brdp = (stlbrd_t *) malloc(sizeof(stlbrd_t), M_TTYS, M_NOWAIT); + brdp = (stlbrd_t *) malloc(sizeof(stlbrd_t), M_TTYS, M_NOWAIT | M_ZERO); if (brdp == (stlbrd_t *) NULL) { printf("STALLION: failed to allocate memory (size=%d)\n", sizeof(stlbrd_t)); return; } - bzero(brdp, sizeof(stlbrd_t)); if ((unit < 0) || (unit > STL_MAXBRDS)) { printf("STALLION: bad PCI board unit number=%d\n", unit); @@ -2596,13 +2594,12 @@ static int stl_initports(stlbrd_t *brdp, stlpanel_t *panelp) if ((chipmask & (0x1 << (i / 4))) == 0) continue; portp = (stlport_t *) malloc(sizeof(stlport_t), M_TTYS, - M_NOWAIT); + M_NOWAIT | M_ZERO); if (portp == (stlport_t *) NULL) { printf("STALLION: failed to allocate port memory " "(size=%d)\n", sizeof(stlport_t)); break; } - bzero(portp, sizeof(stlport_t)); portp->portnr = i; portp->brdnr = panelp->brdnr; @@ -2701,13 +2698,13 @@ static int stl_initeio(stlbrd_t *brdp) outb(brdp->ioctrl, (stl_vecmap[brdp->irq] | ((brdp->irqtype) ? EIO_INTLEVEL : EIO_INTEDGE))); - panelp = (stlpanel_t *) malloc(sizeof(stlpanel_t), M_TTYS, M_NOWAIT); + panelp = (stlpanel_t *) malloc(sizeof(stlpanel_t), M_TTYS, + M_NOWAIT | M_ZERO); if (panelp == (stlpanel_t *) NULL) { printf("STALLION: failed to allocate memory (size=%d)\n", sizeof(stlpanel_t)); return(ENOMEM); } - bzero(panelp, sizeof(stlpanel_t)); panelp->brdnr = brdp->brdnr; panelp->panelnr = 0; @@ -2803,13 +2800,12 @@ static int stl_initech(stlbrd_t *brdp) if ((status & ECH_PNLIDMASK) != nxtid) break; panelp = (stlpanel_t *) malloc(sizeof(stlpanel_t), M_TTYS, - M_NOWAIT); + M_NOWAIT | M_ZERO); if (panelp == (stlpanel_t *) NULL) { printf("STALLION: failed to allocate memory" "(size=%d)\n", sizeof(stlpanel_t)); break; } - bzero(panelp, sizeof(stlpanel_t)); panelp->brdnr = brdp->brdnr; panelp->panelnr = panelnr; panelp->iobase = ioaddr; diff --git a/sys/ia64/ia64/busdma_machdep.c b/sys/ia64/ia64/busdma_machdep.c index a86ddd6..0488076 100644 --- a/sys/ia64/ia64/busdma_machdep.c +++ b/sys/ia64/ia64/busdma_machdep.c @@ -243,23 +243,20 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) if (dmat->flags & BUS_DMA_ISA) { bus_dmamap_t map; - map = (bus_dmamap_t)malloc(sizeof(**mapp), M_DEVBUF, - M_NOWAIT); - if (map == NULL) { + map = (bus_dmamap_t)malloc(sizeof(*map), M_DEVBUF, + M_NOWAIT | M_ZERO); + if (map == NULL) return (ENOMEM); - } else { - bzero(map, sizeof(*map)); #if 0 - map->busaddress = - sgmap_alloc_region(chipset.sgmap, - dmat->maxsize, - dmat->boundary, - &map->sgmaphandle); + map->busaddress = + sgmap_alloc_region(chipset.sgmap, + dmat->maxsize, + dmat->boundary, + &map->sgmaphandle); #endif - dmat->map_count++; - *mapp = map; - return (0); - } + dmat->map_count++; + *mapp = map; + return (0); } if (dmat->lowaddr < ptoa(Maxmem)) { @@ -267,14 +264,13 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp) int maxpages; *mapp = (bus_dmamap_t)malloc(sizeof(**mapp), M_DEVBUF, - M_NOWAIT); - if (*mapp == NULL) { + M_NOWAIT | M_ZERO); + if (*mapp == NULL) return (ENOMEM); - } else { - /* Initialize the new map */ - bzero(*mapp, sizeof(**mapp)); - STAILQ_INIT(&((*mapp)->bpages)); - } + + /* Initialize the new map */ + STAILQ_INIT(&((*mapp)->bpages)); + /* * Attempt to add pages to our pool on a per-instance * basis up to a sane limit. @@ -606,11 +602,10 @@ alloc_bounce_pages(bus_dma_tag_t dmat, u_int numpages) int s; bpage = (struct bounce_page *)malloc(sizeof(*bpage), M_DEVBUF, - M_NOWAIT); + M_NOWAIT | M_ZERO); if (bpage == NULL) break; - bzero(bpage, sizeof(*bpage)); bpage->vaddr = (vm_offset_t)contigmalloc(PAGE_SIZE, M_DEVBUF, M_NOWAIT, 0ul, dmat->lowaddr, diff --git a/sys/ia64/ia64/sscdisk.c b/sys/ia64/ia64/sscdisk.c index da9842d..9d32262 100644 --- a/sys/ia64/ia64/sscdisk.c +++ b/sys/ia64/ia64/sscdisk.c @@ -242,8 +242,7 @@ ssccreate(int unit) if (sc->unit == unit) return (NULL); } - MALLOC(sc, struct ssc_s *,sizeof(*sc), M_SSC, M_WAITOK); - bzero(sc, sizeof(*sc)); + MALLOC(sc, struct ssc_s *,sizeof(*sc), M_SSC, M_WAITOK | M_ZERO); LIST_INSERT_HEAD(&ssc_softc_list, sc, list); sc->unit = unit; bioq_init(&sc->bio_queue); diff --git a/sys/isa/atkbdc_isa.c b/sys/isa/atkbdc_isa.c index e8c3e4c..d99b648 100644 --- a/sys/isa/atkbdc_isa.c +++ b/sys/isa/atkbdc_isa.c @@ -146,10 +146,10 @@ atkbdc_add_device(device_t dev, const char *name, int unit) if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0) return; - kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, M_NOWAIT); + kdev = malloc(sizeof(struct atkbdc_device), M_ATKBDDEV, + M_NOWAIT | M_ZERO); if (!kdev) return; - bzero(kdev, sizeof *kdev); if (resource_int_value(name, unit, "irq", &t) == 0) kdev->irq = t; diff --git a/sys/isa/fd.c b/sys/isa/fd.c index e82bbd5..4fee4f5 100644 --- a/sys/isa/fd.c +++ b/sys/isa/fd.c @@ -818,10 +818,9 @@ fdc_add_child(device_t dev, const char *name, int unit) struct fdc_ivars *ivar; device_t child; - ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT); + ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT | M_ZERO); if (ivar == NULL) return; - bzero(ivar, sizeof *ivar); if (resource_int_value(name, unit, "drive", &ivar->fdunit) != 0) ivar->fdunit = 0; child = device_add_child(dev, name, unit); diff --git a/sys/isa/isa_common.c b/sys/isa/isa_common.c index 4334ddf..9a761cf 100644 --- a/sys/isa/isa_common.c +++ b/sys/isa/isa_common.c @@ -522,10 +522,9 @@ isa_add_child(device_t dev, int order, const char *name, int unit) device_t child; struct isa_device *idev; - idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT); + idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT | M_ZERO); if (!idev) return 0; - bzero(idev, sizeof *idev); resource_list_init(&idev->id_resources); TAILQ_INIT(&idev->id_configs); diff --git a/sys/isa/pnpparse.c b/sys/isa/pnpparse.c index 8c66716..976b0eb 100644 --- a/sys/isa/pnpparse.c +++ b/sys/isa/pnpparse.c @@ -62,12 +62,11 @@ pnp_parse_resources(device_t dev, u_char *resources, int len, u_int32_t vendor_i id = isa_get_logicalid(dev); configs = (struct isa_config *)malloc(sizeof(*configs) * (1 + MAXDEP), - M_DEVBUF, M_NOWAIT); + M_DEVBUF, M_NOWAIT | M_ZERO); if (configs == NULL) { device_printf(dev, "No memory to parse PNP data\n"); return; } - bzero(configs, sizeof(*configs) * (1 + MAXDEP)); config = &configs[0]; priorities[0] = 0; resp = resources; diff --git a/sys/isofs/cd9660/cd9660_vfsops.c b/sys/isofs/cd9660/cd9660_vfsops.c index 49e6169..aaefb78 100644 --- a/sys/isofs/cd9660/cd9660_vfsops.c +++ b/sys/isofs/cd9660/cd9660_vfsops.c @@ -401,8 +401,7 @@ iso_mountfs(devvp, mp, p, argp) pri_sierra->root_directory_record: pri->root_directory_record); - isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK); - bzero((caddr_t)isomp, sizeof *isomp); + isomp = malloc(sizeof *isomp, M_ISOFSMNT, M_WAITOK | M_ZERO); isomp->logical_block_size = logical_block_size; isomp->volume_space_size = isonum_733 (high_sierra? @@ -723,8 +722,7 @@ cd9660_vget_internal(mp, ino, vpp, relocated, isodir) return (error); } MALLOC(ip, struct iso_node *, sizeof(struct iso_node), M_ISOFSNODE, - M_WAITOK); - bzero((caddr_t)ip, sizeof(struct iso_node)); + M_WAITOK | M_ZERO); lockinit(&vp->v_lock, PINOD, "isonode", 0, 0); /* * ISOFS uses stdlock and can share lock structure diff --git a/sys/kern/kern_conf.c b/sys/kern/kern_conf.c index 8c20321..0c446c8 100644 --- a/sys/kern/kern_conf.c +++ b/sys/kern/kern_conf.c @@ -170,8 +170,7 @@ allocdev(void) if (stashed >= DEVT_STASH) { MALLOC(si, struct specinfo *, sizeof(*si), M_DEVT, - M_USE_RESERVE); - bzero(si, sizeof(*si)); + M_USE_RESERVE | M_ZERO); } else if (LIST_FIRST(&dev_free)) { si = LIST_FIRST(&dev_free); LIST_REMOVE(si, si_hash); diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 29de2b1..75ec0ee 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -859,8 +859,7 @@ falloc(p, resultfp, resultfd) * the list of open files. */ nfiles++; - MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK); - bzero(fp, sizeof(struct file)); + MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK | M_ZERO); /* * wait until after malloc (which may have blocked) returns before @@ -915,8 +914,7 @@ fdinit(p) register struct filedesc *fdp = p->p_fd; MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0), - M_FILEDESC, M_WAITOK); - bzero(newfdp, sizeof(struct filedesc0)); + M_FILEDESC, M_WAITOK | M_ZERO); newfdp->fd_fd.fd_cdir = fdp->fd_cdir; if (newfdp->fd_fd.fd_cdir) VREF(newfdp->fd_fd.fd_cdir); diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index 64d8d9f..56e818a 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -306,8 +306,7 @@ kqueue(struct proc *p, struct kqueue_args *uap) fp->f_flag = FREAD | FWRITE; fp->f_type = DTYPE_KQUEUE; fp->f_ops = &kqueueops; - kq = malloc(sizeof(struct kqueue), M_TEMP, M_WAITOK); - bzero(kq, sizeof(*kq)); + kq = malloc(sizeof(struct kqueue), M_TEMP, M_WAITOK | M_ZERO); TAILQ_INIT(&kq->kq_head); fp->f_data = (caddr_t)kq; p->p_retval[0] = fd; diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c index d180f3c..97bb2bb 100644 --- a/sys/kern/kern_jail.c +++ b/sys/kern/kern_jail.c @@ -64,8 +64,7 @@ jail(p, uap) return (error); if (j.version != 0) return (EINVAL); - MALLOC(pr, struct prison *, sizeof *pr , M_PRISON, M_WAITOK); - bzero((caddr_t)pr, sizeof *pr); + MALLOC(pr, struct prison *, sizeof *pr , M_PRISON, M_WAITOK | M_ZERO); error = copyinstr(j.hostname, &pr->pr_host, sizeof pr->pr_host, 0); if (error) goto bail; diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 2060958..9fce595 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -515,10 +515,9 @@ linker_file_add_dependancy(linker_file_t file, linker_file_t dep) linker_file_t* newdeps; newdeps = malloc((file->ndeps + 1) * sizeof(linker_file_t*), - M_LINKER, M_WAITOK); + M_LINKER, M_WAITOK | M_ZERO); if (newdeps == NULL) return ENOMEM; - bzero(newdeps, (file->ndeps + 1) * sizeof(linker_file_t*)); if (file->deps) { bcopy(file->deps, newdeps, file->ndeps * sizeof(linker_file_t*)); @@ -589,12 +588,11 @@ linker_file_lookup_symbol(linker_file_t file, const char* name, int deps) cp = malloc(sizeof(struct common_symbol) + common_size + strlen(name) + 1, - M_LINKER, M_WAITOK); + M_LINKER, M_WAITOK | M_ZERO); if (!cp) { KLD_DPF(SYM, ("linker_file_lookup_symbol: nomem\n")); return 0; } - bzero(cp, sizeof(struct common_symbol) + common_size + strlen(name)+ 1); cp->address = (caddr_t) (cp + 1); cp->name = cp->address + common_size; @@ -1021,10 +1019,9 @@ linker_preload(void* arg) /* XXX what can we do? this is a build error. :-( */ continue; } - mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT); + mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT|M_ZERO); if (mod == NULL) panic("no memory for module list"); - bzero(mod, sizeof(*mod)); mod->container = linker_kernel_file; mod->name = modname; TAILQ_INSERT_TAIL(&found_modules, mod, link); @@ -1082,10 +1079,10 @@ restart: TAILQ_REMOVE(&loaded_files, lf, loaded); goto restart; /* we changed the tailq next ptr */ } - mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT); + mod = malloc(sizeof(struct modlist), M_LINKER, + M_NOWAIT|M_ZERO); if (mod == NULL) panic("no memory for module list"); - bzero(mod, sizeof(*mod)); mod->container = lf; mod->name = modname; TAILQ_INSERT_TAIL(&found_modules, mod, link); @@ -1383,10 +1380,9 @@ linker_load_dependancies(linker_file_t lf) if (mp->md_type != MDT_VERSION) continue; modname = linker_reloc_ptr(lf, mp->md_cval); - mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT); + mod = malloc(sizeof(struct modlist), M_LINKER, M_NOWAIT|M_ZERO); if (mod == NULL) panic("no memory for module list"); - bzero(mod, sizeof(*mod)); mod->container = lf; mod->name = modname; TAILQ_INSERT_TAIL(&found_modules, mod, link); diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c index 5290d90..af317f0 100644 --- a/sys/kern/kern_mutex.c +++ b/sys/kern/kern_mutex.c @@ -599,9 +599,9 @@ mtx_init(struct mtx *m, const char *t, int flag) #endif /* XXX - should not use DEVBUF */ - debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, M_NOWAIT); + debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, + M_NOWAIT | M_ZERO); MPASS(debug != NULL); - bzero(debug, sizeof(struct mtx_debug)); } #endif bzero((void *)m, sizeof *m); diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 2085c90..e9aeff5 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -339,8 +339,7 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, return (NULL); } } - oidp = malloc(sizeof(struct sysctl_oid), M_SYSCTLOID, M_WAITOK); - bzero(oidp, sizeof(struct sysctl_oid)); + oidp = malloc(sizeof(struct sysctl_oid), M_SYSCTLOID, M_WAITOK|M_ZERO); oidp->oid_parent = parent; SLIST_NEXT(oidp, oid_link) = NULL; oidp->oid_number = number; diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index f812bfd..9908d8a 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -728,12 +728,11 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu nbytes = hdr->e_shnum * hdr->e_shentsize; if (nbytes == 0 || hdr->e_shoff == 0) goto nosyms; - shdr = malloc(nbytes, M_LINKER, M_WAITOK); + shdr = malloc(nbytes, M_LINKER, M_WAITOK | M_ZERO); if (shdr == NULL) { error = ENOMEM; goto out; } - bzero(shdr, nbytes); error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes, hdr->e_shoff, UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index f812bfd..9908d8a 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -728,12 +728,11 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu nbytes = hdr->e_shnum * hdr->e_shentsize; if (nbytes == 0 || hdr->e_shoff == 0) goto nosyms; - shdr = malloc(nbytes, M_LINKER, M_WAITOK); + shdr = malloc(nbytes, M_LINKER, M_WAITOK | M_ZERO); if (shdr == NULL) { error = ENOMEM; goto out; } - bzero(shdr, nbytes); error = vn_rdwr(UIO_READ, nd.ni_vp, (caddr_t)shdr, nbytes, hdr->e_shoff, UIO_SYSSPACE, IO_NODELOCKED, p->p_ucred, &resid, p); diff --git a/sys/kern/subr_blist.c b/sys/kern/subr_blist.c index d706524..9ac4338 100644 --- a/sys/kern/subr_blist.c +++ b/sys/kern/subr_blist.c @@ -152,9 +152,7 @@ blist_create(daddr_t blocks) skip = (skip + 1) << BLIST_META_RADIX_SHIFT; } - bl = malloc(sizeof(struct blist), M_SWAP, M_WAITOK); - - bzero(bl, sizeof(*bl)); + bl = malloc(sizeof(struct blist), M_SWAP, M_WAITOK | M_ZERO); bl->bl_blocks = blocks; bl->bl_radix = radix; diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index a89048a..5032ab0 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -125,10 +125,9 @@ devclass_find_internal(const char *classname, int create) PDEBUG(("%s not found%s", classname, (create? ", creating": ""))); if (create) { dc = malloc(sizeof(struct devclass) + strlen(classname) + 1, - M_BUS, M_NOWAIT); + M_BUS, M_NOWAIT|M_ZERO); if (!dc) return NULL; - bzero(dc, sizeof(struct devclass) + strlen(classname) + 1); dc->name = (char*) (dc + 1); strcpy(dc->name, classname); dc->devices = NULL; @@ -162,10 +161,9 @@ devclass_add_driver(devclass_t dc, driver_t *driver) PDEBUG(("%s", DRIVERNAME(driver))); - dl = malloc(sizeof *dl, M_BUS, M_NOWAIT); + dl = malloc(sizeof *dl, M_BUS, M_NOWAIT|M_ZERO); if (!dl) return ENOMEM; - bzero(dl, sizeof *dl); /* * Compile the driver's methods. Also increase the reference count @@ -322,10 +320,9 @@ devclass_get_devices(devclass_t dc, device_t **devlistp, int *devcountp) if (dc->devices[i]) count++; - list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT); + list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT|M_ZERO); if (!list) return ENOMEM; - bzero(list, count * sizeof(device_t)); count = 0; for (i = 0; i < dc->maxunit; i++) @@ -405,10 +402,9 @@ devclass_add_device(devclass_t dc, device_t dev) PDEBUG(("%s in devclass %s", DEVICENAME(dev), DEVCLANAME(dc))); buflen = strlen(dc->name) + 5; - dev->nameunit = malloc(buflen, M_BUS, M_NOWAIT); + dev->nameunit = malloc(buflen, M_BUS, M_NOWAIT|M_ZERO); if (!dev->nameunit) return ENOMEM; - bzero(dev->nameunit, buflen); if ((error = devclass_alloc_unit(dc, &dev->unit)) != 0) { free(dev->nameunit, M_BUS); @@ -460,10 +456,9 @@ make_device(device_t parent, const char *name, int unit) } else dc = NULL; - dev = malloc(sizeof(struct device), M_BUS, M_NOWAIT); + dev = malloc(sizeof(struct device), M_BUS, M_NOWAIT|M_ZERO); if (!dev) return 0; - bzero(dev, sizeof(struct device)); dev->parent = parent; TAILQ_INIT(&dev->children); @@ -715,10 +710,9 @@ device_get_children(device_t dev, device_t **devlistp, int *devcountp) child = TAILQ_NEXT(child, link)) count++; - list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT); + list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT|M_ZERO); if (!list) return ENOMEM; - bzero(list, count * sizeof(device_t)); count = 0; for (child = TAILQ_FIRST(&dev->children); child; @@ -993,13 +987,12 @@ device_set_driver(device_t dev, driver_t *driver) if (driver) { kobj_init((kobj_t) dev, (kobj_class_t) driver); if (!(dev->flags & DF_EXTERNALSOFTC)) { - dev->softc = malloc(driver->size, M_BUS, M_NOWAIT); + dev->softc = malloc(driver->size, M_BUS, M_NOWAIT|M_ZERO); if (!dev->softc) { kobj_init((kobj_t) dev, &null_class); dev->driver = NULL; return ENOMEM; } - bzero(dev->softc, driver->size); } } else kobj_init((kobj_t) dev, &null_class); diff --git a/sys/kern/subr_kobj.c b/sys/kern/subr_kobj.c index 2f3e60f..659e97a 100644 --- a/sys/kern/subr_kobj.c +++ b/sys/kern/subr_kobj.c @@ -175,10 +175,9 @@ kobj_create(kobj_class_t cls, /* * Allocate and initialise the new object. */ - obj = malloc(cls->size, mtype, mflags); + obj = malloc(cls->size, mtype, mflags | M_ZERO); if (!obj) return 0; - bzero(obj, cls->size); kobj_init(obj, cls); return obj; diff --git a/sys/kern/subr_prof.c b/sys/kern/subr_prof.c index 1c84108..3da2a05 100644 --- a/sys/kern/subr_prof.c +++ b/sys/kern/subr_prof.c @@ -114,12 +114,11 @@ kmstartup(dummy) p->tolimit = MAXARCS; p->tossize = p->tolimit * sizeof(struct tostruct); cp = (char *)malloc(p->kcountsize + p->fromssize + p->tossize, - M_GPROF, M_NOWAIT); + M_GPROF, M_NOWAIT | M_ZERO); if (cp == 0) { printf("No memory for profiling.\n"); return; } - bzero(cp, p->kcountsize + p->tossize + p->fromssize); p->tos = (struct tostruct *)cp; cp += p->tossize; p->kcount = (HISTCOUNTER *)cp; diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index c3f7faf..ccd1af1 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -120,10 +120,9 @@ rman_manage_region(struct rman *rm, u_long start, u_long end) { struct resource *r, *s; - r = malloc(sizeof *r, M_RMAN, M_NOWAIT); + r = malloc(sizeof *r, M_RMAN, M_NOWAIT | M_ZERO); if (r == 0) return ENOMEM; - bzero(r, sizeof *r); r->r_sharehead = 0; r->r_start = start; r->r_end = end; @@ -247,10 +246,9 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count, * split it in two. The first case requires * two new allocations; the second requires but one. */ - rv = malloc(sizeof *rv, M_RMAN, M_NOWAIT); + rv = malloc(sizeof *rv, M_RMAN, M_NOWAIT | M_ZERO); if (rv == 0) goto out; - bzero(rv, sizeof *rv); rv->r_start = rstart; rv->r_end = rstart + count - 1; rv->r_flags = flags | RF_ALLOCATED; @@ -267,13 +265,12 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count, /* * We are allocating in the middle. */ - r = malloc(sizeof *r, M_RMAN, M_NOWAIT); + r = malloc(sizeof *r, M_RMAN, M_NOWAIT|M_ZERO); if (r == 0) { free(rv, M_RMAN); rv = 0; goto out; } - bzero(r, sizeof *r); r->r_start = rv->r_end + 1; r->r_end = s->r_end; r->r_flags = s->r_flags; @@ -326,10 +323,9 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count, rend = min(s->r_end, max(start + count, end)); if (s->r_start >= start && s->r_end <= end && (s->r_end - s->r_start + 1) == count) { - rv = malloc(sizeof *rv, M_RMAN, M_NOWAIT); + rv = malloc(sizeof *rv, M_RMAN, M_NOWAIT | M_ZERO); if (rv == 0) goto out; - bzero(rv, sizeof *rv); rv->r_start = s->r_start; rv->r_end = s->r_end; rv->r_flags = s->r_flags & @@ -338,13 +334,12 @@ rman_reserve_resource(struct rman *rm, u_long start, u_long end, u_long count, rv->r_rm = rm; if (s->r_sharehead == 0) { s->r_sharehead = malloc(sizeof *s->r_sharehead, - M_RMAN, M_NOWAIT); + M_RMAN, M_NOWAIT | M_ZERO); if (s->r_sharehead == 0) { free(rv, M_RMAN); rv = 0; goto out; } - bzero(s->r_sharehead, sizeof *s->r_sharehead); LIST_INIT(s->r_sharehead); LIST_INSERT_HEAD(s->r_sharehead, s, r_sharelink); diff --git a/sys/kern/subr_turnstile.c b/sys/kern/subr_turnstile.c index 5290d90..af317f0 100644 --- a/sys/kern/subr_turnstile.c +++ b/sys/kern/subr_turnstile.c @@ -599,9 +599,9 @@ mtx_init(struct mtx *m, const char *t, int flag) #endif /* XXX - should not use DEVBUF */ - debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, M_NOWAIT); + debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, + M_NOWAIT | M_ZERO); MPASS(debug != NULL); - bzero(debug, sizeof(struct mtx_debug)); } #endif bzero((void *)m, sizeof *m); diff --git a/sys/kern/subr_witness.c b/sys/kern/subr_witness.c index 5290d90..af317f0 100644 --- a/sys/kern/subr_witness.c +++ b/sys/kern/subr_witness.c @@ -599,9 +599,9 @@ mtx_init(struct mtx *m, const char *t, int flag) #endif /* XXX - should not use DEVBUF */ - debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, M_NOWAIT); + debug = malloc(sizeof(struct mtx_debug), M_DEVBUF, + M_NOWAIT | M_ZERO); MPASS(debug != NULL); - bzero(debug, sizeof(struct mtx_debug)); } #endif bzero((void *)m, sizeof *m); diff --git a/sys/kern/tty.c b/sys/kern/tty.c index ce11ea5..b80d266 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -2423,8 +2423,7 @@ ttymalloc(tp) if (tp) return(tp); - tp = malloc(sizeof *tp, M_TTYS, M_WAITOK); - bzero(tp, sizeof *tp); + tp = malloc(sizeof *tp, M_TTYS, M_WAITOK | M_ZERO); ttyregister(tp); return (tp); } diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 58af6c6..f7a4370 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -147,8 +147,7 @@ ptyinit(n) if (n & ~0xff) return (NODEV); - pt = malloc(sizeof(*pt), M_PTY, M_WAITOK); - bzero(pt, sizeof(*pt)); + pt = malloc(sizeof(*pt), M_PTY, M_WAITOK | M_ZERO); pt->devs = devs = make_dev(&pts_cdevsw, n, UID_ROOT, GID_WHEEL, 0666, "tty%c%r", names[n / 32], n % 32); pt->devc = devc = make_dev(&ptc_cdevsw, n, diff --git a/sys/kern/tty_snoop.c b/sys/kern/tty_snoop.c index 9950513..b448e30 100644 --- a/sys/kern/tty_snoop.c +++ b/sys/kern/tty_snoop.c @@ -291,8 +291,7 @@ snpopen(dev, flag, mode, p) if (dev->si_drv1 == NULL) { int mynor = minor(dev); - dev->si_drv1 = snp = malloc(sizeof(*snp), M_SNP, M_WAITOK); - bzero(snp, sizeof(*snp)); + dev->si_drv1 = snp = malloc(sizeof(*snp), M_SNP, M_WAITOK|M_ZERO); make_dev(&snp_cdevsw, mynor, 0, 0, 0600, "snp%d", mynor); } else return (EBUSY); diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 2d8a578..a93ee50 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1045,8 +1045,7 @@ do_setopt_accept_filter(so, sopt) error = ENOENT; goto out; } - MALLOC(af, struct so_accf *, sizeof(*af), M_ACCF, M_WAITOK); - bzero(af, sizeof(*af)); + MALLOC(af, struct so_accf *, sizeof(*af), M_ACCF, M_WAITOK | M_ZERO); if (afp->accf_create != NULL) { if (afap->af_name[0] != '\0') { int len = strlen(afap->af_name) + 1; @@ -1310,8 +1309,7 @@ sogetopt(so, sopt) if ((so->so_options & SO_ACCEPTCONN) == 0) return (EINVAL); MALLOC(afap, struct accept_filter_arg *, sizeof(*afap), - M_TEMP, M_WAITOK); - bzero(afap, sizeof(*afap)); + M_TEMP, M_WAITOK | M_ZERO); if ((so->so_options & SO_ACCEPTFILTER) != 0) { strcpy(afap->af_name, so->so_accf->so_accept_filter->accf_name); if (so->so_accf->so_accept_filter_str != NULL) diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index d5cc5ea..d5b8ec5 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1421,8 +1421,8 @@ sf_buf_init(void *arg) mtx_enter(&sf_freelist.sf_lock, MTX_DEF); SLIST_INIT(&sf_freelist); sf_base = kmem_alloc_pageable(kernel_map, nsfbufs * PAGE_SIZE); - sf_bufs = malloc(nsfbufs * sizeof(struct sf_buf), M_TEMP, M_NOWAIT); - bzero(sf_bufs, nsfbufs * sizeof(struct sf_buf)); + sf_bufs = malloc(nsfbufs * sizeof(struct sf_buf), M_TEMP, + M_NOWAIT | M_ZERO); for (i = 0; i < nsfbufs; i++) { sf_bufs[i].kva = sf_base + i * PAGE_SIZE; SLIST_INSERT_HEAD(&sf_freelist, &sf_bufs[i], free_list); diff --git a/sys/kern/vfs_export.c b/sys/kern/vfs_export.c index 8bfc501..a6bae88 100644 --- a/sys/kern/vfs_export.c +++ b/sys/kern/vfs_export.c @@ -335,8 +335,7 @@ vfs_rootmountalloc(fstypename, devname, mpp) break; if (vfsp == NULL) return (ENODEV); - mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); - bzero((char *)mp, (u_long)sizeof(struct mount)); + mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE); (void)vfs_busy(mp, LK_NOWAIT, 0, p); LIST_INIT(&mp->mnt_vnodelist); @@ -2322,8 +2321,7 @@ vfs_hang_addrlist(mp, nep, argp) return (0); } i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen; - np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK); - bzero((caddr_t) np, i); + np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK | M_ZERO); saddr = (struct sockaddr *) (np + 1); if ((error = copyin(argp->ex_addr, (caddr_t) saddr, argp->ex_addrlen))) goto out; diff --git a/sys/kern/vfs_extattr.c b/sys/kern/vfs_extattr.c index 59aacb5..5f1a1d4 100644 --- a/sys/kern/vfs_extattr.c +++ b/sys/kern/vfs_extattr.c @@ -256,8 +256,7 @@ mount(p, uap) /* * Allocate and initialize the filesystem. */ - mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK); - bzero((char *)mp, (u_long)sizeof(struct mount)); + mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE); (void)vfs_busy(mp, LK_NOWAIT, 0, p); mp->mnt_op = vfsp->vfc_vfsops; diff --git a/sys/kern/vfs_init.c b/sys/kern/vfs_init.c index 3a053cf..3f36a5f 100644 --- a/sys/kern/vfs_init.c +++ b/sys/kern/vfs_init.c @@ -119,10 +119,10 @@ vfs_opv_recalc(void) if (*opv_desc_vector_p) FREE(*opv_desc_vector_p, M_VNODE); MALLOC(*opv_desc_vector_p, vop_t **, - vfs_opv_numops * sizeof(vop_t *), M_VNODE, M_WAITOK); + vfs_opv_numops * sizeof(vop_t *), M_VNODE, + M_WAITOK | M_ZERO); if (*opv_desc_vector_p == NULL) panic("no memory for vop_t ** vector"); - bzero(*opv_desc_vector_p, vfs_opv_numops * sizeof(vop_t *)); /* Fill in, with slot 0 being to return EOPNOTSUPP */ opv_desc_vector = *opv_desc_vector_p; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 8bfc501..a6bae88 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -335,8 +335,7 @@ vfs_rootmountalloc(fstypename, devname, mpp) break; if (vfsp == NULL) return (ENODEV); - mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); - bzero((char *)mp, (u_long)sizeof(struct mount)); + mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE); (void)vfs_busy(mp, LK_NOWAIT, 0, p); LIST_INIT(&mp->mnt_vnodelist); @@ -2322,8 +2321,7 @@ vfs_hang_addrlist(mp, nep, argp) return (0); } i = sizeof(struct netcred) + argp->ex_addrlen + argp->ex_masklen; - np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK); - bzero((caddr_t) np, i); + np = (struct netcred *) malloc(i, M_NETADDR, M_WAITOK | M_ZERO); saddr = (struct sockaddr *) (np + 1); if ((error = copyin(argp->ex_addr, (caddr_t) saddr, argp->ex_addrlen))) goto out; diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 59aacb5..5f1a1d4 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -256,8 +256,7 @@ mount(p, uap) /* * Allocate and initialize the filesystem. */ - mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK); - bzero((char *)mp, (u_long)sizeof(struct mount)); + mp = malloc(sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); lockinit(&mp->mnt_lock, PVFS, "vfslock", 0, LK_NOPAUSE); (void)vfs_busy(mp, LK_NOWAIT, 0, p); mp->mnt_op = vfsp->vfc_vfsops; diff --git a/sys/miscfs/union/union_vfsops.c b/sys/miscfs/union/union_vfsops.c index 57a4e98..94cba85 100644 --- a/sys/miscfs/union/union_vfsops.c +++ b/sys/miscfs/union/union_vfsops.c @@ -179,9 +179,7 @@ union_mount(mp, path, data, ndp, p) */ um = (struct union_mount *) malloc(sizeof(struct union_mount), - M_UNIONFSMNT, M_WAITOK); - - bzero(um, sizeof(struct union_mount)); + M_UNIONFSMNT, M_WAITOK | M_ZERO); um->um_op = args.mntflags & UNMNT_OPMASK; diff --git a/sys/msdosfs/msdosfs_vfsops.c b/sys/msdosfs/msdosfs_vfsops.c index 823eb36..30b5522 100644 --- a/sys/msdosfs/msdosfs_vfsops.c +++ b/sys/msdosfs/msdosfs_vfsops.c @@ -176,8 +176,7 @@ msdosfs_mountroot() if (bdevvp(rootdev, &rootvp)) panic("msdosfs_mountroot: can't setup rootvp"); - mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK); - bzero((char *)mp, (u_long)sizeof(struct mount)); + mp = malloc((u_long)sizeof(struct mount), M_MOUNT, M_WAITOK | M_ZERO); mp->mnt_op = &msdosfs_vfsops; mp->mnt_flag = 0; LIST_INIT(&mp->mnt_vnodelist); @@ -464,8 +463,7 @@ mountmsdosfs(devvp, mp, p, argp) } #endif - pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK); - bzero((caddr_t)pmp, sizeof *pmp); + pmp = malloc(sizeof *pmp, M_MSDOSFSMNT, M_WAITOK | M_ZERO); pmp->pm_mountp = mp; /* diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 5ee63df..d2eaa39 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -366,8 +366,7 @@ bpfopen(dev, flags, fmt, p) if ((dev->si_flags & SI_NAMED) == 0) make_dev(&bpf_cdevsw, minor(dev), UID_ROOT, GID_WHEEL, 0600, "bpf%d", dev2unit(dev)); - MALLOC(d, struct bpf_d *, sizeof(*d), M_BPF, M_WAITOK); - bzero(d, sizeof(*d)); + MALLOC(d, struct bpf_d *, sizeof(*d), M_BPF, M_WAITOK | M_ZERO); dev->si_drv1 = d; d->bd_bufsize = bpf_bufsize; d->bd_sig = SIGIO; diff --git a/sys/net/bridge.c b/sys/net/bridge.c index 00fce3a..0ab2cba 100644 --- a/sys/net/bridge.c +++ b/sys/net/bridge.c @@ -443,8 +443,7 @@ bdginit(void *dummy) flush_table(); ifp2sc = malloc(BDG_MAX_PORTS * sizeof(struct bdg_softc), - M_IFADDR, M_WAITOK ); - bzero(ifp2sc, BDG_MAX_PORTS * sizeof(struct bdg_softc) ); + M_IFADDR, M_WAITOK | M_ZERO); bzero(&bdg_stats, sizeof(bdg_stats) ); bdgtakeifaces(); diff --git a/sys/net/if.c b/sys/net/if.c index cb77a31..0c6fc84 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -167,8 +167,7 @@ if_attach(ifp) getmicrotime(&ifp->if_lastchange); if (ifnet_addrs == 0 || if_index >= if_indexlim) { unsigned n = (if_indexlim <<= 1) * sizeof(ifa); - caddr_t q = malloc(n, M_IFADDR, M_WAITOK); - bzero(q, n); + caddr_t q = malloc(n, M_IFADDR, M_WAITOK | M_ZERO); if (ifnet_addrs) { bcopy((caddr_t)ifnet_addrs, (caddr_t)q, n/2); free((caddr_t)ifnet_addrs, M_IFADDR); @@ -177,8 +176,7 @@ if_attach(ifp) /* grow ifindex2ifnet */ n = if_indexlim * sizeof(struct ifnet *); - q = malloc(n, M_IFADDR, M_WAITOK); - bzero(q, n); + q = malloc(n, M_IFADDR, M_WAITOK | M_ZERO); if (ifindex2ifnet) { bcopy((caddr_t)ifindex2ifnet, q, n/2); free((caddr_t)ifindex2ifnet, M_IFADDR); @@ -203,9 +201,8 @@ if_attach(ifp) socksize = sizeof(*sdl); socksize = ROUNDUP(socksize); ifasize = sizeof(*ifa) + 2 * socksize; - ifa = (struct ifaddr *)malloc(ifasize, M_IFADDR, M_WAITOK); + ifa = (struct ifaddr *)malloc(ifasize, M_IFADDR, M_WAITOK | M_ZERO); if (ifa) { - bzero((caddr_t)ifa, ifasize); sdl = (struct sockaddr_dl *)(ifa + 1); sdl->sdl_len = socksize; sdl->sdl_family = AF_LINK; diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c index f8e38ca..4554a29 100644 --- a/sys/net/if_ef.c +++ b/sys/net/if_ef.c @@ -492,10 +492,10 @@ ef_clone(struct ef_link *efl, int ft) char cbuf[IFNAMSIZ], *ifname; int ifnlen; - efp = (struct efnet*)malloc(sizeof(struct efnet), M_IFADDR, M_WAITOK); + efp = (struct efnet*)malloc(sizeof(struct efnet), M_IFADDR, + M_WAITOK | M_ZERO); if (efp == NULL) return ENOMEM; - bzero(efp, sizeof(*efp)); efp->ef_ifp = ifp; eifp = &efp->ef_ac.ac_if; ifnlen = 1 + snprintf(cbuf, sizeof(cbuf), "%s%df", ifp->if_name, diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c index 50888ee..f7bc1f2 100644 --- a/sys/net/if_sl.c +++ b/sys/net/if_sl.c @@ -251,8 +251,7 @@ slcreate() int unit; struct mbuf *m; - MALLOC(sc, struct sl_softc *, sizeof(*sc), M_SL, M_WAITOK); - bzero(sc, sizeof *sc); + MALLOC(sc, struct sl_softc *, sizeof(*sc), M_SL, M_WAITOK | M_ZERO); m = m_gethdr(M_WAIT, MT_DATA); if (m != NULL) { diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c index 6c88075..504c932 100644 --- a/sys/net/if_tap.c +++ b/sys/net/if_tap.c @@ -205,8 +205,7 @@ tapcreate(dev) char *name = NULL; /* allocate driver storage and create device */ - MALLOC(tp, struct tap_softc *, sizeof(*tp), M_TAP, M_WAITOK); - bzero(tp, sizeof(*tp)); + MALLOC(tp, struct tap_softc *, sizeof(*tp), M_TAP, M_WAITOK | M_ZERO); /* select device: tap or vmnet */ if (minor(dev) & VMNET_DEV_MASK) { diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index bc1e2c6..c7047a7 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -147,8 +147,7 @@ tuncreate(dev) dev = make_dev(&tun_cdevsw, minor(dev), UID_UUCP, GID_DIALER, 0600, "tun%d", dev2unit(dev)); - MALLOC(sc, struct tun_softc *, sizeof(*sc), M_TUN, M_WAITOK); - bzero(sc, sizeof *sc); + MALLOC(sc, struct tun_softc *, sizeof(*sc), M_TUN, M_WAITOK | M_ZERO); sc->tun_flags = TUN_INITED; ifp = &sc->tun_if; diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index d778e01..d9b4b10 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -108,10 +108,10 @@ rts_attach(struct socket *so, int proto, struct proc *p) if (sotorawcb(so) != 0) return EISCONN; /* XXX panic? */ - MALLOC(rp, struct rawcb *, sizeof *rp, M_PCB, M_WAITOK); /* XXX */ + /* XXX */ + MALLOC(rp, struct rawcb *, sizeof *rp, M_PCB, M_WAITOK | M_ZERO); if (rp == 0) return ENOBUFS; - bzero(rp, sizeof *rp); /* * The splnet() is necessary to block protocols from sending diff --git a/sys/netatalk/at_control.c b/sys/netatalk/at_control.c index bdaeb6c..3107225 100644 --- a/sys/netatalk/at_control.c +++ b/sys/netatalk/at_control.c @@ -138,8 +138,7 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * allocate a fresh one. */ if ( aa == (struct at_ifaddr *) 0 ) { - aa0 = malloc(sizeof(struct at_ifaddr), M_IFADDR, M_WAITOK); - bzero(aa0, sizeof(struct at_ifaddr)); + aa0 = malloc(sizeof(struct at_ifaddr), M_IFADDR, M_WAITOK | M_ZERO); if (( aa = at_ifaddr ) != NULL ) { /* * Don't let the loopback be first, since the first diff --git a/sys/netatalk/ddp_pcb.c b/sys/netatalk/ddp_pcb.c index 617ab29..7390d8d 100644 --- a/sys/netatalk/ddp_pcb.c +++ b/sys/netatalk/ddp_pcb.c @@ -419,8 +419,7 @@ at_pcballoc( struct socket *so ) { struct ddpcb *ddp; - MALLOC(ddp, struct ddpcb *, sizeof *ddp, M_PCB, M_WAITOK); - bzero(ddp, sizeof *ddp); + MALLOC(ddp, struct ddpcb *, sizeof *ddp, M_PCB, M_WAITOK | M_ZERO); ddp->ddp_lsat.sat_port = ATADDR_ANYPORT; ddp->ddp_next = ddpcb; diff --git a/sys/netatalk/ddp_usrreq.c b/sys/netatalk/ddp_usrreq.c index 617ab29..7390d8d 100644 --- a/sys/netatalk/ddp_usrreq.c +++ b/sys/netatalk/ddp_usrreq.c @@ -419,8 +419,7 @@ at_pcballoc( struct socket *so ) { struct ddpcb *ddp; - MALLOC(ddp, struct ddpcb *, sizeof *ddp, M_PCB, M_WAITOK); - bzero(ddp, sizeof *ddp); + MALLOC(ddp, struct ddpcb *, sizeof *ddp, M_PCB, M_WAITOK | M_ZERO); ddp->ddp_lsat.sat_port = ATADDR_ANYPORT; ddp->ddp_next = ddpcb; diff --git a/sys/netinet/in.c b/sys/netinet/in.c index 7dcfe87..f8d591e 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -283,10 +283,9 @@ in_control(so, cmd, data, ifp, p) return (EADDRNOTAVAIL); if (ia == (struct in_ifaddr *)0) { ia = (struct in_ifaddr *) - malloc(sizeof *ia, M_IFADDR, M_WAITOK); + malloc(sizeof *ia, M_IFADDR, M_WAITOK | M_ZERO); if (ia == (struct in_ifaddr *)NULL) return (ENOBUFS); - bzero((caddr_t)ia, sizeof *ia); /* * Protect from ipintr() traversing address list * while we're modifying it. @@ -802,13 +801,13 @@ in_addmulti(ap, ifp) /* XXX - if_addmulti uses M_WAITOK. Can this really be called at interrupt time? If so, need to fix if_addmulti. XXX */ - inm = (struct in_multi *)malloc(sizeof(*inm), M_IPMADDR, M_NOWAIT); + inm = (struct in_multi *)malloc(sizeof(*inm), M_IPMADDR, + M_NOWAIT | M_ZERO); if (inm == NULL) { splx(s); return (NULL); } - bzero(inm, sizeof *inm); inm->inm_addr = *ap; inm->inm_ifp = ifp; inm->inm_ifma = ifma; diff --git a/sys/netinet/in_hostcache.c b/sys/netinet/in_hostcache.c index 33e0187..36a92fd 100644 --- a/sys/netinet/in_hostcache.c +++ b/sys/netinet/in_hostcache.c @@ -78,8 +78,8 @@ inhc_alloc(struct sockaddr_in *sin) if (rt == 0) return 0; - MALLOC(inhc, struct in_hcentry *, sizeof *inhc, M_HOSTCACHE, M_WAITOK); - bzero(inhc, sizeof *inhc); + MALLOC(inhc, struct in_hcentry *, sizeof *inhc, M_HOSTCACHE, + M_WAITOK | M_ZERO); inhc->inhc_hc.hc_host = dup_sockaddr((struct sockaddr *)sin, 1); if (in_broadcast(sin->sin_addr, rt->rt_ifp)) inhc->inhc_flags |= INHC_BROADCAST; diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 4fc9b92..fd0f248 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -605,8 +605,8 @@ in_setsockaddr(so, nam) /* * Do the malloc first in case it blocks. */ - MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, M_WAITOK); - bzero(sin, sizeof *sin); + MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, + M_WAITOK | M_ZERO); sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); @@ -637,8 +637,8 @@ in_setpeeraddr(so, nam) /* * Do the malloc first in case it blocks. */ - MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, M_WAITOK); - bzero(sin, sizeof (*sin)); + MALLOC(sin, struct sockaddr_in *, sizeof *sin, M_SONAME, + M_WAITOK | M_ZERO); sin->sin_family = AF_INET; sin->sin_len = sizeof(*sin); diff --git a/sys/netinet/ip_dummynet.c b/sys/netinet/ip_dummynet.c index f8882bb..ed43449 100644 --- a/sys/netinet/ip_dummynet.c +++ b/sys/netinet/ip_dummynet.c @@ -751,12 +751,11 @@ create_queue(struct dn_flow_set *fs, int i) if ( fs->rq[i] != NULL ) return fs->rq[i] ; } - q = malloc(sizeof(*q), M_IPFW, M_DONTWAIT) ; + q = malloc(sizeof(*q), M_IPFW, M_DONTWAIT | M_ZERO); /* M_ZERO needed */ if (q == NULL) { printf("sorry, cannot allocate queue for new flow\n"); return NULL ; } - bzero(q, sizeof(*q) ); /* needed */ q->fs = fs ; q->hash_slot = i ; q->next = fs->rq[i] ; @@ -1011,11 +1010,11 @@ dummynet_io(int pipe_nr, int dir, /* pipe_nr can also be a fs_nr */ if ( fs->flags_fs & DN_IS_RED && red_drops(fs, q, len) ) goto dropit ; - pkt = (struct dn_pkt *)malloc(sizeof (*pkt), M_IPFW, M_NOWAIT) ; + /* XXX expensive to zero, see if we can remove it*/ + pkt = (struct dn_pkt *)malloc(sizeof (*pkt), M_IPFW, M_NOWAIT | M_ZERO); if ( pkt == NULL ) goto dropit ; /* cannot allocate packet header */ /* ok, i can handle the pkt now... */ - bzero(pkt, sizeof(*pkt) ); /* XXX expensive, see if we can remove it*/ /* build and enqueue packet + parameters */ pkt->hdr.mh_type = MT_DUMMYNET ; (struct ip_fw_chain *)pkt->hdr.mh_data = rule ; @@ -1322,12 +1321,11 @@ alloc_hash(struct dn_flow_set *x, struct dn_flow_set *pfs) } else /* one is enough for null mask */ x->rq_size = 1; x->rq = malloc((1 + x->rq_size) * sizeof(struct dn_flow_queue *), - M_IPFW, M_DONTWAIT); + M_IPFW, M_DONTWAIT | M_ZERO); if (x->rq == NULL) { printf("sorry, cannot allocate queue\n"); return ENOSPC; } - bzero(x->rq, (1+x->rq_size) * sizeof(struct dn_flow_queue *)); x->rq_elements = 0; return 0 ; } @@ -1382,12 +1380,11 @@ config_pipe(struct dn_pipe *p) a = b , b = b->next) ; if (b == NULL || b->pipe_nr != p->pipe_nr) { /* new pipe */ - x = malloc(sizeof(struct dn_pipe), M_IPFW, M_DONTWAIT) ; + x = malloc(sizeof(struct dn_pipe), M_IPFW, M_DONTWAIT | M_ZERO); if (x == NULL) { printf("ip_dummynet.c: no memory for new pipe\n"); return ENOSPC; } - bzero(x, sizeof(struct dn_pipe)); x->pipe_nr = p->pipe_nr; x->fs.pipe = x ; x->backlogged_heap.size = x->backlogged_heap.elements = 0 ; @@ -1427,12 +1424,11 @@ config_pipe(struct dn_pipe *p) if (b == NULL || b->fs_nr != pfs->fs_nr) { /* new */ if (pfs->parent_nr == 0) /* need link to a pipe */ return EINVAL ; - x = malloc(sizeof(struct dn_flow_set), M_IPFW, M_DONTWAIT); + x = malloc(sizeof(struct dn_flow_set), M_IPFW, M_DONTWAIT | M_ZERO); if (x == NULL) { printf("ip_dummynet.c: no memory for new flow_set\n"); return ENOSPC; } - bzero(x, sizeof(struct dn_flow_set)); x->fs_nr = pfs->fs_nr; x->parent_nr = pfs->parent_nr; x->weight = pfs->weight ; diff --git a/sys/netinet/ip_fw.c b/sys/netinet/ip_fw.c index fbbaa9e..7e69223 100644 --- a/sys/netinet/ip_fw.c +++ b/sys/netinet/ip_fw.c @@ -804,20 +804,18 @@ add_dyn_rule(struct ipfw_flow_id *id, struct ipfw_flow_id *mask, if (ipfw_dyn_v != NULL) free(ipfw_dyn_v, M_IPFW); ipfw_dyn_v = malloc(curr_dyn_buckets * sizeof r, - M_IPFW, M_DONTWAIT); + M_IPFW, M_DONTWAIT | M_ZERO); if (ipfw_dyn_v == NULL) return ; /* failed ! */ - bzero(ipfw_dyn_v, curr_dyn_buckets * sizeof r); } } i = hash_packet(id); - r = malloc(sizeof *r, M_IPFW, M_DONTWAIT); + r = malloc(sizeof *r, M_IPFW, M_DONTWAIT | M_ZERO); if (r == NULL) { printf ("sorry cannot allocate state\n"); return ; } - bzero (r, sizeof (*r) ); if (mask) r->mask = *mask ; @@ -1465,7 +1463,7 @@ add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl) int s; fwc = malloc(sizeof *fwc, M_IPFW, M_DONTWAIT); - ftmp_ext = malloc(sizeof *ftmp_ext, M_IPFW, M_DONTWAIT); + ftmp_ext = malloc(sizeof *ftmp_ext, M_IPFW, M_DONTWAIT | M_ZERO); ftmp = &ftmp_ext->rule ; if (!fwc || !ftmp) { dprintf(("%s malloc said no\n", err_prefix)); @@ -1474,7 +1472,6 @@ add_entry(struct ip_fw_head *chainptr, struct ip_fw *frwl) return (ENOSPC); } - bzero(ftmp_ext, sizeof(*ftmp_ext)); /* play safe! */ bcopy(frwl, ftmp, sizeof(*ftmp)); if (ftmp->fw_flg & IP_FW_F_RND_MATCH) ftmp_ext->dont_match_prob = (intptr_t)ftmp->pipe_ptr; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 1f7d0fb..cb7e05e 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1050,10 +1050,9 @@ findpcb: #ifdef INET6 if (isipv6) { MALLOC(sin6, struct sockaddr_in6 *, sizeof *sin6, - M_SONAME, M_NOWAIT); + M_SONAME, M_NOWAIT | M_ZERO); if (sin6 == NULL) goto drop; - bzero(sin6, sizeof(*sin6)); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); sin6->sin6_addr = ip6->ip6_src; diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index 1f7d0fb..cb7e05e 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -1050,10 +1050,9 @@ findpcb: #ifdef INET6 if (isipv6) { MALLOC(sin6, struct sockaddr_in6 *, sizeof *sin6, - M_SONAME, M_NOWAIT); + M_SONAME, M_NOWAIT | M_ZERO); if (sin6 == NULL) goto drop; - bzero(sin6, sizeof(*sin6)); sin6->sin6_family = AF_INET6; sin6->sin6_len = sizeof(*sin6); sin6->sin6_addr = ip6->ip6_src; diff --git a/sys/netipx/ipx.c b/sys/netipx/ipx.c index 7ba85ae..6dfc32f 100644 --- a/sys/netipx/ipx.c +++ b/sys/netipx/ipx.c @@ -129,10 +129,10 @@ ipx_control(so, cmd, data, ifp, p) case SIOCSIFDSTADDR: if (ia == NULL) { oia = (struct ipx_ifaddr *) - malloc(sizeof(*ia), M_IFADDR, M_WAITOK); + malloc(sizeof(*ia), M_IFADDR, + M_WAITOK | M_ZERO); if (oia == NULL) return (ENOBUFS); - bzero((caddr_t)oia, sizeof(*oia)); if ((ia = ipx_ifaddr) != NULL) { for ( ; ia->ia_next != NULL; ia = ia->ia_next) ; diff --git a/sys/netipx/ipx_ip.c b/sys/netipx/ipx_ip.c index 9062d3b..042d276 100644 --- a/sys/netipx/ipx_ip.c +++ b/sys/netipx/ipx_ip.c @@ -101,10 +101,9 @@ ipxipattach() ifp->if_flags = IFF_POINTOPOINT; } - MALLOC((m), struct ifnet_en *, sizeof(*m), M_PCB, M_NOWAIT); + MALLOC((m), struct ifnet_en *, sizeof(*m), M_PCB, M_NOWAIT | M_ZERO); if (m == NULL) return (NULL); - bzero(m, sizeof(*m)); m->ifen_next = ipxip_list; ipxip_list = m; ifp = &m->ifen_ifnet; diff --git a/sys/netipx/ipx_pcb.c b/sys/netipx/ipx_pcb.c index 61af5c3..0ae2462 100644 --- a/sys/netipx/ipx_pcb.c +++ b/sys/netipx/ipx_pcb.c @@ -60,10 +60,9 @@ ipx_pcballoc(so, head, p) { register struct ipxpcb *ipxp; - MALLOC(ipxp, struct ipxpcb *, sizeof *ipxp, M_PCB, M_NOWAIT); + MALLOC(ipxp, struct ipxpcb *, sizeof *ipxp, M_PCB, M_NOWAIT | M_ZERO); if (ipxp == NULL) return (ENOBUFS); - bzero(ipxp, sizeof *ipxp); ipxp->ipxp_socket = so; if (ipxcksum) ipxp->ipxp_flags |= IPXP_CHECKSUM; diff --git a/sys/netipx/spx_usrreq.c b/sys/netipx/spx_usrreq.c index be8eb97..eef2445 100644 --- a/sys/netipx/spx_usrreq.c +++ b/sys/netipx/spx_usrreq.c @@ -1330,13 +1330,12 @@ spx_attach(so, proto, p) } ipxp = sotoipxpcb(so); - MALLOC(cb, struct spxpcb *, sizeof *cb, M_PCB, M_NOWAIT); + MALLOC(cb, struct spxpcb *, sizeof *cb, M_PCB, M_NOWAIT | M_ZERO); if (cb == NULL) { error = ENOBUFS; goto spx_attach_end; } - bzero(cb, sizeof *cb); sb = &so->so_snd; mm = m_getclr(M_DONTWAIT, MT_HEADER); diff --git a/sys/netnatm/natm_pcb.c b/sys/netnatm/natm_pcb.c index 2ce9a30..46bcb7c 100644 --- a/sys/netnatm/natm_pcb.c +++ b/sys/netnatm/natm_pcb.c @@ -63,16 +63,15 @@ int wait; { struct natmpcb *npcb; - MALLOC(npcb, struct natmpcb *, sizeof(*npcb), M_PCB, wait); + MALLOC(npcb, struct natmpcb *, sizeof(*npcb), M_PCB, wait | M_ZERO); #ifdef DIAGNOSTIC if (wait == M_WAITOK && npcb == NULL) panic("npcb_alloc: malloc didn't wait"); #endif - if (npcb) { - bzero(npcb, sizeof(*npcb)); + if (npcb) npcb->npcb_flags = NPCB_FREE; - } + return(npcb); } diff --git a/sys/nfs/nfs_nqlease.c b/sys/nfs/nfs_nqlease.c index 2ff330e..6669010 100644 --- a/sys/nfs/nfs_nqlease.c +++ b/sys/nfs/nfs_nqlease.c @@ -262,8 +262,7 @@ nqsrv_getlease(vp, duration, flags, slp, procp, nam, cachablep, frev, cred) if (!ok) { *lphp = (struct nqm *) malloc(sizeof (struct nqm), - M_NQMHOST, M_WAITOK); - bzero((caddr_t)*lphp, sizeof (struct nqm)); + M_NQMHOST, M_WAITOK | M_ZERO); lph = (*lphp)->lpm_hosts; } nqsrv_addhost(lph, slp, nam); @@ -307,8 +306,8 @@ doreply: "nqsrvnuml", 0); } while (nfsstats.srvnqnfs_leases > nqsrv_maxnumlease); } - MALLOC(lp, struct nqlease *, sizeof (struct nqlease), M_NQLEASE, M_WAITOK); - bzero((caddr_t)lp, sizeof (struct nqlease)); + MALLOC(lp, struct nqlease *, sizeof (struct nqlease), M_NQLEASE, + M_WAITOK | M_ZERO); if (flags & ND_WRITE) lp->lc_flag |= (LC_WRITE | LC_WRITTEN); nqsrv_addhost(&lp->lc_host, slp, nam); diff --git a/sys/nfs/nfs_srvcache.c b/sys/nfs/nfs_srvcache.c index 9eb168f..99fae0e 100644 --- a/sys/nfs/nfs_srvcache.c +++ b/sys/nfs/nfs_srvcache.c @@ -220,8 +220,7 @@ loop: NFS_DPF(RC, ("M%03x", nd->nd_retxid & 0xfff)); if (numnfsrvcache < desirednfsrvcache) { rp = (struct nfsrvcache *)malloc((u_long)sizeof *rp, - M_NFSD, M_WAITOK); - bzero((char *)rp, sizeof *rp); + M_NFSD, M_WAITOK | M_ZERO); numnfsrvcache++; rp->rc_flag = RC_LOCKED; } else { diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 83cc56b..d1a8ead 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -388,8 +388,8 @@ nfssvc_addsock(fp, mynam, p) so->so_snd.sb_timeo = 0; slp = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)slp, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, + M_WAITOK | M_ZERO); STAILQ_INIT(&slp->ns_rec); TAILQ_INIT(&slp->ns_uidlruhead); TAILQ_INSERT_TAIL(&nfssvc_sockhead, slp, ns_chain); @@ -433,8 +433,7 @@ nfssvc_nfsd(nsd, argp, p) #endif if (nfsd == (struct nfsd *)0) { nsd->nsd_nfsd = nfsd = (struct nfsd *) - malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK); - bzero((caddr_t)nfsd, sizeof (struct nfsd)); + malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK | M_ZERO); s = splnet(); nfsd->nfsd_procp = p; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); @@ -853,15 +852,13 @@ nfsrv_init(terminating) #if 0 nfs_udpsock = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)nfs_udpsock, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); STAILQ_INIT(&nfs_udpsock->ns_rec); TAILQ_INIT(&nfs_udpsock->ns_uidlruhead); TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain); nfs_cltpsock = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)nfs_cltpsock, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); STAILQ_INIT(&nfs_cltpsock->ns_rec); TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead); TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain); diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c index 83cc56b..d1a8ead 100644 --- a/sys/nfsclient/nfs_nfsiod.c +++ b/sys/nfsclient/nfs_nfsiod.c @@ -388,8 +388,8 @@ nfssvc_addsock(fp, mynam, p) so->so_snd.sb_timeo = 0; slp = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)slp, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, + M_WAITOK | M_ZERO); STAILQ_INIT(&slp->ns_rec); TAILQ_INIT(&slp->ns_uidlruhead); TAILQ_INSERT_TAIL(&nfssvc_sockhead, slp, ns_chain); @@ -433,8 +433,7 @@ nfssvc_nfsd(nsd, argp, p) #endif if (nfsd == (struct nfsd *)0) { nsd->nsd_nfsd = nfsd = (struct nfsd *) - malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK); - bzero((caddr_t)nfsd, sizeof (struct nfsd)); + malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK | M_ZERO); s = splnet(); nfsd->nfsd_procp = p; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); @@ -853,15 +852,13 @@ nfsrv_init(terminating) #if 0 nfs_udpsock = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)nfs_udpsock, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); STAILQ_INIT(&nfs_udpsock->ns_rec); TAILQ_INIT(&nfs_udpsock->ns_uidlruhead); TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain); nfs_cltpsock = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)nfs_cltpsock, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); STAILQ_INIT(&nfs_cltpsock->ns_rec); TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead); TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain); diff --git a/sys/nfsserver/nfs_srvcache.c b/sys/nfsserver/nfs_srvcache.c index 9eb168f..99fae0e 100644 --- a/sys/nfsserver/nfs_srvcache.c +++ b/sys/nfsserver/nfs_srvcache.c @@ -220,8 +220,7 @@ loop: NFS_DPF(RC, ("M%03x", nd->nd_retxid & 0xfff)); if (numnfsrvcache < desirednfsrvcache) { rp = (struct nfsrvcache *)malloc((u_long)sizeof *rp, - M_NFSD, M_WAITOK); - bzero((char *)rp, sizeof *rp); + M_NFSD, M_WAITOK | M_ZERO); numnfsrvcache++; rp->rc_flag = RC_LOCKED; } else { diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index 83cc56b..d1a8ead 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -388,8 +388,8 @@ nfssvc_addsock(fp, mynam, p) so->so_snd.sb_timeo = 0; slp = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)slp, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, + M_WAITOK | M_ZERO); STAILQ_INIT(&slp->ns_rec); TAILQ_INIT(&slp->ns_uidlruhead); TAILQ_INSERT_TAIL(&nfssvc_sockhead, slp, ns_chain); @@ -433,8 +433,7 @@ nfssvc_nfsd(nsd, argp, p) #endif if (nfsd == (struct nfsd *)0) { nsd->nsd_nfsd = nfsd = (struct nfsd *) - malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK); - bzero((caddr_t)nfsd, sizeof (struct nfsd)); + malloc(sizeof (struct nfsd), M_NFSD, M_WAITOK | M_ZERO); s = splnet(); nfsd->nfsd_procp = p; TAILQ_INSERT_TAIL(&nfsd_head, nfsd, nfsd_chain); @@ -853,15 +852,13 @@ nfsrv_init(terminating) #if 0 nfs_udpsock = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)nfs_udpsock, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); STAILQ_INIT(&nfs_udpsock->ns_rec); TAILQ_INIT(&nfs_udpsock->ns_uidlruhead); TAILQ_INSERT_HEAD(&nfssvc_sockhead, nfs_udpsock, ns_chain); nfs_cltpsock = (struct nfssvc_sock *) - malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK); - bzero((caddr_t)nfs_cltpsock, sizeof (struct nfssvc_sock)); + malloc(sizeof (struct nfssvc_sock), M_NFSSVC, M_WAITOK | M_ZERO); STAILQ_INIT(&nfs_cltpsock->ns_rec); TAILQ_INIT(&nfs_cltpsock->ns_uidlruhead); TAILQ_INSERT_TAIL(&nfssvc_sockhead, nfs_cltpsock, ns_chain); diff --git a/sys/ntfs/ntfs_subr.c b/sys/ntfs/ntfs_subr.c index 839f752..d9b38d4 100644 --- a/sys/ntfs/ntfs_subr.c +++ b/sys/ntfs/ntfs_subr.c @@ -394,10 +394,9 @@ ntfs_ntlookup( } } while (LOCKMGR(&ntfs_hashlock, LK_EXCLUSIVE | LK_SLEEPFAIL, NULL)); - MALLOC(ip, struct ntnode *, sizeof(struct ntnode), - M_NTFSNTNODE, M_WAITOK); + MALLOC(ip, struct ntnode *, sizeof(struct ntnode), M_NTFSNTNODE, + M_WAITOK | M_ZERO); ddprintf(("ntfs_ntlookup: allocating ntnode: %d: %p\n", ino, ip)); - bzero((caddr_t) ip, sizeof(struct ntnode)); /* Generic initialization */ ip->i_devvp = ntmp->ntm_devvp; @@ -544,8 +543,7 @@ ntfs_attrtontvattr( *rvapp = NULL; MALLOC(vap, struct ntvattr *, sizeof(struct ntvattr), - M_NTFSNTVATTR, M_WAITOK); - bzero(vap, sizeof(struct ntvattr)); + M_NTFSNTVATTR, M_WAITOK | M_ZERO); vap->va_ip = NULL; vap->va_flag = rap->a_hdr.a_flag; vap->va_type = rap->a_hdr.a_type; @@ -737,8 +735,8 @@ ntfs_fget( if (*fpp) return (0); - MALLOC(fp, struct fnode *, sizeof(struct fnode), M_NTFSFNODE, M_WAITOK); - bzero(fp, sizeof(struct fnode)); + MALLOC(fp, struct fnode *, sizeof(struct fnode), M_NTFSFNODE, + M_WAITOK | M_ZERO); dprintf(("ntfs_fget: allocating fnode: %p\n",fp)); fp->f_ip = ip; diff --git a/sys/ntfs/ntfs_vfsops.c b/sys/ntfs/ntfs_vfsops.c index e5a0216..7c6b2c0 100644 --- a/sys/ntfs/ntfs_vfsops.c +++ b/sys/ntfs/ntfs_vfsops.c @@ -478,8 +478,7 @@ ntfs_mountfs(devvp, mp, argsp, p) error = bread(devvp, BBLOCK, BBSIZE, NOCRED, &bp); if (error) goto out; - ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK ); - bzero( ntmp, sizeof *ntmp ); + ntmp = malloc( sizeof *ntmp, M_NTFSMNT, M_WAITOK | M_ZERO); bcopy( bp->b_data, &ntmp->ntm_bootfile, sizeof(struct bootfile) ); brelse( bp ); bp = NULL; diff --git a/sys/pc98/cbus/fdc.c b/sys/pc98/cbus/fdc.c index a58019b..1b21f64 100644 --- a/sys/pc98/cbus/fdc.c +++ b/sys/pc98/cbus/fdc.c @@ -1027,10 +1027,9 @@ fdc_add_child(device_t dev, const char *name, int unit) struct fdc_ivars *ivar; device_t child; - ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT); + ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT | M_ZERO); if (ivar == NULL) return; - bzero(ivar, sizeof *ivar); if (resource_int_value(name, unit, "drive", &ivar->fdunit) != 0) ivar->fdunit = 0; child = device_add_child(dev, name, unit); diff --git a/sys/pc98/i386/userconfig.c b/sys/pc98/i386/userconfig.c index 4ded4f7..aa3a798 100644 --- a/sys/pc98/i386/userconfig.c +++ b/sys/pc98/i386/userconfig.c @@ -3257,8 +3257,8 @@ load_devtab(void) char *name; int unit; - uc_devtab = malloc(sizeof(struct uc_device)*(count + 1),M_DEVL,M_WAITOK); - bzero(uc_devtab, sizeof(struct uc_device) * (count + 1)); + uc_devtab = malloc(sizeof(struct uc_device) * (count + 1), M_DEVL, + M_WAITOK | M_ZERO); dt = 0; for (i = 0; i < count; i++) { name = resource_query_name(i); diff --git a/sys/pc98/pc98/fd.c b/sys/pc98/pc98/fd.c index a58019b..1b21f64 100644 --- a/sys/pc98/pc98/fd.c +++ b/sys/pc98/pc98/fd.c @@ -1027,10 +1027,9 @@ fdc_add_child(device_t dev, const char *name, int unit) struct fdc_ivars *ivar; device_t child; - ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT); + ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT | M_ZERO); if (ivar == NULL) return; - bzero(ivar, sizeof *ivar); if (resource_int_value(name, unit, "drive", &ivar->fdunit) != 0) ivar->fdunit = 0; child = device_add_child(dev, name, unit); diff --git a/sys/pc98/pc98/syscons.c b/sys/pc98/pc98/syscons.c index 3bdc003..554432d 100644 --- a/sys/pc98/pc98/syscons.c +++ b/sys/pc98/pc98/syscons.c @@ -2563,8 +2563,7 @@ scinit(int unit, int flags) kernel_default.rev_color); } else { /* assert(sc_malloc) */ - sc->dev = malloc(sizeof(dev_t)*sc->vtys, M_DEVBUF, M_WAITOK); - bzero(sc->dev, sizeof(dev_t)*sc->vtys); + sc->dev = malloc(sizeof(dev_t)*sc->vtys, M_DEVBUF, M_WAITOK|M_ZERO); sc->dev[0] = makedev(CDEV_MAJOR, unit*MAXCONS); sc->dev[0]->si_tty = ttymalloc(sc->dev[0]->si_tty); scp = alloc_scp(sc, sc->first_vty); diff --git a/sys/pc98/pc98/wd.c b/sys/pc98/pc98/wd.c index 7f6ebe0..3b96e817 100644 --- a/sys/pc98/pc98/wd.c +++ b/sys/pc98/pc98/wd.c @@ -302,10 +302,9 @@ wdprobe(struct isa_device *dvp) if (unit >= NWDC) return (0); - du = malloc(sizeof *du, M_TEMP, M_NOWAIT); + du = malloc(sizeof *du, M_TEMP, M_NOWAIT | M_ZERO); if (du == NULL) return (0); - bzero(du, sizeof *du); du->dk_ctrlr = dvp->id_unit; interface = du->dk_ctrlr / 2; du->dk_interface = interface; @@ -511,14 +510,13 @@ wdattach(struct isa_device *dvp) if (resource_int_value("wd", lunit, "flags", &flags) != 0) flags = 0; - du = malloc(sizeof *du, M_TEMP, M_NOWAIT); + du = malloc(sizeof *du, M_TEMP, M_NOWAIT | M_ZERO); if (du == NULL) continue; if (wddrives[lunit] != NULL) panic("drive attached twice"); wddrives[lunit] = du; bioq_init(&drive_queue[lunit]); - bzero(du, sizeof *du); du->dk_ctrlr = dvp->id_unit; if (eide_quirks & Q_CMD640B) { du->dk_ctrlr_cmd640 = PRIMARY; diff --git a/sys/pc98/pc98/wd_cd.c b/sys/pc98/pc98/wd_cd.c index 14b7f6c..f1cca1b 100644 --- a/sys/pc98/pc98/wd_cd.c +++ b/sys/pc98/pc98/wd_cd.c @@ -107,9 +107,8 @@ acd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun, { struct acd *ptr; - if (!(ptr = malloc(sizeof(struct acd), M_TEMP, M_NOWAIT))) + if (!(ptr = malloc(sizeof(struct acd), M_TEMP, M_NOWAIT | M_ZERO))) return NULL; - bzero(ptr, sizeof(struct acd)); bioq_init(&ptr->bio_queue); ptr->ata = ata; ptr->unit = unit; @@ -123,9 +122,8 @@ acd_init_lun(struct atapi *ata, int unit, struct atapi_params *ap, int lun, ptr->changer_info = NULL; if (device_stats == NULL) { if (!(ptr->device_stats = malloc(sizeof(struct devstat), - M_TEMP, M_NOWAIT))) + M_TEMP, M_NOWAIT | M_ZERO))) return NULL; - bzero(ptr->device_stats, sizeof(struct devstat)); } else ptr->device_stats = device_stats; @@ -199,12 +197,11 @@ acdattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug) char string[16]; struct acd *tmpcdp = cdp; - chp = malloc(sizeof(struct changer), M_TEMP, M_NOWAIT); + chp = malloc(sizeof(struct changer), M_TEMP, M_NOWAIT | M_ZERO); if (chp == NULL) { printf("wcd: out of memory\n"); return 0; } - bzero(chp, sizeof(struct changer)); result = atapi_request_immediate(ata, unit, ATAPI_MECH_STATUS, 0, 0, 0, 0, 0, 0, 0, sizeof(struct changer)>>8, diff --git a/sys/pc98/pc98/wfd.c b/sys/pc98/pc98/wfd.c index 439769f..2ead84e 100644 --- a/sys/pc98/pc98/wfd.c +++ b/sys/pc98/pc98/wfd.c @@ -180,13 +180,12 @@ wfdattach (struct atapi *ata, int unit, struct atapi_params *ap, int debug) printf("wfd: check `options ATAPI_STATIC' in your kernel config file!\n"); return (0); } - t = malloc (sizeof (struct wfd), M_TEMP, M_NOWAIT); + t = malloc (sizeof (struct wfd), M_TEMP, M_NOWAIT | M_ZERO); if (! t) { printf ("wfd: out of memory\n"); return (0); } wfdtab[wfdnlun] = t; - bzero (t, sizeof (struct wfd)); bioq_init(&t->buf_queue); t->ata = ata; t->unit = unit; diff --git a/sys/pc98/pc98/wst.c b/sys/pc98/pc98/wst.c index 3e34a38..3260471 100644 --- a/sys/pc98/pc98/wst.c +++ b/sys/pc98/pc98/wst.c @@ -235,13 +235,12 @@ wstattach(struct atapi *ata, int unit, struct atapi_params *ap, int debug) "wst: check `options ATAPI_STATIC' in your kernel config file!\n"); return(-1); } - t = malloc(sizeof(struct wst), M_TEMP, M_NOWAIT); + t = malloc(sizeof(struct wst), M_TEMP, M_NOWAIT | M_ZERO); if (!t) { printf("wst: out of memory\n"); return(-1); } wsttab[wstnlun] = t; - bzero(t, sizeof(struct wst)); bioq_init(&t->buf_queue); t->ata = ata; t->unit = unit; diff --git a/sys/pci/if_fxp.c b/sys/pci/if_fxp.c index 6544f56..13cd0fd 100644 --- a/sys/pci/if_fxp.c +++ b/sys/pci/if_fxp.c @@ -587,15 +587,14 @@ fxp_attach_common(sc, enaddr) DELAY(10); sc->cbl_base = malloc(sizeof(struct fxp_cb_tx) * FXP_NTXCB, - M_DEVBUF, M_NOWAIT); + M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->cbl_base == NULL) goto fail; - bzero(sc->cbl_base, sizeof(struct fxp_cb_tx) * FXP_NTXCB); - sc->fxp_stats = malloc(sizeof(struct fxp_stats), M_DEVBUF, M_NOWAIT); + sc->fxp_stats = malloc(sizeof(struct fxp_stats), M_DEVBUF, + M_NOWAIT | M_ZERO); if (sc->fxp_stats == NULL) goto fail; - bzero(sc->fxp_stats, sizeof(struct fxp_stats)); sc->mcsp = malloc(sizeof(struct fxp_cb_mcs), M_DEVBUF, M_NOWAIT); if (sc->mcsp == NULL) diff --git a/sys/pci/if_mn.c b/sys/pci/if_mn.c index 703c6e5..8c222ba 100644 --- a/sys/pci/if_mn.c +++ b/sys/pci/if_mn.c @@ -724,8 +724,7 @@ mn_create_channel(struct softc *sc, int chan) struct schan *sch; sch = sc->ch[chan] = (struct schan *)malloc(sizeof *sc->ch[chan], - M_MN, M_WAITOK); - bzero(sch, sizeof *sch); + M_MN, M_WAITOK | M_ZERO); sch->sc = sc; sch->state = DOWN; sch->chan = chan; @@ -1216,8 +1215,7 @@ mn_attach (device_t self) once++; } - sc = (struct softc *)malloc(sizeof *sc, M_MN, M_WAITOK); - bzero(sc, sizeof *sc); + sc = (struct softc *)malloc(sizeof *sc, M_MN, M_WAITOK | M_ZERO); device_set_softc(self, sc); sc->dev = self; diff --git a/sys/pci/if_tx.c b/sys/pci/if_tx.c index 0080611..ca2a89d 100644 --- a/sys/pci/if_tx.c +++ b/sys/pci/if_tx.c @@ -747,13 +747,12 @@ epic_common_attach(sc) i = sizeof(struct epic_frag_list)*TX_RING_SIZE + sizeof(struct epic_rx_desc)*RX_RING_SIZE + sizeof(struct epic_tx_desc)*TX_RING_SIZE + PAGE_SIZE, - sc->pool = (epic_softc_t *) malloc( i, M_DEVBUF, M_NOWAIT); + sc->pool = (epic_softc_t *) malloc(i, M_DEVBUF, M_NOWAIT | M_ZERO); if (sc->pool == NULL) { printf(": can't allocate memory for buffers\n"); return -1; } - bzero(sc->pool, i); /* Align pool on PAGE_SIZE */ pool = (caddr_t)sc->pool; diff --git a/sys/pci/isp_pci.c b/sys/pci/isp_pci.c index 683ac4a..b559906 100644 --- a/sys/pci/isp_pci.c +++ b/sys/pci/isp_pci.c @@ -317,12 +317,11 @@ isp_pci_attach(device_t dev) } } - pcs = malloc(sizeof (struct isp_pcisoftc), M_DEVBUF, M_NOWAIT); + pcs = malloc(sizeof (struct isp_pcisoftc), M_DEVBUF, M_NOWAIT | M_ZERO); if (pcs == NULL) { device_printf(dev, "cannot allocate softc\n"); return (ENOMEM); } - bzero(pcs, sizeof (struct isp_pcisoftc)); /* * Figure out which we should try first - memory mapping or i/o mapping? @@ -443,12 +442,11 @@ isp_pci_attach(device_t dev) PCI_MBOX_REGS2100_OFF; } isp = &pcs->pci_isp; - isp->isp_param = malloc(psize, M_DEVBUF, M_NOWAIT); + isp->isp_param = malloc(psize, M_DEVBUF, M_NOWAIT | M_ZERO); if (isp->isp_param == NULL) { device_printf(dev, "cannot allocate parameter data\n"); goto bad; } - bzero(isp->isp_param, psize); isp->isp_mdvec = mdvp; isp->isp_type = basetype; isp->isp_revision = pci_get_revid(dev); @@ -850,12 +848,11 @@ isp_pci_mbxdma(struct ispsoftc *isp) } len = sizeof (XS_T **) * isp->isp_maxcmds; - isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK); + isp->isp_xflist = (XS_T **) malloc(len, M_DEVBUF, M_WAITOK | M_ZERO); if (isp->isp_xflist == NULL) { isp_prt(isp, ISP_LOGERR, "cannot alloc xflist array"); return (1); } - bzero(isp->isp_xflist, len); len = sizeof (bus_dmamap_t) * isp->isp_maxcmds; pci->dmaps = (bus_dmamap_t *) malloc(len, M_DEVBUF, M_WAITOK); if (pci->dmaps == NULL) { diff --git a/sys/pci/ncr.c b/sys/pci/ncr.c index c30e922..fd5d9c0 100644 --- a/sys/pci/ncr.c +++ b/sys/pci/ncr.c @@ -6533,13 +6533,13 @@ ncr_alloc_nccb (ncb_p np, u_long target, u_long lun) /* ** Allocate a lcb */ - lp = (lcb_p) malloc (sizeof (struct lcb), M_DEVBUF, M_NOWAIT); + lp = (lcb_p) malloc (sizeof (struct lcb), M_DEVBUF, + M_NOWAIT | M_ZERO); if (!lp) return(NULL); /* ** Initialize it */ - bzero (lp, sizeof (*lp)); lp->jump_lcb.l_cmd = (SCR_JUMP ^ IFFALSE (DATA (lun))); lp->jump_lcb.l_paddr = tp->jump_lcb.l_paddr; @@ -6562,7 +6562,7 @@ ncr_alloc_nccb (ncb_p np, u_long target, u_long lun) /* ** Allocate a nccb */ - cp = (nccb_p) malloc (sizeof (struct nccb), M_DEVBUF, M_NOWAIT); + cp = (nccb_p) malloc (sizeof (struct nccb), M_DEVBUF, M_NOWAIT|M_ZERO); if (!cp) return (NULL); @@ -6572,11 +6572,6 @@ ncr_alloc_nccb (ncb_p np, u_long target, u_long lun) } /* - ** Initialize it - */ - bzero (cp, sizeof (*cp)); - - /* ** Fill in physical addresses */ diff --git a/sys/pci/pci.c b/sys/pci/pci.c index 2e5b9c5..c87e8e4 100644 --- a/sys/pci/pci.c +++ b/sys/pci/pci.c @@ -185,12 +185,10 @@ pci_readppb(device_t pcib, int b, int s, int f) { pcih1cfgregs *p; - p = malloc(sizeof (pcih1cfgregs), M_DEVBUF, M_WAITOK); + p = malloc(sizeof (pcih1cfgregs), M_DEVBUF, M_WAITOK | M_ZERO); if (p == NULL) return (NULL); - bzero(p, sizeof *p); - p->secstat = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_SECSTAT_1, 2); p->bridgectl = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_BRIDGECTL_1, 2); @@ -231,12 +229,10 @@ pci_readpcb(device_t pcib, int b, int s, int f) { pcih2cfgregs *p; - p = malloc(sizeof (pcih2cfgregs), M_DEVBUF, M_WAITOK); + p = malloc(sizeof (pcih2cfgregs), M_DEVBUF, M_WAITOK | M_ZERO); if (p == NULL) return (NULL); - bzero(p, sizeof *p); - p->secstat = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_SECSTAT_2, 2); p->bridgectl = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_BRIDGECTL_2, 2); @@ -304,10 +300,9 @@ pci_read_device(device_t pcib, int b, int s, int f) if (PCIB_READ_CONFIG(pcib, b, s, f, PCIR_DEVVENDOR, 4) != -1) { devlist_entry = malloc(sizeof(struct pci_devinfo), - M_DEVBUF, M_WAITOK); + M_DEVBUF, M_WAITOK | M_ZERO); if (devlist_entry == NULL) return (NULL); - bzero(devlist_entry, sizeof *devlist_entry); cfg = &devlist_entry->cfg; diff --git a/sys/pci/pci_compat.c b/sys/pci/pci_compat.c index 447fc58..401680d 100644 --- a/sys/pci/pci_compat.c +++ b/sys/pci/pci_compat.c @@ -317,10 +317,9 @@ compat_pci_handler(module_t mod, int type, void *data) switch (type) { case MOD_LOAD: - driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT); + driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT | M_ZERO); if (!driver) return ENOMEM; - bzero(driver, sizeof(driver_t)); driver->name = dvp->pd_name; driver->methods = pci_compat_methods; driver->size = sizeof(struct pci_devinfo *); diff --git a/sys/pci/simos.c b/sys/pci/simos.c index 413f7d7..bf12f5a 100644 --- a/sys/pci/simos.c +++ b/sys/pci/simos.c @@ -107,9 +107,8 @@ simos_attach(pcici_t config_id, int unit) struct simos_softc* sc; struct cam_devq *devq; - sc = malloc(sizeof(struct simos_softc), M_DEVBUF, M_WAITOK); + sc = malloc(sizeof(struct simos_softc), M_DEVBUF, M_WAITOK | M_ZERO); simosp[unit] = sc; - bzero(sc, sizeof *sc); sc->sc_unit = unit; sc->sc_regs = (SimOS_SCSI*) SIMOS_SCSI_ADDR; diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 1546227..aa93e0a 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -806,8 +806,7 @@ top: goto top; } MALLOC(pagedep, struct pagedep *, sizeof(struct pagedep), M_PAGEDEP, - M_SOFTDEP_FLAGS); - bzero(pagedep, sizeof(struct pagedep)); + M_SOFTDEP_FLAGS|M_ZERO); pagedep->pd_list.wk_type = D_PAGEDEP; pagedep->pd_mnt = mp; pagedep->pd_ino = ip->i_number; @@ -1191,8 +1190,7 @@ softdep_setup_allocdirect(ip, lbn, newblkno, oldblkno, newsize, oldsize, bp) struct newblk *newblk; MALLOC(adp, struct allocdirect *, sizeof(struct allocdirect), - M_ALLOCDIRECT, M_SOFTDEP_FLAGS); - bzero(adp, sizeof(struct allocdirect)); + M_ALLOCDIRECT, M_SOFTDEP_FLAGS|M_ZERO); adp->ad_list.wk_type = D_ALLOCDIRECT; adp->ad_lbn = lbn; adp->ad_newblkno = newblkno; @@ -1412,8 +1410,7 @@ newallocindir(ip, ptrno, newblkno, oldblkno) struct allocindir *aip; MALLOC(aip, struct allocindir *, sizeof(struct allocindir), - M_ALLOCINDIR, M_SOFTDEP_FLAGS); - bzero(aip, sizeof(struct allocindir)); + M_ALLOCINDIR, M_SOFTDEP_FLAGS|M_ZERO); aip->ai_list.wk_type = D_ALLOCINDIR; aip->ai_state = ATTACHED; aip->ai_offset = ptrno; @@ -1627,8 +1624,7 @@ softdep_setup_freeblocks(ip, length) if (length != 0) panic("softde_setup_freeblocks: non-zero length"); MALLOC(freeblks, struct freeblks *, sizeof(struct freeblks), - M_FREEBLKS, M_SOFTDEP_FLAGS); - bzero(freeblks, sizeof(struct freeblks)); + M_FREEBLKS, M_SOFTDEP_FLAGS|M_ZERO); freeblks->fb_list.wk_type = D_FREEBLKS; freeblks->fb_uid = ip->i_uid; freeblks->fb_previousinum = ip->i_number; @@ -2189,8 +2185,8 @@ softdep_setup_directory_add(bp, dp, diroffset, newinum, newdirbp) fs = dp->i_fs; lbn = lblkno(fs, diroffset); offset = blkoff(fs, diroffset); - MALLOC(dap, struct diradd *, sizeof(struct diradd), M_DIRADD, M_SOFTDEP_FLAGS); - bzero(dap, sizeof(struct diradd)); + MALLOC(dap, struct diradd *, sizeof(struct diradd), M_DIRADD, + M_SOFTDEP_FLAGS|M_ZERO); dap->da_list.wk_type = D_DIRADD; dap->da_offset = offset; dap->da_newinum = newinum; @@ -2441,8 +2437,7 @@ newdirrem(bp, dp, ip, isrmdir, prevdirremp) (void) request_cleanup(FLUSH_REMOVE, 0); num_dirrem += 1; MALLOC(dirrem, struct dirrem *, sizeof(struct dirrem), - M_DIRREM, M_SOFTDEP_FLAGS); - bzero(dirrem, sizeof(struct dirrem)); + M_DIRREM, M_SOFTDEP_FLAGS|M_ZERO); dirrem->dm_list.wk_type = D_DIRREM; dirrem->dm_state = isrmdir ? RMDIR : 0; dirrem->dm_mnt = ITOV(ip)->v_mount; @@ -2538,8 +2533,7 @@ softdep_setup_directory_change(bp, dp, ip, newinum, isrmdir) */ if (newinum != WINO) { MALLOC(dap, struct diradd *, sizeof(struct diradd), - M_DIRADD, M_SOFTDEP_FLAGS); - bzero(dap, sizeof(struct diradd)); + M_DIRADD, M_SOFTDEP_FLAGS|M_ZERO); dap->da_list.wk_type = D_DIRADD; dap->da_state = DIRCHG | ATTACHED | DEPCOMPLETE; dap->da_offset = offset; diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index fd3fd5d..a0d3142 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -602,8 +602,7 @@ ffs_mountfs(devvp, mp, p, malloctype) error = EROFS; /* needs translation */ goto out; } - ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK); - bzero((caddr_t)ump, sizeof *ump); + ump = malloc(sizeof *ump, M_UFSMNT, M_WAITOK | M_ZERO); ump->um_malloctype = malloctype; ump->um_i_effnlink_valid = 1; ump->um_fs = malloc((u_long)fs->fs_sbsize, M_UFSMNT, diff --git a/sys/ufs/ufs/ufs_quota.c b/sys/ufs/ufs/ufs_quota.c index 10f93af..c0b699f 100644 --- a/sys/ufs/ufs/ufs_quota.c +++ b/sys/ufs/ufs/ufs_quota.c @@ -773,8 +773,8 @@ dqget(vp, id, ump, type, dqp) numdquot < MAXQUOTAS * desiredvnodes) desireddquot += DQUOTINC; if (numdquot < desireddquot) { - dq = (struct dquot *)malloc(sizeof *dq, M_DQUOT, M_WAITOK); - bzero((char *)dq, sizeof *dq); + dq = (struct dquot *)malloc(sizeof *dq, M_DQUOT, + M_WAITOK | M_ZERO); numdquot++; } else { if ((dq = dqfreelist.tqh_first) == NULL) { diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index e215149..0b88efd 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -333,8 +333,7 @@ swap_pager_swap_init() for (n = 1; n < cnt.v_page_count / 4; n <<= 1) ; - swhash = malloc(sizeof(struct swblock *) * n, M_VMPGDATA, M_WAITOK); - bzero(swhash, sizeof(struct swblock *) * n); + swhash = malloc(sizeof(struct swblock *) * n, M_VMPGDATA, M_WAITOK | M_ZERO); swhash_mask = n - 1; } |