Call malloc(9) with M_ZERO flag instead of memset() after malloc().
This commit is contained in:
parent
c12b5c180d
commit
e6f8529d26
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fwnode.c,v 1.7 2001/11/15 09:48:08 lukem Exp $ */
|
||||
/* $NetBSD: fwnode.c,v 1.8 2002/01/12 16:58:16 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: fwnode.c,v 1.7 2001/11/15 09:48:08 lukem Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: fwnode.c,v 1.8 2002/01/12 16:58:16 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
@ -113,8 +113,7 @@ fwnode_attach(struct device *parent, struct device *self, void *aux)
|
||||
struct ieee1394_attach_args *fwa = aux;
|
||||
struct ieee1394_abuf *ab;
|
||||
|
||||
ab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK);
|
||||
memset(ab, 0, sizeof(struct ieee1394_abuf));
|
||||
ab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK|M_ZERO);
|
||||
ab->ab_data = malloc(4, M_1394DATA, M_WAITOK);
|
||||
ab->ab_data[0] = 0;
|
||||
|
||||
@ -450,10 +449,9 @@ fwnode_configrom_input(struct ieee1394_abuf *ab, int rcode)
|
||||
|
||||
if (!complete) {
|
||||
free(t, M_1394DATA);
|
||||
ab->ab_data = malloc(newlen, M_1394DATA, M_WAITOK);
|
||||
ab->ab_data = malloc(newlen, M_1394DATA, M_WAITOK|M_ZERO);
|
||||
sc->sc_sc1394.sc1394_configrom = ab->ab_data;
|
||||
sc->sc_sc1394.sc1394_configrom_len = 0;
|
||||
memset(ab->ab_data, 0, newlen);
|
||||
ab->ab_csr = CSR_BASE + CSR_CONFIG_ROM;
|
||||
ab->ab_length = newlen;
|
||||
ab->ab_retlen = 0;
|
||||
@ -712,8 +710,8 @@ int fwnode_parse_leaf(u_int32_t *addr, struct configrom_data *data)
|
||||
struct configrom_leafdata *l;
|
||||
int len, version;
|
||||
|
||||
l = malloc(sizeof(struct configrom_leafdata), M_1394DATA, M_WAITOK);
|
||||
memset(l, 0, sizeof(struct configrom_leafdata));
|
||||
l = malloc(sizeof(struct configrom_leafdata), M_1394DATA,
|
||||
M_WAITOK|M_ZERO);
|
||||
data->leafdata = l;
|
||||
l->desc_type = (ntohl(addr[1]) >> 24) & 0xff;
|
||||
l->spec_id = ntohl(addr[1]) & 0xffffff;
|
||||
@ -751,7 +749,7 @@ int fwnode_parse_leaf(u_int32_t *addr, struct configrom_data *data)
|
||||
|
||||
/* No guarentee this is zero terminated so account for that. */
|
||||
l->datalen = (len * 4) + 1;
|
||||
l->text = malloc (l->datalen, M_1394DATA, M_WAITOK);
|
||||
l->text = malloc(l->datalen, M_1394DATA, M_WAITOK);
|
||||
|
||||
/* Offset 3 of a text descriptor begins the text. */
|
||||
memcpy (l->text, &addr[3], l->datalen);
|
||||
@ -1014,12 +1012,9 @@ sbp2_init(struct fwnode_softc *sc, struct fwnode_device_cap *devcap)
|
||||
struct ieee1394_abuf *ab, *ab2;
|
||||
u_int32_t loc = ((int32_t *)devcap->dev_data)[0];
|
||||
|
||||
ab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK);
|
||||
memset(ab, 0, sizeof(struct ieee1394_abuf));
|
||||
ab->ab_data = malloc(8, M_1394DATA, M_WAITOK);
|
||||
memset(ab->ab_data, 0, 8);
|
||||
ab2 = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK);
|
||||
memset(ab2, 0, sizeof(struct ieee1394_abuf));
|
||||
ab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK|M_ZERO);
|
||||
ab->ab_data = malloc(8, M_1394DATA, M_WAITOK|M_ZERO);
|
||||
ab2 = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK|M_ZERO);
|
||||
|
||||
loc *= 4;
|
||||
ab->ab_length = 8;
|
||||
@ -1065,10 +1060,10 @@ sbp2_login(struct ieee1394_abuf *ab, int rcode)
|
||||
}
|
||||
|
||||
ab->ab_data = malloc(32, M_1394DATA, M_WAITOK);
|
||||
respab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK);
|
||||
statab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA, M_WAITOK);
|
||||
memset(respab, 0, sizeof(struct ieee1394_abuf));
|
||||
memset(statab, 0, sizeof(struct ieee1394_abuf));
|
||||
respab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA,
|
||||
M_WAITOK|M_ZERO);
|
||||
statab = malloc(sizeof(struct ieee1394_abuf), M_1394DATA,
|
||||
M_WAITOK|M_ZERO);
|
||||
|
||||
statab->ab_length = 32;
|
||||
statab->ab_tcode = IEEE1394_TCODE_WRITE_REQ_BLOCK;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: fwohci.c,v 1.48 2002/01/09 18:50:54 drochner Exp $ */
|
||||
/* $NetBSD: fwohci.c,v 1.49 2002/01/12 16:58:16 tsutsui Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
@ -49,7 +49,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.48 2002/01/09 18:50:54 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: fwohci.c,v 1.49 2002/01/12 16:58:16 tsutsui Exp $");
|
||||
|
||||
#define DOUBLEBUF 1
|
||||
#define NO_THREAD 1
|
||||
@ -852,8 +852,7 @@ fwohci_desc_alloc(struct fwohci_softc *sc)
|
||||
OHCI_BUF_IR_CNT * sc->sc_isoctx + 2;
|
||||
dsize = sizeof(struct fwohci_desc) * sc->sc_descsize;
|
||||
mapsize = howmany(sc->sc_descsize, NBBY);
|
||||
sc->sc_descmap = malloc(mapsize, M_DEVBUF, M_WAITOK);
|
||||
memset(sc->sc_descmap, 0, mapsize);
|
||||
sc->sc_descmap = malloc(mapsize, M_DEVBUF, M_WAITOK|M_ZERO);
|
||||
|
||||
if ((error = bus_dmamem_alloc(sc->sc_dmat, dsize, PAGE_SIZE, 0,
|
||||
&sc->sc_dseg, 1, &sc->sc_dnseg, 0)) != 0) {
|
||||
@ -945,8 +944,8 @@ fwohci_ctx_alloc(struct fwohci_softc *sc, struct fwohci_ctx **fcp,
|
||||
int buf2cnt;
|
||||
#endif
|
||||
|
||||
fc = malloc(sizeof(*fc) + sizeof(*fb) * bufcnt, M_DEVBUF, M_WAITOK);
|
||||
memset(fc, 0, sizeof(*fc) + sizeof(*fb) * bufcnt);
|
||||
fc = malloc(sizeof(*fc) + sizeof(*fb) * bufcnt, M_DEVBUF,
|
||||
M_WAITOK|M_ZERO);
|
||||
LIST_INIT(&fc->fc_handler);
|
||||
TAILQ_INIT(&fc->fc_buf);
|
||||
fc->fc_ctx = ctx;
|
||||
@ -2560,10 +2559,9 @@ fwohci_uid_collect(struct fwohci_softc *sc)
|
||||
if (sc->sc_uidtbl != NULL)
|
||||
free(sc->sc_uidtbl, M_DEVBUF);
|
||||
sc->sc_uidtbl = malloc(sizeof(*fu) * (sc->sc_rootid + 1), M_DEVBUF,
|
||||
M_NOWAIT); /* XXX M_WAITOK requires locks */
|
||||
M_NOWAIT|M_ZERO); /* XXX M_WAITOK requires locks */
|
||||
if (sc->sc_uidtbl == NULL)
|
||||
return;
|
||||
memset(sc->sc_uidtbl, 0, sizeof(*fu) * (sc->sc_rootid + 1));
|
||||
|
||||
for (i = 0, fu = sc->sc_uidtbl; i <= sc->sc_rootid; i++, fu++) {
|
||||
if (i == (sc->sc_nodeid & OHCI_NodeId_NodeNumber)) {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: irframe.c,v 1.15 2001/12/29 14:25:47 augustss Exp $ */
|
||||
/* $NetBSD: irframe.c,v 1.16 2002/01/12 16:59:17 tsutsui Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
@ -400,8 +400,7 @@ irframe_alloc(size_t size, const struct irframe_methods *m, void *h)
|
||||
for (unit = 0; unit < cd->cd_ndevs; unit++)
|
||||
if (cd->cd_devs[unit] == NULL)
|
||||
break;
|
||||
dev = malloc(size, M_DEVBUF, M_WAITOK);
|
||||
memset(dev, 0, size);
|
||||
dev = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO);
|
||||
snprintf(dev->dv_xname, sizeof dev->dv_xname, "irframe%d", unit);
|
||||
dev->dv_unit = unit;
|
||||
dev->dv_flags = DVF_ACTIVE; /* always initially active */
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: hid.c,v 1.21 2002/01/02 11:10:50 augustss Exp $ */
|
||||
/* $NetBSD: hid.c,v 1.22 2002/01/12 17:11:03 tsutsui Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -39,7 +39,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.21 2002/01/02 11:10:50 augustss Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.22 2002/01/12 17:11:03 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -100,8 +100,7 @@ hid_start_parse(void *d, int len, enum hid_kind kind)
|
||||
{
|
||||
struct hid_data *s;
|
||||
|
||||
s = malloc(sizeof *s, M_TEMP, M_WAITOK);
|
||||
memset(s, 0, sizeof *s);
|
||||
s = malloc(sizeof *s, M_TEMP, M_WAITOK|M_ZERO);
|
||||
s->start = s->p = d;
|
||||
s->end = (char *)d + len;
|
||||
s->kind = kind;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: umidi.c,v 1.12 2002/01/02 17:20:09 augustss Exp $ */
|
||||
/* $NetBSD: umidi.c,v 1.13 2002/01/12 17:11:03 tsutsui Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
@ -36,7 +36,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.12 2002/01/02 17:20:09 augustss Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: umidi.c,v 1.13 2002/01/12 17:11:03 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -980,8 +980,7 @@ alloc_all_mididevs(struct umidi_softc *sc, int nmidi)
|
||||
{
|
||||
sc->sc_num_mididevs = nmidi;
|
||||
sc->sc_mididevs = malloc(sizeof(*sc->sc_mididevs)*nmidi,
|
||||
M_USBDEV, M_WAITOK);
|
||||
memset(sc->sc_mididevs, 0, sizeof(*sc->sc_mididevs)*nmidi);
|
||||
M_USBDEV, M_WAITOK|M_ZERO);
|
||||
if (!sc->sc_mididevs)
|
||||
return USBD_NOMEM;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb_subr.c,v 1.96 2001/11/22 21:59:33 augustss Exp $ */
|
||||
/* $NetBSD: usb_subr.c,v 1.97 2002/01/12 17:11:03 tsutsui Exp $ */
|
||||
/* $FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $ */
|
||||
|
||||
/*
|
||||
@ -39,7 +39,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.96 2001/11/22 21:59:33 augustss Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.97 2002/01/12 17:11:03 tsutsui Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -972,10 +972,9 @@ usbd_new_device(device_ptr_t parent, usbd_bus_handle bus, int depth,
|
||||
return (USBD_NO_ADDR);
|
||||
}
|
||||
|
||||
dev = malloc(sizeof *dev, M_USB, M_NOWAIT);
|
||||
dev = malloc(sizeof *dev, M_USB, M_NOWAIT|M_ZERO);
|
||||
if (dev == NULL)
|
||||
return (USBD_NOMEM);
|
||||
memset(dev, 0, sizeof(*dev));
|
||||
|
||||
dev->bus = bus;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user