Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Dec 2021 15:56:31 GMT
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 66cc270f8f0f - stable/13 - cam: Remove all the write-only variables
Message-ID:  <202112061556.1B6FuVl9033636@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=66cc270f8f0f40c979e0264057a61027f58285b1

commit 66cc270f8f0f40c979e0264057a61027f58285b1
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-11-24 04:14:05 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-12-06 15:55:57 +0000

    cam: Remove all the write-only variables
    
    Delete all the write only variables in CAM. At worst, the only behavior
    change would be to prevent core dumps from chasing NULL pointers (though
    I think in all these cases the pointers can't be NULL).
    
    Sponsored by:           Netflix
    
    (cherry picked from commit 6637b7460066314f9b3ce0073ec6563e15ece608)
---
 sys/cam/nvme/nvme_da.c      |  7 -------
 sys/cam/nvme/nvme_xpt.c     |  4 ----
 sys/cam/scsi/scsi_cd.c      |  2 --
 sys/cam/scsi/scsi_ch.c      |  5 -----
 sys/cam/scsi/scsi_da.c      |  6 ------
 sys/cam/scsi/scsi_enc.c     |  5 -----
 sys/cam/scsi/scsi_enc_ses.c |  4 ----
 sys/cam/scsi/scsi_pass.c    | 10 +---------
 8 files changed, 1 insertion(+), 42 deletions(-)

diff --git a/sys/cam/nvme/nvme_da.c b/sys/cam/nvme/nvme_da.c
index baeaad182f3a..f1c9a9ec9fea 100644
--- a/sys/cam/nvme/nvme_da.c
+++ b/sys/cam/nvme/nvme_da.c
@@ -375,10 +375,8 @@ ndaioctl(struct disk *dp, u_long cmd, void *data, int fflag,
     struct thread *td)
 {
 	struct cam_periph *periph;
-	struct nda_softc *softc;
 
 	periph = (struct cam_periph *)dp->d_drv1;
-	softc = (struct nda_softc *)periph->softc;
 
 	switch (cmd) {
 	case NVME_IO_TEST:
@@ -1269,11 +1267,6 @@ ndadone(struct cam_periph *periph, union ccb *done_ccb)
 static int
 ndaerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
 {
-	struct nda_softc *softc;
-	struct cam_periph *periph;
-
-	periph = xpt_path_periph(ccb->ccb_h.path);
-	softc = (struct nda_softc *)periph->softc;
 
 	switch (ccb->ccb_h.status & CAM_STATUS_MASK) {
 	case CAM_CMD_TIMEOUT:
diff --git a/sys/cam/nvme/nvme_xpt.c b/sys/cam/nvme/nvme_xpt.c
index 800d6aeb291e..2aeda18ad3be 100644
--- a/sys/cam/nvme/nvme_xpt.c
+++ b/sys/cam/nvme/nvme_xpt.c
@@ -258,13 +258,11 @@ nvme_probe_start(struct cam_periph *periph, union ccb *start_ccb)
 {
 	struct ccb_nvmeio *nvmeio;
 	nvme_probe_softc *softc;
-	struct cam_path *path;
 	lun_id_t lun;
 
 	CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_TRACE, ("nvme_probe_start\n"));
 
 	softc = (nvme_probe_softc *)periph->softc;
-	path = start_ccb->ccb_h.path;
 	nvmeio = &start_ccb->nvmeio;
 	lun = xpt_path_lun_id(periph->path);
 
@@ -312,7 +310,6 @@ nvme_probe_done(struct cam_periph *periph, union ccb *done_ccb)
 	struct cam_path *path;
 	struct scsi_vpd_device_id *did;
 	struct scsi_vpd_id_descriptor *idd;
-	cam_status status;
 	u_int32_t  priority;
 	int found = 1, e, g, len;
 
@@ -335,7 +332,6 @@ out:
 			/* Don't wedge the queue */
 			xpt_release_devq(path, /*count*/1, /*run_queue*/TRUE);
 		}
-		status = done_ccb->ccb_h.status & CAM_STATUS_MASK;
 
 		/*
 		 * If we get to this point, we got an error status back
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c
index 0c7068bf287e..460b423e469e 100644
--- a/sys/cam/scsi/scsi_cd.c
+++ b/sys/cam/scsi/scsi_cd.c
@@ -3146,12 +3146,10 @@ static int
 cdreadtoc(struct cam_periph *periph, u_int32_t mode, u_int32_t start,
 	  u_int8_t *data, u_int32_t len, u_int32_t sense_flags)
 {
-	u_int32_t ntoc;
         struct ccb_scsiio *csio;
 	union ccb *ccb;
 	int error;
 
-	ntoc = len;
 	error = 0;
 
 	ccb = cam_periph_getccb(periph, CAM_PRIORITY_NORMAL);
diff --git a/sys/cam/scsi/scsi_ch.c b/sys/cam/scsi/scsi_ch.c
index 64b0947eaf8d..2599bb841345 100644
--- a/sys/cam/scsi/scsi_ch.c
+++ b/sys/cam/scsi/scsi_ch.c
@@ -735,11 +735,6 @@ chdone(struct cam_periph *periph, union ccb *done_ccb)
 static int
 cherror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
 {
-	struct ch_softc *softc;
-	struct cam_periph *periph;
-
-	periph = xpt_path_periph(ccb->ccb_h.path);
-	softc = (struct ch_softc *)periph->softc;
 
 	return (cam_periph_error(ccb, cam_flags, sense_flags));
 }
diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c
index abe66e4acd35..034953494bf6 100644
--- a/sys/cam/scsi/scsi_da.c
+++ b/sys/cam/scsi/scsi_da.c
@@ -4516,13 +4516,11 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
 	struct bio *bp, *bp1;
 	struct da_softc *softc;
 	struct ccb_scsiio *csio;
-	u_int32_t  priority;
 	da_ccb_state state;
 
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone\n"));
 
 	softc = (struct da_softc *)periph->softc;
-	priority = done_ccb->ccb_h.pinfo.priority;
 	csio = &done_ccb->csio;
 
 #if defined(BUF_TRACKING) || defined(FULL_BUF_TRACKING)
@@ -5286,7 +5284,6 @@ dadone_probeata(struct cam_periph *periph, union ccb *done_ccb)
 	u_int32_t  priority;
 	int continue_probe;
 	int error;
-	int16_t *ptr;
 
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_probeata\n"));
 
@@ -5294,7 +5291,6 @@ dadone_probeata(struct cam_periph *periph, union ccb *done_ccb)
 	priority = done_ccb->ccb_h.pinfo.priority;
 	csio = &done_ccb->csio;
 	ata_params = (struct ata_params *)csio->data_ptr;
-	ptr = (uint16_t *)ata_params;
 	continue_probe = 0;
 	error = 0;
 
@@ -5879,12 +5875,10 @@ static void
 dadone_tur(struct cam_periph *periph, union ccb *done_ccb)
 {
 	struct da_softc *softc;
-	struct ccb_scsiio *csio;
 
 	CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("dadone_tur\n"));
 
 	softc = (struct da_softc *)periph->softc;
-	csio = &done_ccb->csio;
 
 	cam_periph_assert(periph, MA_OWNED);
 
diff --git a/sys/cam/scsi/scsi_enc.c b/sys/cam/scsi/scsi_enc.c
index 30cbf108fd44..ad6c09c99f58 100644
--- a/sys/cam/scsi/scsi_enc.c
+++ b/sys/cam/scsi/scsi_enc.c
@@ -345,11 +345,6 @@ enc_close(struct cdev *dev, int flag, int fmt, struct thread *td)
 int
 enc_error(union ccb *ccb, uint32_t cflags, uint32_t sflags)
 {
-	struct enc_softc *softc;
-	struct cam_periph *periph;
-
-	periph = xpt_path_periph(ccb->ccb_h.path);
-	softc = (struct enc_softc *)periph->softc;
 
 	return (cam_periph_error(ccb, cflags, sflags));
 }
diff --git a/sys/cam/scsi/scsi_enc_ses.c b/sys/cam/scsi/scsi_enc_ses.c
index d20f3dec4e52..7d3664beafdb 100644
--- a/sys/cam/scsi/scsi_enc_ses.c
+++ b/sys/cam/scsi/scsi_enc_ses.c
@@ -1336,7 +1336,6 @@ ses_process_config(enc_softc_t *enc, struct enc_fsm_state *state,
     union ccb *ccb, uint8_t **bufp, int error, int xfer_len)
 {
 	struct ses_iterator iter;
-	ses_softc_t *ses;
 	enc_cache_t *enc_cache;
 	ses_cache_t *ses_cache;
 	uint8_t *buf;
@@ -1359,7 +1358,6 @@ ses_process_config(enc_softc_t *enc, struct enc_fsm_state *state,
 
 	CAM_DEBUG(enc->periph->path, CAM_DEBUG_SUBTRACE,
 	    ("entering %s(%p, %d)\n", __func__, bufp, xfer_len));
-	ses = enc->enc_private;
 	enc_cache = &enc->enc_daemon_cache;
 	ses_cache = enc_cache->private;
 	buf = *bufp;
@@ -2867,7 +2865,6 @@ ses_get_elm_devnames(enc_softc_t *enc, encioc_elm_devnames_t *elmdn)
 static int
 ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, int ioc)
 {
-	ses_softc_t *ses;
 	enc_cache_t *enc_cache;
 	ses_cache_t *ses_cache;
 	const struct ses_enc_desc *enc_desc;
@@ -2880,7 +2877,6 @@ ses_handle_string(enc_softc_t *enc, encioc_string_t *sstr, int ioc)
 	uint8_t *buf;
 	size_t size, rsize;
 
-	ses = enc->enc_private;
 	enc_cache = &enc->enc_daemon_cache;
 	ses_cache = enc_cache->private;
 
diff --git a/sys/cam/scsi/scsi_pass.c b/sys/cam/scsi/scsi_pass.c
index 146ff8f26700..456eff641776 100644
--- a/sys/cam/scsi/scsi_pass.c
+++ b/sys/cam/scsi/scsi_pass.c
@@ -1203,7 +1203,7 @@ static int
 passcopysglist(struct cam_periph *periph, struct pass_io_req *io_req,
 	       ccb_flags direction)
 {
-	bus_size_t kern_watermark, user_watermark, len_copied, len_to_copy;
+	bus_size_t kern_watermark, user_watermark, len_to_copy;
 	bus_dma_segment_t *user_sglist, *kern_sglist;
 	int i, j, error;
 
@@ -1211,7 +1211,6 @@ passcopysglist(struct cam_periph *periph, struct pass_io_req *io_req,
 	kern_watermark = 0;
 	user_watermark = 0;
 	len_to_copy = 0;
-	len_copied = 0;
 	user_sglist = io_req->user_segptr;
 	kern_sglist = io_req->kern_segptr;
 
@@ -1250,8 +1249,6 @@ passcopysglist(struct cam_periph *periph, struct pass_io_req *io_req,
 			}
 		}
 
-		len_copied += len_to_copy;
-
 		if (user_sglist[i].ds_len == user_watermark) {
 			i++;
 			user_watermark = 0;
@@ -2240,11 +2237,6 @@ passsendccb(struct cam_periph *periph, union ccb *ccb, union ccb *inccb)
 static int
 passerror(union ccb *ccb, u_int32_t cam_flags, u_int32_t sense_flags)
 {
-	struct cam_periph *periph;
-	struct pass_softc *softc;
-
-	periph = xpt_path_periph(ccb->ccb_h.path);
-	softc = (struct pass_softc *)periph->softc;
 
 	return(cam_periph_error(ccb, cam_flags, sense_flags));
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112061556.1B6FuVl9033636>