All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14
@ 2017-08-25 20:46 Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 01/17] Remove an obsolete function declaration Bart Van Assche
                   ` (17 more replies)
  0 siblings, 18 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley; +Cc: linux-scsi, Bart Van Assche

Hello Martin,

The patches in this series fall into three categories:
- One patch renames a few functions to make it clear whether these
  are used by the legacy SCSI code path or by the new scsi-mq code.
- Two patches are related to using blk_mq_rq_to_pdu() instead of
  struct request.special.
- Fourteen patches suppress warnings reported by static analysis
  tools. These tools are very useful but unfortunately the current
  code base makes these tools report a significant number of false
  positives.

Please consider these patches for kernel v4.14.

Thanks,

Bart.

Changes in v2 compared to v1:
- Left out the SCSI device VPD patch from this series and posted it
  separately as a two-patch series.
- Reworked patch "scsi_transport_srp: Suppress a W=1 compiler warning".
- Dropped the patch "scsi_setup_fs_cmnd(): Call scsi_req_init() instead of
  open-coding it".

Bart Van Assche (17):
  Remove an obsolete function declaration
  Avoid sign extension of scsi_device.type
  Suppress gcc 7 fall-through warnings reported with W=1
  Convert a strncmp() call into a strcmp() call
  Document which queue type a function is intended for
  Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer
  sd, sr: Convert two assignments into warning statements
  sd: Fix indentation
  sd: Remove a useless comparison
  sg: Fix type of last blk_trace_setup() argument
  libiscsi: Fix indentation
  libsas: Remove a set-but-not-used variable
  libsas: Annotate fall-through in a switch statement
  scsi_transport_sas, sas_tlr_supported(): Check kzalloc() return value
  scsi_transport_srp: Suppress a W=1 compiler warning
  scsi_debug: Remove a set-but-not-used variable
  iscsi_tcp: Remove a set-but-not-used variable

 drivers/scsi/iscsi_tcp.c            |  2 --
 drivers/scsi/libiscsi.c             |  2 +-
 drivers/scsi/libsas/sas_ata.c       |  1 +
 drivers/scsi/libsas/sas_scsi_host.c |  3 ---
 drivers/scsi/scsi_debug.c           |  3 +--
 drivers/scsi/scsi_error.c           | 10 +++++++--
 drivers/scsi/scsi_ioctl.c           |  4 +++-
 drivers/scsi/scsi_lib.c             | 41 +++++++++++++++++++------------------
 drivers/scsi/scsi_priv.h            |  2 +-
 drivers/scsi/scsi_scan.c            |  2 +-
 drivers/scsi/scsi_sysfs.c           |  2 +-
 drivers/scsi/scsi_transport_sas.c   |  3 +++
 drivers/scsi/scsi_transport_srp.c   |  2 +-
 drivers/scsi/sd.c                   |  6 +++---
 drivers/scsi/sg.c                   |  3 +--
 drivers/scsi/sr.c                   |  2 +-
 include/scsi/scsi_cmnd.h            |  1 -
 include/scsi/scsi_device.h          |  2 +-
 include/scsi/scsi_tcq.h             |  2 +-
 include/scsi/scsi_transport_srp.h   |  2 +-
 20 files changed, 50 insertions(+), 45 deletions(-)

-- 
2.14.1

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH v2 01/17] Remove an obsolete function declaration
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 02/17] Avoid sign extension of scsi_device.type Bart Van Assche
                   ` (16 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Hannes Reinecke, Johannes Thumshirn

Commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as part of
struct request") removed the scsi_get_command() function. Hence also
remove the declaration of that function.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 include/scsi/scsi_cmnd.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index a1266d318c85..f5afcff8d76f 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -158,7 +158,6 @@ static inline struct scsi_driver *scsi_cmd_to_driver(struct scsi_cmnd *cmd)
 	return *(struct scsi_driver **)cmd->request->rq_disk->private_data;
 }
 
