Use M_ZERO instead of explicit memsets and bzeros.
This commit is contained in:
parent
401f7c11ff
commit
a492b68b27
@ -957,11 +957,10 @@ ctl_init(void)
|
||||
if (ctl_disable != 0)
|
||||
return;
|
||||
|
||||
control_softc = malloc(sizeof(*control_softc), M_DEVBUF, M_WAITOK);
|
||||
control_softc = malloc(sizeof(*control_softc), M_DEVBUF,
|
||||
M_WAITOK | M_ZERO);
|
||||
softc = control_softc;
|
||||
|
||||
memset(softc, 0, sizeof(*softc));
|
||||
|
||||
softc->dev = make_dev(&ctl_cdevsw, 0, UID_ROOT, GID_OPERATOR, 0600,
|
||||
"cam/ctl");
|
||||
|
||||
@ -3271,14 +3270,13 @@ ctl_pool_create(struct ctl_softc *ctl_softc, ctl_pool_type pool_type,
|
||||
|
||||
retval = 0;
|
||||
|
||||
pool = (struct ctl_io_pool *)malloc(sizeof(*pool), M_CTL, M_NOWAIT);
|
||||
pool = (struct ctl_io_pool *)malloc(sizeof(*pool), M_CTL,
|
||||
M_NOWAIT | M_ZERO);
|
||||
if (pool == NULL) {
|
||||
retval = -ENOMEM;
|
||||
goto bailout;
|
||||
}
|
||||
|
||||
memset(pool, 0, sizeof(*pool));
|
||||
|
||||
pool->type = pool_type;
|
||||
pool->ctl_softc = ctl_softc;
|
||||
|
||||
@ -6561,7 +6559,7 @@ ctl_mode_sense(struct ctl_scsiio *ctsio)
|
||||
header_len, page_len, total_len);
|
||||
#endif
|
||||
|
||||
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
|
||||
ctsio->kern_sg_entries = 0;
|
||||
ctsio->kern_data_resid = 0;
|
||||
ctsio->kern_rel_offset = 0;
|
||||
@ -6574,7 +6572,6 @@ ctl_mode_sense(struct ctl_scsiio *ctsio)
|
||||
ctsio->kern_data_len = alloc_len;
|
||||
ctsio->kern_total_len = alloc_len;
|
||||
}
|
||||
memset(ctsio->kern_data_ptr, 0, total_len);
|
||||
|
||||
switch (ctsio->cdb[0]) {
|
||||
case MODE_SENSE_6: {
|
||||
@ -6742,7 +6739,7 @@ ctl_read_capacity(struct ctl_scsiio *ctsio)
|
||||
|
||||
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
|
||||
|
||||
ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK | M_ZERO);
|
||||
data = (struct scsi_read_capacity_data *)ctsio->kern_data_ptr;
|
||||
ctsio->residual = 0;
|
||||
ctsio->kern_data_len = sizeof(*data);
|
||||
@ -6751,8 +6748,6 @@ ctl_read_capacity(struct ctl_scsiio *ctsio)
|
||||
ctsio->kern_rel_offset = 0;
|
||||
ctsio->kern_sg_entries = 0;
|
||||
|
||||
memset(data, 0, sizeof(*data));
|
||||
|
||||
/*
|
||||
* If the maximum LBA is greater than 0xfffffffe, the user must
|
||||
* issue a SERVICE ACTION IN (16) command, with the read capacity
|
||||
@ -6806,7 +6801,7 @@ ctl_read_capacity_16(struct ctl_scsiio *ctsio)
|
||||
|
||||
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
|
||||
|
||||
ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK | M_ZERO);
|
||||
data = (struct scsi_read_capacity_data_long *)ctsio->kern_data_ptr;
|
||||
|
||||
if (sizeof(*data) < alloc_len) {
|
||||
@ -6822,8 +6817,6 @@ ctl_read_capacity_16(struct ctl_scsiio *ctsio)
|
||||
ctsio->kern_rel_offset = 0;
|
||||
ctsio->kern_sg_entries = 0;
|
||||
|
||||
memset(data, 0, sizeof(*data));
|
||||
|
||||
scsi_u64to8b(lun->be_lun->maxlba, data->addr);
|
||||
/* XXX KDM this may not be 512 bytes... */
|
||||
scsi_ulto4b(lun->be_lun->blocksize, data->length);
|
||||
@ -6913,8 +6906,7 @@ ctl_maintenance_in(struct ctl_scsiio *ctsio)
|
||||
|
||||
alloc_len = scsi_4btoul(cdb->length);
|
||||
|
||||
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK);
|
||||
memset(ctsio->kern_data_ptr, 0, total_len);
|
||||
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
|
||||
|
||||
ctsio->kern_sg_entries = 0;
|
||||
|
||||
@ -7068,7 +7060,7 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio)
|
||||
}
|
||||
mtx_unlock(&softc->ctl_lock);
|
||||
|
||||
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(total_len, M_CTL, M_WAITOK | M_ZERO);
|
||||
|
||||
if (total_len < alloc_len) {
|
||||
ctsio->residual = alloc_len - total_len;
|
||||
@ -7084,8 +7076,6 @@ ctl_persistent_reserve_in(struct ctl_scsiio *ctsio)
|
||||
ctsio->kern_rel_offset = 0;
|
||||
ctsio->kern_sg_entries = 0;
|
||||
|
||||
memset(ctsio->kern_data_ptr, 0, total_len);
|
||||
|
||||
mtx_lock(&softc->ctl_lock);
|
||||
switch (cdb->action) {
|
||||
case SPRI_RK: { // read keys
|
||||
@ -8611,7 +8601,7 @@ ctl_report_luns(struct ctl_scsiio *ctsio)
|
||||
lun_datalen = sizeof(*lun_data) +
|
||||
(num_luns * sizeof(struct scsi_report_luns_lundata));
|
||||
|
||||
ctsio->kern_data_ptr = malloc(lun_datalen, M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(lun_datalen, M_CTL, M_WAITOK | M_ZERO);
|
||||
lun_data = (struct scsi_report_luns_data *)ctsio->kern_data_ptr;
|
||||
ctsio->kern_sg_entries = 0;
|
||||
|
||||
@ -8630,8 +8620,6 @@ ctl_report_luns(struct ctl_scsiio *ctsio)
|
||||
|
||||
initidx = ctl_get_initindex(&ctsio->io_hdr.nexus);
|
||||
|
||||
memset(lun_data, 0, lun_datalen);
|
||||
|
||||
/*
|
||||
* We set this to the actual data length, regardless of how much
|
||||
* space we actually have to return results. If the user looks at
|
||||
@ -8907,7 +8895,7 @@ ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len)
|
||||
* XXX KDM GFP_??? We probably don't want to wait here,
|
||||
* unless we end up having a process/thread context.
|
||||
*/
|
||||
ctsio->kern_data_ptr = malloc(sup_page_size, M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(sup_page_size, M_CTL, M_WAITOK | M_ZERO);
|
||||
if (ctsio->kern_data_ptr == NULL) {
|
||||
ctsio->io_hdr.status = CTL_SCSI_ERROR;
|
||||
ctsio->scsi_status = SCSI_STATUS_BUSY;
|
||||
@ -8930,8 +8918,6 @@ ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len)
|
||||
ctsio->kern_rel_offset = 0;
|
||||
ctsio->kern_sg_entries = 0;
|
||||
|
||||
memset(pages, 0, sup_page_size);
|
||||
|
||||
/*
|
||||
* The control device is always connected. The disk device, on the
|
||||
* other hand, may not be online all the time. Need to change this
|
||||
@ -8971,7 +8957,7 @@ ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len)
|
||||
lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr;
|
||||
|
||||
/* XXX KDM which malloc flags here?? */
|
||||
ctsio->kern_data_ptr = malloc(sizeof(*sn_ptr), M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(sizeof(*sn_ptr), M_CTL, M_WAITOK | M_ZERO);
|
||||
if (ctsio->kern_data_ptr == NULL) {
|
||||
ctsio->io_hdr.status = CTL_SCSI_ERROR;
|
||||
ctsio->scsi_status = SCSI_STATUS_BUSY;
|
||||
@ -8994,8 +8980,6 @@ ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len)
|
||||
ctsio->kern_rel_offset = 0;
|
||||
ctsio->kern_sg_entries = 0;
|
||||
|
||||
memset(sn_ptr, 0, sizeof(*sn_ptr));
|
||||
|
||||
/*
|
||||
* The control device is always connected. The disk device, on the
|
||||
* other hand, may not be online all the time. Need to change this
|
||||
@ -9065,7 +9049,7 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len)
|
||||
sizeof(struct scsi_vpd_id_trgt_port_grp_id);
|
||||
|
||||
/* XXX KDM which malloc flags here ?? */
|
||||
ctsio->kern_data_ptr = malloc(devid_len, M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(devid_len, M_CTL, M_WAITOK | M_ZERO);
|
||||
if (ctsio->kern_data_ptr == NULL) {
|
||||
ctsio->io_hdr.status = CTL_SCSI_ERROR;
|
||||
ctsio->scsi_status = SCSI_STATUS_BUSY;
|
||||
@ -9096,7 +9080,6 @@ ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len)
|
||||
CTL_WWPN_LEN);
|
||||
desc3 = (struct scsi_vpd_id_descriptor *)(&desc2->identifier[0] +
|
||||
sizeof(struct scsi_vpd_id_rel_trgt_port_id));
|
||||
memset(devid_ptr, 0, devid_len);
|
||||
|
||||
/*
|
||||
* The control device is always connected. The disk device, on the
|
||||
@ -9296,7 +9279,7 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio)
|
||||
* that much.
|
||||
*/
|
||||
/* XXX KDM what malloc flags should we use here?? */
|
||||
ctsio->kern_data_ptr = malloc(sizeof(*inq_ptr), M_CTL, M_WAITOK);
|
||||
ctsio->kern_data_ptr = malloc(sizeof(*inq_ptr), M_CTL, M_WAITOK | M_ZERO);
|
||||
if (ctsio->kern_data_ptr == NULL) {
|
||||
ctsio->io_hdr.status = CTL_SCSI_ERROR;
|
||||
ctsio->scsi_status = SCSI_STATUS_BUSY;
|
||||
@ -9318,8 +9301,6 @@ ctl_inquiry_std(struct ctl_scsiio *ctsio)
|
||||
ctsio->kern_total_len = alloc_len;
|
||||
}
|
||||
|
||||
memset(inq_ptr, 0, sizeof(*inq_ptr));
|
||||
|
||||
/*
|
||||
* If we have a LUN configured, report it as connected. Otherwise,
|
||||
* report that it is offline or no device is supported, depending
|
||||
|
@ -376,7 +376,6 @@ ctl_grow_beio(struct ctl_be_block_softc *softc, int count)
|
||||
beio = (struct ctl_be_block_io *)malloc(sizeof(*beio),
|
||||
M_CTLBLK,
|
||||
M_WAITOK | M_ZERO);
|
||||
bzero(beio, sizeof(*beio));
|
||||
beio->softc = softc;
|
||||
mtx_lock(&softc->lock);
|
||||
STAILQ_INSERT_TAIL(&softc->beio_free_queue, beio, links);
|
||||
|
Loading…
Reference in New Issue
Block a user