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

This commit is contained in:
tsutsui 2002-01-12 16:03:11 +00:00
parent 5f90ae55b5
commit 84926576f1
7 changed files with 36 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ac97.c,v 1.22 2002/01/06 17:03:17 jmcneill Exp $ */
/* $NetBSD: ac97.c,v 1.23 2002/01/12 16:03:11 tsutsui Exp $ */
/* $OpenBSD: ac97.c,v 1.8 2000/07/19 09:01:35 csapuntz Exp $ */
/*
@ -63,7 +63,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.22 2002/01/06 17:03:17 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: ac97.c,v 1.23 2002/01/12 16:03:11 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -566,13 +566,11 @@ ac97_attach(host_if)
u_int32_t id;
mixer_ctrl_t ctl;
as = malloc(sizeof(struct ac97_softc), M_DEVBUF, M_WAITOK);
as = malloc(sizeof(struct ac97_softc), M_DEVBUF, M_WAITOK|M_ZERO);
if (as == NULL)
return (ENOMEM);
memset(as, 0, sizeof(*as));
as->codec_if.vtbl = &ac97civ;
as->host_if = host_if;

View File

@ -1,4 +1,4 @@
/* $NetBSD: aic7xxx.c,v 1.84 2001/11/28 05:45:27 lukem Exp $ */
/* $NetBSD: aic7xxx.c,v 1.85 2002/01/12 16:03:11 tsutsui Exp $ */
/*
* Generic driver for the aic7xxx based adaptec SCSI controllers
@ -87,7 +87,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: aic7xxx.c,v 1.84 2001/11/28 05:45:27 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: aic7xxx.c,v 1.85 2002/01/12 16:03:11 tsutsui Exp $");
#include "opt_ddb.h"
#include "opt_ahc.h"
@ -810,12 +810,11 @@ ahc_alloc(struct ahc_softc *ahc, bus_space_handle_t sh, bus_space_tag_t st,
{
struct scb_data *scb_data;
scb_data = malloc(sizeof (struct scb_data), M_DEVBUF, M_NOWAIT);
scb_data = malloc(sizeof (struct scb_data), M_DEVBUF, M_NOWAIT|M_ZERO);
if (scb_data == NULL) {
printf("%s: cannot malloc softc!\n", ahc_name(ahc));
return -1;
}
memset(scb_data, 0, sizeof (struct scb_data));
LIST_INIT(&ahc->pending_ccbs);
ahc->tag = st;
ahc->bsh = sh;
@ -863,10 +862,9 @@ ahcinitscbdata(struct ahc_softc *ahc)
/* Allocate SCB resources */
scb_data->scbarray =
(struct scb *)malloc(sizeof(struct scb) * AHC_SCB_MAX,
M_DEVBUF, M_NOWAIT);
M_DEVBUF, M_NOWAIT|M_ZERO);
if (scb_data->scbarray == NULL)
return (ENOMEM);
memset(scb_data->scbarray, 0, sizeof(struct scb) * AHC_SCB_MAX);
/* Determine the number of hardware SCBs and initialize them */

View File