-extern struct scsi_cmnd *scsi_get_command(struct scsi_device *, gfp_t);
 extern void scsi_put_command(struct scsi_cmnd *);
 extern void scsi_finish_command(struct scsi_cmnd *cmd);
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 02/17] Avoid sign extension of scsi_device.type
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 01/17] Remove an obsolete function declaration Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 03/17] Suppress gcc 7 fall-through warnings reported with W=1 Bart Van Assche
                   ` (15 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Johannes Thumshirn

This patch avoids that smatch reports the following:

drivers/scsi/scsi_sysfs.c:506 scsi_bus_uevent() warn: argument 3 to %02x specifier has type 'char'
drivers/scsi/scsi_sysfs.c:872 sdev_show_modalias() warn: argument 4 to %02x specifier has type 'char'

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 include/scsi/scsi_device.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 0979a5f3b69a..f054f3f43c75 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -111,7 +111,7 @@ struct scsi_device {
 	unsigned sector_size;	/* size in bytes */
 
 	void *hostdata;		/* available to low-level driver */
-	char type;
+	unsigned char type;
 	char scsi_level;
 	char inq_periph_qual;	/* PQ from INQUIRY data */	
 	struct mutex inquiry_mutex;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 03/17] Suppress gcc 7 fall-through warnings reported with W=1
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 01/17] Remove an obsolete function declaration Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 02/17] Avoid sign extension of scsi_device.type Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 04/17] Convert a strncmp() call into a strcmp() call Bart Van Assche
                   ` (14 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Hannes Reinecke, Johannes Thumshirn

The conclusion of a recent discussion about the new warnings
reported by gcc 7 is that the new warnings reported when building
with W=1 should be suppressed. However, gcc 7 still warns about
fall-through in switch statements when building with W=1. Suppress
these warnings by annotating the SCSI core properly.

See also Linus Torvalds, Lots of new warnings with gcc-7.1.1, 11
July 2017 (https://www.mail-archive.com/linux-media@vger.kernel.org/msg115428.html).

References: commit bd664f6b3e37 ("disable new gcc-7.1.1 warnings for now")
Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/scsi_error.c | 8 +++++++-
 drivers/scsi/scsi_ioctl.c | 4 +++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index ea9f40e51f68..01b2d2055edf 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -552,6 +552,7 @@ int scsi_check_sense(struct scsi_cmnd *scmd)
 			set_host_byte(scmd, DID_ALLOC_FAILURE);
 			return SUCCESS;
 		}
+		/* FALLTHROUGH */
 	case COPY_ABORTED:
 	case VOLUME_OVERFLOW:
 	case MISCOMPARE:
@@ -573,6 +574,7 @@ int scsi_check_sense(struct scsi_cmnd *scmd)
 			return ADD_TO_MLQUEUE;
 		else
 			set_host_byte(scmd, DID_TARGET_FAILURE);
+		/* FALLTHROUGH */
 
 	case ILLEGAL_REQUEST:
 		if (sshdr.asc == 0x20 || /* Invalid command operation code */
@@ -683,6 +685,7 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
 	switch (status_byte(scmd->result)) {
 	case GOOD:
 		scsi_handle_queue_ramp_up(scmd->device);
+		/* FALLTHROUGH */
 	case COMMAND_TERMINATED:
 		return SUCCESS;
 	case CHECK_CONDITION:
@@ -1734,6 +1737,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 			set_host_byte(scmd, DID_TIME_OUT);
 			return SUCCESS;
 		}
+		/* FALLTHROUGH */
 	case DID_NO_CONNECT:
 	case DID_BAD_TARGET:
 		/*
@@ -1819,6 +1823,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * the case of trying to send too many commands to a
 		 * tagged queueing device.
 		 */
+		/* FALLTHROUGH */
 	case BUSY:
 		/*
 		 * device can't talk to us at the moment.  Should only
@@ -1831,6 +1836,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		if (scmd->cmnd[0] == REPORT_LUNS)
 			scmd->device->sdev_target->expecting_lun_change = 0;
 		scsi_handle_queue_ramp_up(scmd->device);
+		/* FALLTHROUGH */
 	case COMMAND_TERMINATED:
 		return SUCCESS;
 	case TASK_ABORTED:
@@ -2320,8 +2326,8 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
 		rtn = scsi_try_host_reset(scmd);
 		if (rtn == SUCCESS)
 			break;
-	default:
 		/* FALLTHROUGH */
+	default:
 		rtn = FAILED;
 		break;
 	}
diff --git a/drivers/scsi/scsi_ioctl.c b/drivers/scsi/scsi_ioctl.c
index b6bf3f29a12a..0a875491f5a7 100644
--- a/drivers/scsi/scsi_ioctl.c
+++ b/drivers/scsi/scsi_ioctl.c
@@ -116,13 +116,15 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,
 		case NOT_READY:	/* This happens if there is no disc in drive */
 			if (sdev->removable)
 				break;
+			/* FALLTHROUGH */
 		case UNIT_ATTENTION:
 			if (sdev->removable) {
 				sdev->changed = 1;
 				result = 0;	/* This is no longer considered an error */
 				break;
 			}
-		default:	/* Fall through for non-removable media */
+			/* FALLTHROUGH -- for non-removable media */
+		default:
 			sdev_printk(KERN_INFO, sdev,
 				    "ioctl_internal_command return code = %x\n",
 				    result);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 04/17] Convert a strncmp() call into a strcmp() call
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (2 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 03/17] Suppress gcc 7 fall-through warnings reported with W=1 Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 05/17] Document which queue type a function is intended for Bart Van Assche
                   ` (13 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Johannes Thumshirn

This patch avoids that smatch reports the following warning:

drivers/scsi/scsi_sysfs.c:117: check_set() error: strncmp() '"-"' too small (2 vs 20)

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/scsi_sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 41891db20108..5ed473a87589 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -114,7 +114,7 @@ static int check_set(unsigned long long *val, char *src)
 {
 	char *last;
 
-	if (strncmp(src, "-", 20) == 0) {
+	if (strcmp(src, "-") == 0) {
 		*val = SCAN_WILD_CARD;
 	} else {
 		/*
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 05/17] Document which queue type a function is intended for
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (3 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 04/17] Convert a strncmp() call into a strcmp() call Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 06/17] Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer Bart Van Assche
                   ` (12 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Bart Van Assche, Christoph Hellwig,
	Hannes Reinecke, Johannes Thumshirn

Rename several functions to make it easy to see which queue type a
function is intended for.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/scsi_lib.c  | 23 ++++++++++++-----------
 drivers/scsi/scsi_priv.h |  2 +-
 drivers/scsi/scsi_scan.c |  2 +-
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 98c600442227..1e2d1d8becbc 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -2006,8 +2006,8 @@ static enum blk_eh_timer_return scsi_timeout(struct request *req,
 	return scsi_times_out(req);
 }
 
-static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq,
-		unsigned int hctx_idx, unsigned int numa_node)
+static int scsi_mq_init_request(struct blk_mq_tag_set *set, struct request *rq,
+				unsigned int hctx_idx, unsigned int numa_node)
 {
 	struct Scsi_Host *shost = set->driver_data;
 	const bool unchecked_isa_dma = shost->unchecked_isa_dma;
@@ -2031,8 +2031,8 @@ static int scsi_init_request(struct blk_mq_tag_set *set, struct request *rq,
 	return 0;
 }
 
-static void scsi_exit_request(struct blk_mq_tag_set *set, struct request *rq,
-		unsigned int hctx_idx)
+static void scsi_mq_exit_request(struct blk_mq_tag_set *set, struct request *rq,
+				 unsigned int hctx_idx)
 {
 	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
 
@@ -2109,7 +2109,8 @@ void __scsi_init_queue(struct Scsi_Host *shost, struct request_queue *q)
 }
 EXPORT_SYMBOL_GPL(__scsi_init_queue);
 
-static int scsi_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp)
+static int scsi_old_init_rq(struct request_queue *q, struct request *rq,
+			    gfp_t gfp)
 {
 	struct Scsi_Host *shost = q->rq_alloc_data;
 	const bool unchecked_isa_dma = shost->unchecked_isa_dma;
@@ -2139,7 +2140,7 @@ static int scsi_init_rq(struct request_queue *q, struct request *rq, gfp_t gfp)
 	return -ENOMEM;
 }
 
