svn commit: r246439 - stable/9/sys/cam/ctl

Alexander Motin mav at FreeBSD.org
Wed Feb 6 22:25:29 UTC 2013


Author: mav
Date: Wed Feb  6 22:25:28 2013
New Revision: 246439
URL: http://svnweb.freebsd.org/changeset/base/246439

Log:
  MFC r242358 (by trasz):
  Use M_ZERO instead of explicit memsets and bzeros.

Modified:
  stable/9/sys/cam/ctl/ctl.c
  stable/9/sys/cam/ctl/ctl_backend_block.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/cam/ctl/ctl.c
==============================================================================
--- stable/9/sys/cam/ctl/ctl.c	Wed Feb  6 22:22:15 2013	(r246438)
+++ stable/9/sys/cam/ctl/ctl.c	Wed Feb  6 22:25:28 2013	(r246439)
@@ -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_so
 
 	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 *cts
 
 	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 *cts
 	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 *
 
 	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->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 *ct
 
 	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 @@ retry:
 	}
 	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 @@ retry:
 	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_sc
 	 * 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_sc
 	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_scsii
 	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_scsii
 	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
 		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
 	          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 

Modified: stable/9/sys/cam/ctl/ctl_backend_block.c
==============================================================================
--- stable/9/sys/cam/ctl/ctl_backend_block.c	Wed Feb  6 22:22:15 2013	(r246438)
+++ stable/9/sys/cam/ctl/ctl_backend_block.c	Wed Feb  6 22:25:28 2013	(r246439)
@@ -376,7 +376,6 @@ ctl_grow_beio(struct ctl_be_block_softc 
 		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);


More information about the svn-src-stable-9 mailing list