@ -1,4 +1,4 @@
/* $NetBSD: ibm561.c,v 1.1 2001/12/12 07:46:48 elric Exp $ */
/* $NetBSD: ibm561.c,v 1.2 2002/01/12 16:03:12 tsutsui Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -155,8 +155,7 @@ ibm561_register(v, sched_update, wr, rd)
{
struct ibm561data *data;
data = malloc(sizeof *data, M_DEVBUF, M_WAITOK);
memset(data, 0x0, sizeof *data);
data = malloc(sizeof *data, M_DEVBUF, M_WAITOK|M_ZERO);
data->cookie = v;
data->ramdac_sched_update = sched_update;
data->ramdac_wr = wr;

View File

@ -1,4 +1,4 @@
/* $NetBSD: ncr53c9x.c,v 1.88 2001/12/03 23:27:31 jdolecek Exp $ */
/* $NetBSD: ncr53c9x.c,v 1.89 2002/01/12 16:03:12 tsutsui Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.88 2001/12/03 23:27:31 jdolecek Exp $");
__KERNEL_RCSID(0, "$NetBSD: ncr53c9x.c,v 1.89 2002/01/12 16:03:12 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1069,12 +1069,11 @@ ncr53c9x_sched(sc)
li = TINFO_LUN(ti, lun);
if (li == NULL) {
/* Initialize LUN info and add to list. */
if ((li = malloc(sizeof(*li), M_DEVBUF, M_NOWAIT))
== NULL) {
if ((li = malloc(sizeof(*li),
M_DEVBUF, M_NOWAIT|M_ZERO)) == NULL) {
splx(s);
continue;
}
memset(li, 0, sizeof(*li));
li->lun = lun;
LIST_INSERT_HEAD(&ti->luns, li, link);

View File

@ -1,4 +1,4 @@
/* $NetBSD: rrunner.c,v 1.28 2001/11/13 13:14:43 lukem Exp $ */
/* $NetBSD: rrunner.c,v 1.29 2002/01/12 16:03:12 tsutsui Exp $ */
/*
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -42,7 +42,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rrunner.c,v 1.28 2001/11/13 13:14:43 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: rrunner.c,v 1.29 2002/01/12 16:03:12 tsutsui Exp $");
#include "opt_inet.h"
#include "opt_ns.h"
@ -794,10 +794,9 @@ esh_fpopen(dev, oflags, devtype, p)
*/
recv = (struct esh_fp_ring_ctl *)
malloc(sizeof(*recv), M_DEVBUF, M_WAITOK);
malloc(sizeof(*recv), M_DEVBUF, M_WAITOK|M_ZERO);
if (recv == NULL)
return(ENOMEM);
memset(recv, 0, sizeof(*recv));
TAILQ_INIT(&recv->ec_queue);
size = RR_FP_RECV_RING_SIZE * sizeof(struct rr_descr);
@ -3712,9 +3711,9 @@ esh_new_dmainfo(sc)
/* None sitting around, so build one now... */
di = (struct esh_dmainfo *) malloc(sizeof(*di), M_DEVBUF, M_WAITOK);
di = (struct esh_dmainfo *) malloc(sizeof(*di), M_DEVBUF,
M_WAITOK|M_ZERO);
assert(di != NULL);
memset(di, 0, sizeof(*di));
if (bus_dmamap_create(sc->sc_dmat, ESH_MAX_NSEGS * RR_DMA_MAX,
ESH_MAX_NSEGS, RR_DMA_MAX, RR_DMA_BOUNDRY,

View File

@ -1,4 +1,4 @@
/* $NetBSD: siop.c,v 1.48 2001/11/13 13:14:44 lukem Exp $ */
/* $NetBSD: siop.c,v 1.49 2002/01/12 16:03:12 tsutsui Exp $ */
/*
* Copyright (c) 2000 Manuel Bouyer.
@ -33,7 +33,7 @@
/* SYM53c7/8xx PCI-SCSI I/O Processors driver */
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: siop.c,v 1.48 2001/11/13 13:14:44 lukem Exp $");
__KERNEL_RCSID(0, "$NetBSD: siop.c,v 1.49 2002/01/12 16:03:12 tsutsui Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1244,7 +1244,8 @@ siop_scsipi_request(chan, req, arg)
}
if (sc->targets[target]->siop_lun[lun] == NULL) {
sc->targets[target]->siop_lun[lun] =
malloc(sizeof(struct siop_lun), M_DEVBUF, M_NOWAIT);
malloc(sizeof(struct siop_lun), M_DEVBUF,
M_NOWAIT|M_ZERO);
if (sc->targets[target]->siop_lun[lun] == NULL) {
printf("%s: can't alloc siop_lun for "
"target %d lun %d\n",
@ -1254,8 +1255,6 @@ siop_scsipi_request(chan, req, arg)
splx(s);
return;
}
memset(sc->targets[target]->siop_lun[lun], 0,
sizeof(struct siop_lun));
}
siop_cmd->siop_target = sc->targets[target];
siop_cmd->xs = xs;
@ -1534,23 +1533,21 @@ siop_morecbd(sc)
u_int32_t *scr;
/* allocate a new list head */
newcbd = malloc(sizeof(struct siop_cbd), M_DEVBUF, M_NOWAIT);
newcbd = malloc(sizeof(struct siop_cbd), M_DEVBUF, M_NOWAIT|M_ZERO);
if (newcbd == NULL) {
printf("%s: can't allocate memory for command descriptors "
"head\n", sc->sc_dev.dv_xname);
return;
}
memset(newcbd, 0, sizeof(struct siop_cbd));
/* allocate cmd list */
newcbd->cmds =
malloc(sizeof(struct siop_cmd) * SIOP_NCMDPB, M_DEVBUF, M_NOWAIT);
newcbd->cmds = malloc(sizeof(struct siop_cmd) * SIOP_NCMDPB,
M_DEVBUF, M_NOWAIT|M_ZERO);
if (newcbd->cmds == NULL) {
printf("%s: can't allocate memory for command descriptors\n",
sc->sc_dev.dv_xname);
goto bad3;
}
memset(newcbd->cmds, 0, sizeof(struct siop_cmd) * SIOP_NCMDPB);
error = bus_dmamem_alloc(sc->sc_dmat, PAGE_SIZE, PAGE_SIZE, 0, &seg,
1, &rseg, BUS_DMA_NOWAIT);
if (error) {
@ -1692,10 +1689,9 @@ siop_get_lunsw(sc)
TAILQ_REMOVE(&sc->lunsw_list, lunsw, next);
return lunsw;
}
lunsw = malloc(sizeof(struct siop_lunsw), M_DEVBUF, M_NOWAIT);
lunsw = malloc(sizeof(struct siop_lunsw), M_DEVBUF, M_NOWAIT|M_ZERO);
if (lunsw == NULL)
return NULL;
memset(lunsw, 0, sizeof(struct siop_lunsw));
#ifdef SIOP_DEBUG
printf("allocating lunsw at offset %d\n", sc->script_free_lo);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: tulip.c,v 1.102 2001/11/22 05:03:04 yamt Exp $ */
/* $NetBSD: tulip.c,v 1.103 2002/01/12 16:03:12 tsutsui Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.102 2001/11/22 05:03:04 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: tulip.c,v 1.103 2002/01/12 16:03:12 tsutsui Exp $");
#include "bpfilter.h"
@ -3856,8 +3856,7 @@ tlp_add_srom_media(sc, type, get, set, list, cnt)
for (i = 0; i < cnt; i++) {
tsti = tlp_srom_to_ifmedia(list[i]);
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
memset(tm, 0, sizeof(*tm));
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
tlp_srom_media_info(sc, tsti, tm);
tm->tm_type = type;
tm->tm_get = get;
@ -4252,8 +4251,7 @@ tlp_21040_tmsw_init(sc)
/*
* No SROM type for External SIA.
*/
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
memset(tm, 0, sizeof(*tm));
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
tm->tm_name = "manual";
tm->tm_opmode = 0;
tm->tm_siaconn = SIACONN_21040_EXTSIA;
@ -4368,8 +4366,7 @@ tlp_21041_tmsw_init(sc)
for (; m_cnt != 0;
m_cnt--, mb_offset += TULIP_ROM_MB_SIZE(mb)) {
mb = sc->sc_srom[mb_offset];
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
memset(tm, 0, sizeof(*tm));
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
switch (mb & TULIP_ROM_MB_MEDIA_CODE) {
case TULIP_ROM_MB_MEDIA_TP_FDX:
case TULIP_ROM_MB_MEDIA_TP:
@ -4557,8 +4554,7 @@ tlp_2114x_isv_tmsw_init(sc)
tlp_get_minst(sc);
sc->sc_media_seen |= 1 << TULIP_ROM_MB_21140_GPR;
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
memset(tm, 0, sizeof(*tm));
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
tm->tm_type = TULIP_ROM_MB_21140_GPR;
tm->tm_get = tlp_21140_gpio_get;
@ -4602,8 +4598,7 @@ tlp_2114x_isv_tmsw_init(sc)
case TULIP_ROM_MB_21140_MII:
sc->sc_media_seen |= 1 << TULIP_ROM_MB_21140_MII;
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
memset(tm, 0, sizeof(*tm));
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
tm->tm_type = TULIP_ROM_MB_21140_MII;
tm->tm_get = tlp_mii_getmedia;
@ -4719,8 +4714,7 @@ tlp_2114x_isv_tmsw_init(sc)
tlp_get_minst(sc);
sc->sc_media_seen |= 1 << TULIP_ROM_MB_21142_SIA;
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
memset(tm, 0, sizeof(*tm));
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
tm->tm_type = TULIP_ROM_MB_21142_SIA;
tm->tm_get = tlp_sia_get;
@ -4762,8 +4756,7 @@ tlp_2114x_isv_tmsw_init(sc)
case TULIP_ROM_MB_21142_MII:
sc->sc_media_seen |= 1 << TULIP_ROM_MB_21142_MII;
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
memset(tm, 0, sizeof(*tm));
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
tm->tm_type = TULIP_ROM_MB_21142_MII;
tm->tm_get = tlp_mii_getmedia;
@ -4879,8 +4872,7 @@ tlp_2114x_isv_tmsw_init(sc)
tlp_get_minst(sc);
sc->sc_media_seen |= 1 << TULIP_ROM_MB_21143_SYM;
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK);
memset(tm, 0, sizeof(*tm));
tm = malloc(sizeof(*tm), M_DEVBUF, M_WAITOK|M_ZERO);
tm->tm_type = TULIP_ROM_MB_21143_SYM;
tm->tm_get = tlp_sia_get;