-static void scsi_exit_rq(struct request_queue *q, struct request *rq)
+static void scsi_old_exit_rq(struct request_queue *q, struct request *rq)
 {
 	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
 
@@ -2149,7 +2150,7 @@ static void scsi_exit_rq(struct request_queue *q, struct request *rq)
 			       cmd->sense_buffer);
 }
 
-struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
+struct request_queue *scsi_old_alloc_queue(struct scsi_device *sdev)
 {
 	struct Scsi_Host *shost = sdev->host;
 	struct request_queue *q;
@@ -2160,8 +2161,8 @@ struct request_queue *scsi_alloc_queue(struct scsi_device *sdev)
 	q->cmd_size = sizeof(struct scsi_cmnd) + shost->hostt->cmd_size;
 	q->rq_alloc_data = shost;
 	q->request_fn = scsi_request_fn;
-	q->init_rq_fn = scsi_init_rq;
-	q->exit_rq_fn = scsi_exit_rq;
+	q->init_rq_fn = scsi_old_init_rq;
+	q->exit_rq_fn = scsi_old_exit_rq;
 	q->initialize_rq_fn = scsi_initialize_rq;
 
 	if (blk_init_allocated_queue(q) < 0) {
@@ -2185,8 +2186,8 @@ static const struct blk_mq_ops scsi_mq_ops = {
 #ifdef CONFIG_BLK_DEBUG_FS
 	.show_rq	= scsi_show_rq,
 #endif
-	.init_request	= scsi_init_request,
-	.exit_request	= scsi_exit_request,
+	.init_request	= scsi_mq_init_request,
+	.exit_request	= scsi_mq_exit_request,
 	.initialize_rq_fn = scsi_initialize_rq,
 	.map_queues	= scsi_map_queues,
 };
diff --git a/drivers/scsi/scsi_priv.h b/drivers/scsi/scsi_priv.h
index c11c1f9c912c..5c6d016a5ae9 100644
--- a/drivers/scsi/scsi_priv.h
+++ b/drivers/scsi/scsi_priv.h
@@ -88,7 +88,7 @@ extern void scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
 extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
 extern void scsi_run_host_queues(struct Scsi_Host *shost);
 extern void scsi_requeue_run_queue(struct work_struct *work);
-extern struct request_queue *scsi_alloc_queue(struct scsi_device *sdev);
+extern struct request_queue *scsi_old_alloc_queue(struct scsi_device *sdev);
 extern struct request_queue *scsi_mq_alloc_queue(struct scsi_device *sdev);
 extern void scsi_start_queue(struct scsi_device *sdev);
 extern int scsi_mq_setup_tags(struct Scsi_Host *shost);
diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index fd88dabd599d..e7818afeda2b 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -268,7 +268,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
 	if (shost_use_blk_mq(shost))
 		sdev->request_queue = scsi_mq_alloc_queue(sdev);
 	else
-		sdev->request_queue = scsi_alloc_queue(sdev);
+		sdev->request_queue = scsi_old_alloc_queue(sdev);
 	if (!sdev->request_queue) {
 		/* release fn is set up in scsi_sysfs_device_initialise, so
 		 * have to free and put manually here */
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 06/17] Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (4 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 05/17] Document which queue type a function is intended for Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 07/17] sd, sr: Convert two assignments into warning statements Bart Van Assche
                   ` (11 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Bart Van Assche

Since commit e9c787e65c0c ("scsi: allocate scsi_cmnd structures as
part of struct request") struct request and struct scsi_cmnd are
adjacent. This means that there is now an alternative to reading
req->special to convert a pointer to a prepared request into a
SCSI command pointer, namely by using blk_mq_rq_to_pdu(). Make
this change where appropriate. Although this patch does not
change any functionality, it slightly improves performance and
slightly improves readability.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/scsi_error.c |  2 +-
 drivers/scsi/scsi_lib.c   | 18 +++++++++---------
 include/scsi/scsi_tcq.h   |  2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 01b2d2055edf..38942050b265 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -259,7 +259,7 @@ void scsi_eh_scmd_add(struct scsi_cmnd *scmd)
  */
 enum blk_eh_timer_return scsi_times_out(struct request *req)
 {
-	struct scsi_cmnd *scmd = req->special;
+	struct scsi_cmnd *scmd = blk_mq_rq_to_pdu(req);
 	enum blk_eh_timer_return rtn = BLK_EH_NOT_HANDLED;
 	struct Scsi_Host *host = scmd->device->host;
 
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 1e2d1d8becbc..813d2456ae93 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -627,7 +627,7 @@ static void scsi_release_bidi_buffers(struct scsi_cmnd *cmd)
 static bool scsi_end_request(struct request *req, blk_status_t error,
 		unsigned int bytes, unsigned int bidi_bytes)
 {
-	struct scsi_cmnd *cmd = req->special;
+	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
 	struct scsi_device *sdev = cmd->device;
 	struct request_queue *q = sdev->request_queue;
 
@@ -1176,7 +1176,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)
 
 static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req)
 {
-	struct scsi_cmnd *cmd = req->special;
+	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
 
 	/*
 	 * Passthrough requests may transfer data, in which case they must
@@ -1207,7 +1207,7 @@ static int scsi_setup_scsi_cmnd(struct scsi_device *sdev, struct request *req)
  */
 static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
 {
-	struct scsi_cmnd *cmd = req->special;
+	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
 
 	if (unlikely(sdev->handler && sdev->handler->prep_fn)) {
 		int ret = sdev->handler->prep_fn(sdev, req);
@@ -1222,7 +1222,7 @@ static int scsi_setup_fs_cmnd(struct scsi_device *sdev, struct request *req)
 
 static int scsi_setup_cmnd(struct scsi_device *sdev, struct request *req)
 {
-	struct scsi_cmnd *cmd = req->special;
+	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
 
 	if (!blk_rq_bytes(req))
 		cmd->sc_data_direction = DMA_NONE;
@@ -1359,7 +1359,7 @@ static int scsi_prep_fn(struct request_queue *q, struct request *req)
 
 static void scsi_unprep_fn(struct request_queue *q, struct request *req)
 {
-	scsi_uninit_cmd(req->special);
+	scsi_uninit_cmd(blk_mq_rq_to_pdu(req));
 }
 
 /*
@@ -1550,7 +1550,7 @@ static int scsi_lld_busy(struct request_queue *q)
  */
 static void scsi_kill_request(struct request *req, struct request_queue *q)
 {
-	struct scsi_cmnd *cmd = req->special;
+	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
 	struct scsi_device *sdev;
 	struct scsi_target *starget;
 	struct Scsi_Host *shost;
@@ -1581,7 +1581,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
 
 static void scsi_softirq_done(struct request *rq)
 {
-	struct scsi_cmnd *cmd = rq->special;
+	struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(rq);
 	unsigned long wait_for = (cmd->allowed + 1) * rq->timeout;
 	int disposition;
 
@@ -1769,8 +1769,8 @@ static void scsi_request_fn(struct request_queue *q)
 			blk_start_request(req);
 
 		spin_unlock_irq(q->queue_lock);
-		cmd = req->special;
-		if (unlikely(cmd == NULL)) {
+		cmd = blk_mq_rq_to_pdu(req);
+		if (cmd != req->special) {
 			printk(KERN_CRIT "impossible request in %s.\n"
 					 "please mail a stack trace to "
 					 "linux-scsi@vger.kernel.org\n",
diff --git a/include/scsi/scsi_tcq.h b/include/scsi/scsi_tcq.h
index 4416b1026189..5b416debf101 100644
--- a/include/scsi/scsi_tcq.h
+++ b/include/scsi/scsi_tcq.h
@@ -39,7 +39,7 @@ static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
 
 	if (!req)
 		return NULL;
-	return req->special;
+	return blk_mq_rq_to_pdu(req);
 }
 
 #endif /* CONFIG_BLOCK */
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 07/17] sd, sr: Convert two assignments into warning statements
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (5 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 06/17] Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 08/17] sd: Fix indentation Bart Van Assche
                   ` (10 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Bart Van Assche

Before scsi_prep_fn() calls the ULP .init_command() callback
function it stores the SCSI command pointer in request.special.
This means that the SCpnt = rq->special assignments in the sd
and sr drivers assign a pointer to itself. Hence convert these
two assignment statements into warning statements.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
 drivers/scsi/sd.c | 2 +-
 drivers/scsi/sr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index bea36adeee17..a88639fbedb3 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1013,7 +1013,7 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
 	ret = scsi_init_io(SCpnt);
 	if (ret != BLKPREP_OK)
 		goto out;
-	SCpnt = rq->special;
+	WARN_ON_ONCE(SCpnt != rq->special);
 
 	/* from here on until we're complete, any goto out
 	 * is used for a killable error condition */
diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index a8f630213a1a..9be34d37c356 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -393,7 +393,7 @@ static int sr_init_command(struct scsi_cmnd *SCpnt)
 	ret = scsi_init_io(SCpnt);
 	if (ret != BLKPREP_OK)
 		goto out;
-	SCpnt = rq->special;
+	WARN_ON_ONCE(SCpnt != rq->special);
 	cd = scsi_cd(rq->rq_disk);
 
 	/* from here on until we're complete, any goto out
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 08/17] sd: Fix indentation
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (6 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 07/17] sd, sr: Convert two assignments into warning statements Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 09/17] sd: Remove a useless comparison Bart Van Assche
                   ` (9 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Johannes Thumshirn

This patch avoids that smatch reports the following:

drivers/scsi/sd.c:3540: sd_suspend_common() warn: inconsistent indenting

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index a88639fbedb3..8b3d7994e182 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3537,7 +3537,7 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
 			 * doesn't support sync. There's not much to do and
 			 * suspend shouldn't fail.
 			 */
-			 ret = 0;
+			ret = 0;
 		}
 	}
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 09/17] sd: Remove a useless comparison
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (7 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 08/17] sd: Fix indentation Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 10/17] sg: Fix type of last blk_trace_setup() argument Bart Van Assche
                   ` (8 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Christoph Hellwig, Johannes Thumshirn

This patch avoids that gcc reports the following warning when
building with W=1:

drivers/scsi/sd.c:315:10: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]
  if (val >= 0 && val <= T10_PI_TYPE3_PROTECTION)

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/sd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 8b3d7994e182..7c0f9eb5a5fd 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -312,7 +312,7 @@ protection_type_store(struct device *dev, struct device_attribute *attr,
 	if (err)
 		return err;
 
-	if (val >= 0 && val <= T10_PI_TYPE3_PROTECTION)
+	if (val <= T10_PI_TYPE3_PROTECTION)
 		sdkp->protection_type = val;
 
 	return count;
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 10/17] sg: Fix type of last blk_trace_setup() argument
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (8 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 09/17] sd: Remove a useless comparison Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 11/17] libiscsi: Fix indentation Bart Van Assche
                   ` (7 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Johannes Thumshirn

Avoid that sparse reports the following:

drivers/scsi/sg.c:1114:41: warning: incorrect type in argument 5 (different address spaces)
drivers/scsi/sg.c:1114:41:    expected char [noderef] <asn:1>*arg
drivers/scsi/sg.c:1114:41:    got char *<noident>

This patch does not change any functionality.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/sg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index f5705a95319f..03194c4b6744 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -1110,8 +1110,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
 		return blk_trace_setup(sdp->device->request_queue,
 				       sdp->disk->disk_name,
 				       MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
-				       NULL,
-				       (char *)arg);
+				       NULL, p);
 	case BLKTRACESTART:
 		return blk_trace_startstop(sdp->device->request_queue, 1);
 	case BLKTRACESTOP:
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 11/17] libiscsi: Fix indentation
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (9 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 10/17] sg: Fix type of last blk_trace_setup() argument Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 12/17] libsas: Remove a set-but-not-used variable Bart Van Assche
                   ` (6 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Johannes Thumshirn

This patch avoids that smatch reports the following:

drivers/scsi/libiscsi.c:1081: iscsi_handle_reject() warn: inconsistent indenting

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/libiscsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 42381adf0769..bd4605a34f54 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -1078,7 +1078,7 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
 		if (opcode != ISCSI_OP_NOOP_OUT)
 			return 0;
 
-		 if (rejected_pdu.itt == cpu_to_be32(ISCSI_RESERVED_TAG)) {
+		if (rejected_pdu.itt == cpu_to_be32(ISCSI_RESERVED_TAG)) {
 			/*
 			 * nop-out in response to target's nop-out rejected.
 			 * Just resend.
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 12/17] libsas: Remove a set-but-not-used variable
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (10 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 11/17] libiscsi: Fix indentation Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 13/17] libsas: Annotate fall-through in a switch statement Bart Van Assche
                   ` (5 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Johannes Thumshirn

This was detected by building with W=1.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/libsas/sas_scsi_host.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 87e5079d816b..fc90b8c65860 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -855,7 +855,6 @@ int sas_target_alloc(struct scsi_target *starget)
 int sas_slave_configure(struct scsi_device *scsi_dev)
 {
 	struct domain_device *dev = sdev_to_domain_dev(scsi_dev);
-	struct sas_ha_struct *sas_ha;
 
 	BUG_ON(dev->rphy->identify.device_type != SAS_END_DEVICE);
 
@@ -864,8 +863,6 @@ int sas_slave_configure(struct scsi_device *scsi_dev)
 		return 0;
 	}
 
-	sas_ha = dev->port->ha;
-
 	sas_read_port_mode_page(scsi_dev);
 
 	if (scsi_dev->tagged_supported) {
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 13/17] libsas: Annotate fall-through in a switch statement
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (11 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 12/17] libsas: Remove a set-but-not-used variable Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 14/17] scsi_transport_sas, sas_tlr_supported(): Check kzalloc() return value Bart Van Assche
                   ` (4 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Johannes Thumshirn

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/libsas/sas_ata.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
index 87f5e694dbed..70be4425ae0b 100644
--- a/drivers/scsi/libsas/sas_ata.c
+++ b/drivers/scsi/libsas/sas_ata.c
@@ -343,6 +343,7 @@ static int smp_ata_check_ready(struct ata_link *link)
 	case SAS_END_DEVICE:
 		if (ex_phy->attached_sata_dev)
 			return sas_ata_clear_pending(dev, ex_phy);
+		/* fall through */
 	default:
 		return -ENODEV;
 	}
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 14/17] scsi_transport_sas, sas_tlr_supported(): Check kzalloc() return value
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (12 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 13/17] libsas: Annotate fall-through in a switch statement Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 15/17] scsi_transport_srp: Suppress a W=1 compiler warning Bart Van Assche
                   ` (3 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Johannes Thumshirn

Check whether memory allocation succeeded before dereferencing
the pointer to the allocated memory.

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/scsi_transport_sas.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/scsi_transport_sas.c b/drivers/scsi/scsi_transport_sas.c
index c5cde4ecef8e..6c05fd9a0be5 100644
--- a/drivers/scsi/scsi_transport_sas.c
+++ b/drivers/scsi/scsi_transport_sas.c
@@ -423,6 +423,9 @@ sas_tlr_supported(struct scsi_device *sdev)
 	char *buffer = kzalloc(vpd_len, GFP_KERNEL);
 	int ret = 0;
 
+	if (!buffer)
+		goto out;
+
 	if (scsi_get_vpd_page(sdev, 0x90, buffer, vpd_len))
 		goto out;
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 15/17] scsi_transport_srp: Suppress a W=1 compiler warning
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (13 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 14/17] scsi_transport_sas, sas_tlr_supported(): Check kzalloc() return value Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 16/17] scsi_debug: Remove a set-but-not-used variable Bart Van Assche
                   ` (2 subsequent siblings)
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Hannes Reinecke, Johannes Thumshirn

Avoid that the following compiler warning is reported when building
with W=1:

drivers/scsi/scsi_transport_srp.c:92:19: warning: comparison is always false due to limited range of data type [-Wtype-limits]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/scsi_transport_srp.c | 2 +-
 include/scsi/scsi_transport_srp.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
index 698cc4681706..4f6f01cf9968 100644
--- a/drivers/scsi/scsi_transport_srp.c
+++ b/drivers/scsi/scsi_transport_srp.c
@@ -78,7 +78,7 @@ static inline struct srp_rport *shost_to_rport(struct Scsi_Host *shost)
  * parameters must be such that multipath can detect failed paths timely.
  * Hence do not allow all three parameters to be disabled simultaneously.
  */
-int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo, int dev_loss_tmo)
+int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo, long dev_loss_tmo)
 {
 	if (reconnect_delay < 0 && fast_io_fail_tmo < 0 && dev_loss_tmo < 0)
 		return -EINVAL;
diff --git a/include/scsi/scsi_transport_srp.h b/include/scsi/scsi_transport_srp.h
index dd096330734e..56ae198acc73 100644
--- a/include/scsi/scsi_transport_srp.h
+++ b/include/scsi/scsi_transport_srp.h
@@ -111,7 +111,7 @@ extern struct srp_rport *srp_rport_add(struct Scsi_Host *,
 				       struct srp_rport_identifiers *);
 extern void srp_rport_del(struct srp_rport *);
 extern int srp_tmo_valid(int reconnect_delay, int fast_io_fail_tmo,
-			 int dev_loss_tmo);
+			 long dev_loss_tmo);
 int srp_parse_tmo(int *tmo, const char *buf);
 extern int srp_reconnect_rport(struct srp_rport *rport);
 extern void srp_start_tl_fail_timers(struct srp_rport *rport);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 16/17] scsi_debug: Remove a set-but-not-used variable
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (14 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 15/17] scsi_transport_srp: Suppress a W=1 compiler warning Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-08-25 20:46 ` [PATCH v2 17/17] iscsi_tcp: " Bart Van Assche
  2017-08-25 21:09 ` [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Martin K. Petersen
  17 siblings, 0 replies; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Douglas Gilbert, Johannes Thumshirn

This patch avoids that gcc reports the following warning when
building with W=1:

drivers/scsi/scsi_debug.c:2264:15: warning: variable ?pcontrol? set but not used [-Wunused-but-set-variable]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/scsi_debug.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 3be980d47268..77a0335eb757 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -2261,7 +2261,7 @@ static int resp_ie_l_pg(unsigned char * arr)
 static int resp_log_sense(struct scsi_cmnd * scp,
                           struct sdebug_dev_info * devip)
 {
-	int ppc, sp, pcontrol, pcode, subpcode, alloc_len, len, n;
+	int ppc, sp, pcode, subpcode, alloc_len, len, n;
 	unsigned char arr[SDEBUG_MAX_LSENSE_SZ];
 	unsigned char *cmd = scp->cmnd;
 
@@ -2272,7 +2272,6 @@ static int resp_log_sense(struct scsi_cmnd * scp,
 		mk_sense_invalid_fld(scp, SDEB_IN_CDB, 1, ppc ? 1 : 0);
 		return check_condition_result;
 	}
-	pcontrol = (cmd[2] & 0xc0) >> 6;
 	pcode = cmd[2] & 0x3f;
 	subpcode = cmd[3] & 0xff;
 	alloc_len = get_unaligned_be16(cmd + 7);
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [PATCH v2 17/17] iscsi_tcp: Remove a set-but-not-used variable
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (15 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 16/17] scsi_debug: Remove a set-but-not-used variable Bart Van Assche
@ 2017-08-25 20:46 ` Bart Van Assche
  2017-09-14 20:56   ` Lee Duncan
  2017-08-25 21:09 ` [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Martin K. Petersen
  17 siblings, 1 reply; 20+ messages in thread
From: Bart Van Assche @ 2017-08-25 20:46 UTC (permalink / raw)
  To: Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Bart Van Assche, Lee Duncan, Johannes Thumshirn

This patch avoids that gcc reports the following warning when
building with W=1:

drivers/scsi/iscsi_tcp.c:166:24: warning: variable ?session? set but not used [-Wunused-but-set-variable]

Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cc: Lee Duncan <lduncan@suse.com>
Cc: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/iscsi_tcp.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index 4842fc0e809d..4d934d6c3e13 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -163,7 +163,6 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
 	struct iscsi_tcp_conn *tcp_conn;
 	struct iscsi_sw_tcp_conn *tcp_sw_conn;
 	struct iscsi_conn *conn;
-	struct iscsi_session *session;
 	void (*old_state_change)(struct sock *);
 
 	read_lock_bh(&sk->sk_callback_lock);
@@ -172,7 +171,6 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
 		read_unlock_bh(&sk->sk_callback_lock);
 		return;
 	}
