A series of small SCSI patches for kernel v4.14
Subsystems (4)
v2 cover A series of small SCSI patches for kernel v4.14
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(-)
Signature · 1 line
2.14.1
PATCH v2 1/17 Remove an obsolete function declaration
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.
--- include/scsi/scsi_cmnd.h | 1 - 1 file changed, 1 deletion(-)
include/scsi/scsi_cmnd.h +0 -1
@@ -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);
Signature · 1 line
2.14.1
PATCH v2 8/17 sd: Fix indentation
In reply to Bart Van AsscheThis patch avoids that smatch reports the following:
drivers/scsi/sd.c:3540: sd_suspend_common() warn: inconsistent indenting
--- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd.c +1 -1
@@ -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 ; } }
Signature · 1 line
2.14.1
PATCH v2 3/17 Suppress gcc 7 fall-through warnings reported with W=1
In reply to Bart Van AsscheThe 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/[email protected]/msg115428.html).
References: commit bd664f6b3e37 ("disable new gcc-7.1.1 warnings for now")
--- drivers/scsi/scsi_error.c | 8 +++++++- drivers/scsi/scsi_ioctl.c | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-)
drivers/scsi/scsi_error.c +7 -1
@@ -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 ; elseset_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 ; }
drivers/scsi/scsi_ioctl.c +3 -1
@@ -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);
Signature · 1 line
2.14.1
PATCH v2 2/17 Avoid sign extension of scsi_device.type
In reply to Bart Van AsscheThis 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'
--- include/scsi/scsi_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/scsi/scsi_device.h +1 -1
@@ -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;
Signature · 1 line
2.14.1
PATCH v2 4/17 Convert a strncmp() call into a strcmp() call
In reply to Bart Van AsscheThis patch avoids that smatch reports the following warning:
drivers/scsi/scsi_sysfs.c:117: check_set() error: strncmp() '"-"' too small (2 vs 20)
--- drivers/scsi/scsi_sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_sysfs.c +1 -1
@@ -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 {/*
Signature · 1 line
2.14.1
PATCH v2 6/17 Use blk_mq_rq_to_pdu() to convert a request to a SCSI command pointer
In reply to Bart Van AsscheSince 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.
--- 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(-)
drivers/scsi/scsi_error.c +1 -1
@@ -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;
drivers/scsi/scsi_lib.c +9 -9
@@ -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 " "[email protected]\n",
include/scsi/scsi_tcq.h +1 -1
@@ -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 */
Signature · 1 line
2.14.1
PATCH v2 11/17 libiscsi: Fix indentation
In reply to Bart Van AsscheThis patch avoids that smatch reports the following:
drivers/scsi/libiscsi.c:1081: iscsi_handle_reject() warn: inconsistent indenting
--- drivers/scsi/libiscsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/libiscsi.c +1 -1
@@ -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.
Signature · 1 line
2.14.1
PATCH v2 5/17 Document which queue type a function is intended for
In reply to Bart Van AsscheRename several functions to make it easy to see which queue type a function is intended for.
--- 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(-)
drivers/scsi/scsi_lib.c +12 -11
@@ -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, };
drivers/scsi/scsi_priv.h +1 -1
@@ -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);
drivers/scsi/scsi_scan.c +1 -1
@@ -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 */
Signature · 1 line
2.14.1
PATCH v2 7/17 sd, sr: Convert two assignments into warning statements
In reply to Bart Van AsscheBefore 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.
--- drivers/scsi/sd.c | 2 +- drivers/scsi/sr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/sd.c +1 -1
@@ -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 */
drivers/scsi/sr.c +1 -1
@@ -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
Signature · 1 line
2.14.1
PATCH v2 9/17 sd: Remove a useless comparison
In reply to Bart Van AsscheThis 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)
--- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sd.c +1 -1
@@ -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;
Signature · 1 line
2.14.1
PATCH v2 13/17 libsas: Annotate fall-through in a switch statement
In reply to Bart Van Assche--- drivers/scsi/libsas/sas_ata.c | 1 + 1 file changed, 1 insertion(+)
drivers/scsi/libsas/sas_ata.c +1 -0
@@ -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 ; }
Signature · 1 line
2.14.1
PATCH v2 17/17 iscsi_tcp: Remove a set-but-not-used variable
In reply to Bart Van AsscheThis 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]
--- drivers/scsi/iscsi_tcp.c | 2 -- 1 file changed, 2 deletions(-)
drivers/scsi/iscsi_tcp.c +0 -2
@@ -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);
Signature · 1 line
2.14.1
PATCH v2 15/17 scsi_transport_srp: Suppress a W=1 compiler warning
In reply to Bart Van AsscheAvoid 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]
--- drivers/scsi/scsi_transport_srp.c | 2 +- include/scsi/scsi_transport_srp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_transport_srp.c +1 -1
@@ -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 ;
include/scsi/scsi_transport_srp.h +1 -1
@@ -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);
Signature · 1 line
2.14.1
PATCH v2 10/17 sg: Fix type of last blk_trace_setup() argument
In reply to Bart Van AsscheAvoid 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>*argdrivers/scsi/sg.c:1114:41: got char *<noident>
This patch does not change any functionality.
--- drivers/scsi/sg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/sg.c +1 -2
@@ -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 :
Signature · 1 line
2.14.1
PATCH v2 12/17 libsas: Remove a set-but-not-used variable
In reply to Bart Van AsscheThis was detected by building with W=1.
--- drivers/scsi/libsas/sas_scsi_host.c | 3 --- 1 file changed, 3 deletions(-)
drivers/scsi/libsas/sas_scsi_host.c +0 -3
@@ -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) {
Signature · 1 line
2.14.1
PATCH v2 14/17 scsi_transport_sas, sas_tlr_supported(): Check kzalloc() return value
In reply to Bart Van AsscheCheck whether memory allocation succeeded before dereferencing the pointer to the allocated memory.
--- drivers/scsi/scsi_transport_sas.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/scsi/scsi_transport_sas.c +3 -0
@@ -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;
Signature · 1 line
2.14.1
PATCH v2 16/17 scsi_debug: Remove a set-but-not-used variable
In reply to Bart Van AsscheThis 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]
--- drivers/scsi/scsi_debug.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/scsi_debug.c +1 -2
@@ -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 );
Signature · 1 line
2.14.1
Martin K. Petersen
AppliedBart,
Quoted 9 lines
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 usingblk_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!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH v2 17/17] iscsi_tcp: Remove a set-but-not-used variable
In reply to Bart Van AsscheQuoted 28 lines · Bart Van Assche
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 <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>Reviewed-by Hannes Reinecke <[email protected]>Cc Lee Duncan <[email protected]>Cc Johannes Thumshirn <[email protected]>--- drivers/scsi/iscsi_tcp.c | 2 -- 1 file changed, 2 deletions(-)drivers/scsi/iscsi_tcp.c +0
-1@@ -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);
drivers/scsi/iscsi_tcp.c static void iscsi_sw_tcp_state_change(struct sock *sk) · line 176
Quoted 7 lines
drivers/scsi/iscsi_tcp.c +0
-1@@ -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);
Signature · 1 line
Lee Duncan