Call malloc(9) with M_ZERO flag instead of memset() after malloc().

This commit is contained in:
tsutsui 2002-01-12 16:41:02 +00:00
parent 1267bddc09
commit c12b5c180d
9 changed files with 34 additions and 49 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: acpi.c,v 1.5 2001/11/13 13:01:57 lukem Exp $ */
/* $NetBSD: acpi.c,v 1.6 2002/01/12 16:43:53 tsutsui Exp $ */
/*
* Copyright 2001 Wasabi Systems, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.5 2001/11/13 13:01:57 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: acpi.c,v 1.6 2002/01/12 16:43:53 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -431,10 +431,9 @@ acpi_make_devnode(ACPI_HANDLE handle, UINT32 level, void *context,
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_THERMAL:
case ACPI_TYPE_POWER:
ad = malloc(sizeof(*ad), M_DEVBUF, M_NOWAIT);
ad = malloc(sizeof(*ad), M_DEVBUF, M_NOWAIT|M_ZERO);
if (ad == NULL)
return (AE_NO_MEMORY);
memset(ad, 0, sizeof(*ad));
ad->ad_handle = handle;
ad->ad_level = level;

View File

@ -1,4 +1,4 @@
/* $NetBSD: hpcfb.c,v 1.15 2001/11/13 12:47:56 lukem Exp $ */
/* $NetBSD: hpcfb.c,v 1.16 2002/01/12 16:45:14 tsutsui Exp $ */
/*-
* Copyright (c) 1999
@ -43,13 +43,13 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: hpcfb.c,v 1.15 2001/11/13 12:47:56 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: hpcfb.c,v 1.16 2002/01/12 16:45:14 tsutsui Exp $");
#define FBDEBUG
static const char _copyright[] __attribute__ ((unused)) =
"Copyright (c) 1999 Shin Takemura. All rights reserved.";
static const char _rcsid[] __attribute__ ((unused)) =
"$NetBSD: hpcfb.c,v 1.15 2001/11/13 12:47:56 lukem Exp $";
"$NetBSD: hpcfb.c,v 1.16 2002/01/12 16:45:14 tsutsui Exp $";
#include <sys/param.h>
#include <sys/systm.h>
@ -696,11 +696,10 @@ hpcfb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
DPRINTF(("%s(%d): hpcfb_alloc_screen()\n", __FILE__, __LINE__));
dc = malloc(sizeof(struct hpcfb_devconfig), M_DEVBUF, M_WAITOK);
dc = malloc(sizeof(struct hpcfb_devconfig), M_DEVBUF, M_WAITOK|M_ZERO);
if (dc == NULL)
return (ENOMEM);
memset(dc, 0, sizeof(struct hpcfb_devconfig));
dc->dc_sc = sc;
if (hpcfb_init(&sc->sc_fbconflist[0], dc) != 0)
return (EINVAL);
@ -733,12 +732,11 @@ hpcfb_alloc_screen(void *v, const struct wsscreen_descr *type, void **cookiep,
dc->dc_curx = -1;
dc->dc_cury = -1;
dc->dc_tvram = malloc(sizeof(struct hpcfb_tvrow)*dc->dc_rows,
M_DEVBUF, M_WAITOK);
M_DEVBUF, M_WAITOK|M_ZERO);
if (dc->dc_tvram == NULL){
free(dc, M_DEVBUF);
return (ENOMEM);
}
memset(dc->dc_tvram, 0, sizeof(struct hpcfb_tvrow)*dc->dc_rows);
*curxp = 0;
*curyp = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: iop.c,v 1.21 2002/01/02 19:04:17 ad Exp $ */
/* $NetBSD: iop.c,v 1.22 2002/01/12 16:49:44 tsutsui Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: iop.c,v 1.21 2002/01/02 19:04:17 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: iop.c,v 1.22 2002/01/12 16:49:44 tsutsui Exp $");
#include "opt_i2o.h"
#include "iop.h"
@ -370,8 +370,7 @@ iop_init(struct iop_softc *sc, const char *intrstr)
#endif
/* Allocate message wrappers. */
im = malloc(sizeof(*im) * sc->sc_maxib, M_DEVBUF, M_NOWAIT);
memset(im, 0, sizeof(*im) * sc->sc_maxib);
im = malloc(sizeof(*im) * sc->sc_maxib, M_DEVBUF, M_NOWAIT|M_ZERO);
sc->sc_ims = im;
SLIST_INIT(&sc->sc_im_freelist);
@ -486,9 +485,8 @@ iop_config_interrupts(struct device *self)
i = sizeof(struct i2o_systab_entry) * (niop - 1) +
sizeof(struct i2o_systab);
iop_systab_size = i;
iop_systab = malloc(i, M_DEVBUF, M_NOWAIT);
iop_systab = malloc(i, M_DEVBUF, M_NOWAIT|M_ZERO);
memset(iop_systab, 0, i);
iop_systab->numentries = niop;
iop_systab->version = I2O_VERSION_11;
@ -703,8 +701,7 @@ iop_reconfigure(struct iop_softc *sc, u_int chgind)
if (sc->sc_tidmap != NULL)
free(sc->sc_tidmap, M_DEVBUF);
sc->sc_tidmap = malloc(sc->sc_nlctent * sizeof(struct iop_tidmap),
M_DEVBUF, M_NOWAIT);
memset(sc->sc_tidmap, 0, sizeof(sc->sc_tidmap));
M_DEVBUF, M_NOWAIT|M_ZERO);
/* Allow 1 queued command per device while we're configuring. */
iop_adjqparam(sc, 1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: iopl.c,v 1.5 2001/11/13 12:24:58 lukem Exp $ */
/* $NetBSD: iopl.c,v 1.6 2002/01/12 16:49:45 tsutsui Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -46,7 +46,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: iopl.c,v 1.5 2001/11/13 12:24:58 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: iopl.c,v 1.6 2002/01/12 16:49:45 tsutsui Exp $");
#include "opt_i2o.h"
#include "opt_inet.h"
@ -523,8 +523,7 @@ iopl_tx_alloc(struct iopl_softc *sc, int count)
#endif
size = count * sizeof(*tx);
sc->sc_tx = malloc(size, M_DEVBUF, M_NOWAIT);
memset(sc->sc_tx, 0, size);
sc->sc_tx = malloc(size, M_DEVBUF, M_NOWAIT|M_ZERO);
for (i = 0, tx = sc->sc_tx; i < count; i++, tx++) {
rv = bus_dmamap_create(sc->sc_dmat, MCLBYTES,
@ -580,8 +579,7 @@ iopl_rx_alloc(struct iopl_softc *sc, int count)
#endif
size = count * sizeof(*rx);
sc->sc_rx = malloc(size, M_DEVBUF, M_NOWAIT);
memset(sc->sc_rx, 0, size);
sc->sc_rx = malloc(size, M_DEVBUF, M_NOWAIT|M_ZERO);
for (i = 0, rx = sc->sc_rx; i < count; i++, rx++) {
state = 0;
@ -1776,9 +1774,8 @@ iopl_filter_ether(struct iopl_softc *sc)
goto allmulti;
size = sizeof(*tbl) * sc->sc_mcast_max;
if ((tbl = malloc(size, M_DEVBUF, M_WAITOK)) == NULL)
if ((tbl = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO)) == NULL)
goto allmulti;
memset(tbl, 0, size);
ETHER_FIRST_MULTI(step, ec, enm)
for (i = 0; enm != NULL; i++) {

View File

@ -1,4 +1,4 @@
/* $NetBSD: iopsp.c,v 1.11 2001/11/13 12:24:59 lukem Exp $ */
/* $NetBSD: iopsp.c,v 1.12 2002/01/12 16:49:45 tsutsui Exp $ */
/*-
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: iopsp.c,v 1.11 2001/11/13 12:24:59 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: iopsp.c,v 1.12 2002/01/12 16:49:45 tsutsui Exp $");
#include "opt_i2o.h"
@ -204,8 +204,7 @@ iopsp_attach(struct device *parent, struct device *self, void *aux)
* purposes only.
*/
size = sc->sc_channel.chan_ntargets * sizeof(struct iopsp_target);
sc->sc_targetmap = malloc(size, M_DEVBUF, M_NOWAIT);
memset(sc->sc_targetmap, 0, size);
sc->sc_targetmap = malloc(size, M_DEVBUF, M_NOWAIT|M_ZERO);
#endif
/* Build the two maps, and attach to scsipi. */
@ -257,9 +256,8 @@ iopsp_reconfig(struct device *dv)
* and we never address that here).
*/
size = sc_chan->chan_ntargets * (IOPSP_MAX_LUN) * sizeof(u_short);
if ((tidmap = malloc(size, M_DEVBUF, M_WAITOK)) == NULL)
if ((tidmap = malloc(size, M_DEVBUF, M_WAITOK|M_ZERO)) == NULL)
return (ENOMEM);
memset(tidmap, 0, size);
#ifdef I2OVERBOSE
for (i = 0; i < sc_chan->chan_ntargets; i++)

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsemul_vt100.c,v 1.16 2001/11/13 06:17:46 lukem Exp $ */
/* $NetBSD: wsemul_vt100.c,v 1.17 2002/01/12 16:41:02 tsutsui Exp $ */
/*
* Copyright (c) 1998
@ -33,7 +33,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.16 2001/11/13 06:17:46 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100.c,v 1.17 2002/01/12 16:41:02 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -211,8 +211,7 @@ wsemul_vt100_attach(int console, const struct wsscreen_descr *type,
edp->cbcookie = cbcookie;
edp->tabs = malloc(edp->ncols, M_DEVBUF, M_NOWAIT);
edp->dblwid = malloc(edp->nrows, M_DEVBUF, M_NOWAIT);
memset(edp->dblwid, 0, edp->nrows);
edp->dblwid = malloc(edp->nrows, M_DEVBUF, M_NOWAIT|M_ZERO);
edp->dw = 0;
edp->dcsarg = malloc(DCS_MAXLEN, M_DEVBUF, M_NOWAIT);
edp->isolatin1tab = malloc(128 * sizeof(int), M_DEVBUF, M_NOWAIT);

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsevent.c,v 1.9 2001/11/13 06:17:47 lukem Exp $ */
/* $NetBSD: wsevent.c,v 1.10 2002/01/12 16:41:02 tsutsui Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.9 2001/11/13 06:17:47 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsevent.c,v 1.10 2002/01/12 16:41:02 tsutsui Exp $");
#include <sys/param.h>
#include <sys/fcntl.h>
@ -108,8 +108,7 @@ wsevent_init(struct wseventvar *ev)
#endif
ev->get = ev->put = 0;
ev->q = malloc((u_long)WSEVENT_QSIZE * sizeof(struct wscons_event),
M_DEVBUF, M_WAITOK);
memset(ev->q, 0, WSEVENT_QSIZE * sizeof(struct wscons_event));
M_DEVBUF, M_WAITOK|M_ZERO);
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: wskbd.c,v 1.59 2001/11/22 00:57:15 augustss Exp $ */
/* $NetBSD: wskbd.c,v 1.60 2002/01/12 16:41:02 tsutsui Exp $ */
/*
* Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
@ -83,7 +83,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.59 2001/11/22 00:57:15 augustss Exp $");
__KERNEL_RCSID(0, "$NetBSD: wskbd.c,v 1.60 2002/01/12 16:41:02 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@ -374,8 +374,7 @@ wskbd_attach(struct device *parent, struct device *self, void *aux)
sc->id = &wskbd_console_data;
} else {
sc->id = malloc(sizeof(struct wskbd_internal),
M_DEVBUF, M_WAITOK);
memset(sc->id, 0, sizeof(struct wskbd_internal));
M_DEVBUF, M_WAITOK|M_ZERO);
sc->id->t_keymap = ap->keymap;
wskbd_update_layout(sc->id, ap->keymap->layout);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: wsmux.c,v 1.26 2001/11/22 00:54:23 augustss Exp $ */
/* $NetBSD: wsmux.c,v 1.27 2002/01/12 16:41:03 tsutsui Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -44,7 +44,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: wsmux.c,v 1.26 2001/11/22 00:54:23 augustss Exp $");
__KERNEL_RCSID(0, "$NetBSD: wsmux.c,v 1.27 2002/01/12 16:41:03 tsutsui Exp $");
#include "wsdisplay.h"
#include "wsmux.h"
@ -599,10 +599,9 @@ wsmux_create(const char *name, int unit)
struct wsmux_softc *sc;
DPRINTF(("wsmux_create: allocating\n"));
sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT|M_ZERO);
if (sc == NULL)
return (NULL);
memset(sc, 0, sizeof *sc);
CIRCLEQ_INIT(&sc->sc_cld);
snprintf(sc->sc_base.me_dv.dv_xname, sizeof sc->sc_base.me_dv.dv_xname,
"%s%d", name, unit);