From 7d9d396fd545532b28c0dea8ef9f385b4fff4578 Mon Sep 17 00:00:00 2001 From: dwmalone Date: Sun, 29 Oct 2000 15:47:16 +0000 Subject: Add the use of M_ZERO to some malloc calls. Submitted by: josh@zipperup.org Submitted by: Robert Drehmel Approved by: gibbs --- sys/cam/cam_xpt.c | 7 +++---- sys/cam/scsi/scsi_cd.c | 18 +++++------------- sys/cam/scsi/scsi_ch.c | 3 +-- sys/dev/advansys/adwcam.c | 3 +-- sys/dev/ahb/ahb.c | 3 +-- sys/dev/aic7xxx/aic7xxx_freebsd.c | 5 ++--- sys/dev/aic7xxx/aic7xxx_osm.c | 5 ++--- 7 files changed, 15 insertions(+), 29 deletions(-) (limited to 'sys') diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c index 4dd19c4..018ee5a 100644 --- a/sys/cam/cam_xpt.c +++ b/sys/cam/cam_xpt.c @@ -1349,13 +1349,12 @@ xpt_init(dummy) */ xpt_config_hook = (struct intr_config_hook *)malloc(sizeof(struct intr_config_hook), - M_TEMP, M_NOWAIT); + M_TEMP, M_NOWAIT | M_ZERO); if (xpt_config_hook == NULL) { printf("xpt_init: Cannot malloc config hook " "- failing attach\n"); return; } - bzero(xpt_config_hook, sizeof(*xpt_config_hook)); xpt_config_hook->ich_func = xpt_config; if (config_intrhook_establish(xpt_config_hook) != 0) { @@ -5406,10 +5405,10 @@ probestart(struct cam_periph *periph, union ccb *start_ccb) if ((device->quirk->quirks & CAM_QUIRK_NOSERIAL) == 0) serial_buf = (struct scsi_vpd_unit_serial_number *) - malloc(sizeof(*serial_buf), M_TEMP, M_NOWAIT); + malloc(sizeof(*serial_buf), M_TEMP, + M_NOWAIT | M_ZERO); if (serial_buf != NULL) { - bzero(serial_buf, sizeof(*serial_buf)); scsi_inquiry(csio, /*retries*/4, probedone, diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index 7e72f38..a972e84 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -3030,8 +3030,7 @@ cdreportkey(struct cam_periph *periph, struct dvd_authinfo *authinfo) } if (length != 0) { - databuf = malloc(length, M_DEVBUF, M_WAITOK); - bzero(databuf, length); + databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO); } else databuf = NULL; @@ -3162,12 +3161,10 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo) length = sizeof(*challenge_data); - challenge_data = malloc(length, M_DEVBUF, M_WAITOK); + challenge_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO); databuf = (u_int8_t *)challenge_data; - bzero(databuf, length); - scsi_ulto2b(length - sizeof(challenge_data->data_len), challenge_data->data_len); @@ -3181,12 +3178,10 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo) length = sizeof(*key2_data); - key2_data = malloc(length, M_DEVBUF, M_WAITOK); + key2_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO); databuf = (u_int8_t *)key2_data; - bzero(databuf, length); - scsi_ulto2b(length - sizeof(key2_data->data_len), key2_data->data_len); @@ -3200,12 +3195,10 @@ cdsendkey(struct cam_periph *periph, struct dvd_authinfo *authinfo) length = sizeof(*rpc_data); - rpc_data = malloc(length, M_DEVBUF, M_WAITOK); + rpc_data = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO); databuf = (u_int8_t *)rpc_data; - bzero(databuf, length); - scsi_ulto2b(length - sizeof(rpc_data->data_len), rpc_data->data_len); @@ -3347,8 +3340,7 @@ cdreaddvdstructure(struct cam_periph *periph, struct dvd_struct *dvdstruct) } if (length != 0) { - databuf = malloc(length, M_DEVBUF, M_WAITOK); - bzero(databuf, length); + databuf = malloc(length, M_DEVBUF, M_WAITOK | M_ZERO); } else databuf = NULL; diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c index b51163b..b7239cb 100644 --- a/sys/cam/scsi/scsi_ch.c +++ b/sys/cam/scsi/scsi_ch.c @@ -1192,8 +1192,7 @@ chgetelemstatus(struct cam_periph *periph, user_data = (struct changer_element_status *) malloc(avail * sizeof(struct changer_element_status), - M_DEVBUF, M_WAITOK); - bzero(user_data, avail * sizeof(struct changer_element_status)); + M_DEVBUF, M_WAITOK | M_ZERO); desc = (struct read_element_status_descriptor *)((uintptr_t)data + sizeof(struct read_element_status_header) + diff --git a/sys/dev/advansys/adwcam.c b/sys/dev/advansys/adwcam.c index 77c1718..3c9b00b 100644 --- a/sys/dev/advansys/adwcam.c +++ b/sys/dev/advansys/adwcam.c @@ -824,12 +824,11 @@ adw_alloc(device_t dev, struct resource *regs, int regs_type, int regs_id) /* * Allocate a storage area for us */ - adw = malloc(sizeof(struct adw_softc), M_DEVBUF, M_NOWAIT); + adw = malloc(sizeof(struct adw_softc), M_DEVBUF, M_NOWAIT | M_ZERO); if (adw == NULL) { printf("adw%d: cannot malloc!\n", device_get_unit(dev)); return NULL; } - bzero(adw, sizeof(struct adw_softc)); LIST_INIT(&adw->pending_ccbs); SLIST_INIT(&adw->sg_maps); adw->device = dev; diff --git a/sys/dev/ahb/ahb.c b/sys/dev/ahb/ahb.c index 9fc15a4..bbd6fd0 100644 --- a/sys/dev/ahb/ahb.c +++ b/sys/dev/ahb/ahb.c @@ -393,12 +393,11 @@ ahballoc(u_long unit, struct resource *res) /* * Allocate a storage area for us */ - ahb = malloc(sizeof(struct ahb_softc), M_DEVBUF, M_NOWAIT); + ahb = malloc(sizeof(struct ahb_softc), M_DEVBUF, M_NOWAIT | M_ZERO); if (!ahb) { printf("ahb%ld: cannot malloc!\n", unit); return (NULL); } - bzero(ahb, sizeof(struct ahb_softc)); SLIST_INIT(&ahb->free_ecbs); LIST_INIT(&ahb->pending_ccbs); ahb->unit = unit; diff --git a/sys/dev/aic7xxx/aic7xxx_freebsd.c b/sys/dev/aic7xxx/aic7xxx_freebsd.c index 4ca846c..31ae3a5 100644 --- a/sys/dev/aic7xxx/aic7xxx_freebsd.c +++ b/sys/dev/aic7xxx/aic7xxx_freebsd.c @@ -1795,11 +1795,10 @@ ahc_platform_set_tags(struct ahc_softc *ahc, int ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg) { - ahc->platform_data = - malloc(sizeof(struct ahc_platform_data), M_DEVBUF, M_NOWAIT); + ahc->platform_data = malloc(sizeof(struct ahc_platform_data), M_DEVBUF, + M_NOWAIT | M_ZERO); if (ahc->platform_data == NULL) return (ENOMEM); - memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data)); return (0); } diff --git a/sys/dev/aic7xxx/aic7xxx_osm.c b/sys/dev/aic7xxx/aic7xxx_osm.c index 4ca846c..31ae3a5 100644 --- a/sys/dev/aic7xxx/aic7xxx_osm.c +++ b/sys/dev/aic7xxx/aic7xxx_osm.c @@ -1795,11 +1795,10 @@ ahc_platform_set_tags(struct ahc_softc *ahc, int ahc_platform_alloc(struct ahc_softc *ahc, void *platform_arg) { - ahc->platform_data = - malloc(sizeof(struct ahc_platform_data), M_DEVBUF, M_NOWAIT); + ahc->platform_data = malloc(sizeof(struct ahc_platform_data), M_DEVBUF, + M_NOWAIT | M_ZERO); if (ahc->platform_data == NULL) return (ENOMEM); - memset(ahc->platform_data, 0, sizeof(struct ahc_platform_data)); return (0); } -- cgit v1.1