-	session = conn->session;
 
 	iscsi_sw_sk_state_check(sk);
 
-- 
2.14.1

^ permalink raw reply related	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14
  2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
                   ` (16 preceding siblings ...)
  2017-08-25 20:46 ` [PATCH v2 17/17] iscsi_tcp: " Bart Van Assche
@ 2017-08-25 21:09 ` Martin K. Petersen
  17 siblings, 0 replies; 20+ messages in thread
From: Martin K. Petersen @ 2017-08-25 21:09 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: Martin K . Petersen, James E . J . Bottomley, linux-scsi


Bart,

> The patches in this series fall into three categories:
> - One patch renames a few functions to make it clear whether these
>   are used by the legacy SCSI code path or by the new scsi-mq code.
> - Two patches are related to using blk_mq_rq_to_pdu() instead of
>   struct request.special.
> - Fourteen patches suppress warnings reported by static analysis
>   tools. These tools are very useful but unfortunately the current
>   code base makes these tools report a significant number of false
>   positives.

Applied to 4.14/scsi-queue. Thank you!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH v2 17/17] iscsi_tcp: Remove a set-but-not-used variable
  2017-08-25 20:46 ` [PATCH v2 17/17] iscsi_tcp: " Bart Van Assche
@ 2017-09-14 20:56   ` Lee Duncan
  0 siblings, 0 replies; 20+ messages in thread
From: Lee Duncan @ 2017-09-14 20:56 UTC (permalink / raw)
  To: Bart Van Assche, Martin K . Petersen, James E . J . Bottomley
  Cc: linux-scsi, Johannes Thumshirn



On 08/25/2017 01:46 PM, Bart Van Assche wrote:
> This patch avoids that gcc reports the following warning when
> building with W=1:
> 
> drivers/scsi/iscsi_tcp.c:166:24: warning: variable ?session? set but not used [-Wunused-but-set-variable]
> 
> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Hannes Reinecke <hare@suse.com>
> Cc: Lee Duncan <lduncan@suse.com>
> Cc: Johannes Thumshirn <jthumshirn@suse.de>
> ---
>  drivers/scsi/iscsi_tcp.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
> index 4842fc0e809d..4d934d6c3e13 100644
> --- a/drivers/scsi/iscsi_tcp.c
> +++ b/drivers/scsi/iscsi_tcp.c
> @@ -163,7 +163,6 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
>  	struct iscsi_tcp_conn *tcp_conn;
>  	struct iscsi_sw_tcp_conn *tcp_sw_conn;
>  	struct iscsi_conn *conn;
> -	struct iscsi_session *session;
>  	void (*old_state_change)(struct sock *);
>  
>  	read_lock_bh(&sk->sk_callback_lock);
> @@ -172,7 +171,6 @@ static void iscsi_sw_tcp_state_change(struct sock *sk)
>  		read_unlock_bh(&sk->sk_callback_lock);
>  		return;
>  	}
> -	session = conn->session;
>  
>  	iscsi_sw_sk_state_check(sk);
>  
> 

Reviewed-by: Lee Duncan <lduncan@suse.com>
-- 
Lee Duncan

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2017-09-14 20:56 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 20:46 [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 01/17] Remove an obsolete function declaration Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 02/17] Avoid sign extension of scsi_device.type Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 03/17] Suppress gcc 7 fall-through warnings reported with W=1 Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 04/17] Convert a strncmp() call into a strcmp() call Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 05/17] Document which queue type a function is intended for Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 06/17] Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 07/17] sd, sr: Convert two assignments into warning statements Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 08/17] sd: Fix indentation Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 09/17] sd: Remove a useless comparison Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 10/17] sg: Fix type of last blk_trace_setup() argument Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 11/17] libiscsi: Fix indentation Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 12/17] libsas: Remove a set-but-not-used variable Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 13/17] libsas: Annotate fall-through in a switch statement Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 14/17] scsi_transport_sas, sas_tlr_supported(): Check kzalloc() return value Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 15/17] scsi_transport_srp: Suppress a W=1 compiler warning Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 16/17] scsi_debug: Remove a set-but-not-used variable Bart Van Assche
2017-08-25 20:46 ` [PATCH v2 17/17] iscsi_tcp: " Bart Van Assche
2017-09-14 20:56   ` Lee Duncan
2017-08-25 21:09 ` [PATCH v2 00/17] A series of small SCSI patches for kernel v4.14 Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.