From c1d798a788e6275d942cc2f80e0d075befa059d6 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 1 Jun 2017 03:46:06 +0000 Subject: [PATCH 1/5] scst: cleanup of dead code Reported-By: David Butterfield git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7198 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_pres.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scst/src/scst_pres.c b/scst/src/scst_pres.c index ce6c5126f..02f4d68ff 100644 --- a/scst/src/scst_pres.c +++ b/scst/src/scst_pres.c @@ -2569,7 +2569,7 @@ out_unlock: /* Called with dev_pr_mutex locked, no IRQ */ void scst_pr_read_keys(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) { - int i, offset = 0, size, size_max; + int offset = 0, size, size_max; struct scst_device *dev = cmd->dev; struct scst_dev_registrant *reg; @@ -2592,7 +2592,6 @@ void scst_pr_read_keys(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) size = 0; size_max = buffer_size - 8; - i = 0; list_for_each_entry(reg, &dev->dev_registrants_list, dev_registrants_list_entry) { if (size_max - size >= 8) { @@ -2602,7 +2601,7 @@ void scst_pr_read_keys(struct scst_cmd *cmd, uint8_t *buffer, int buffer_size) WARN_ON(reg->key == 0); put_unaligned(reg->key, - (__be64 *)&buffer[offset + 8 * i]); + (__be64 *)&buffer[offset]); offset += 8; } From c4e9bab97c6072058c2ffeb4fcd7ea2126866bbb Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 1 Jun 2017 03:49:26 +0000 Subject: [PATCH 2/5] scst: scst_free_acg() not dereference NULL acg->tgt for proc interface Signed-off-by: David Butterfield git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7199 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 64424306f..9393364b9 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -4728,7 +4728,8 @@ static void scst_free_acg(struct scst_acg *acg) struct scst_acn *acn, *acnt; struct scst_tgt *tgt = acg->tgt; - TRACE_DBG("Freeing acg %s/%s", tgt->tgt_name, acg->acg_name); + /* For procfs acg->tgt could be NULL */ + TRACE_DBG("Freeing acg %s/%s", tgt ? tgt->tgt_name : "(tgt=NULL)", acg->acg_name); list_for_each_entry_safe(acg_dev, acg_dev_tmp, &acg->acg_dev_list, acg_dev_list_entry) { From 41a287734fbcc516cb8d3643486a3364f04c8920 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 1 Jun 2017 03:53:08 +0000 Subject: [PATCH 3/5] iscsi-scst: fix a couple of bad-function-cast warnings This is a "marginal" warning, but there are only six of them in the SCST code and this fixes two of those. session.c:105:4: warning: cast from function call of type void * to non-matching type _Bool [-Wbad-function-cast] target.c:668:14: warning: cast from function call of type void * to non-matching type _Bool [-Wbad-function-cast] Signed-off-by: David Butterfield git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7200 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/session.c | 2 +- iscsi-scst/kernel/target.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/iscsi-scst/kernel/session.c b/iscsi-scst/kernel/session.c index dd80debbe..20990cfca 100644 --- a/iscsi-scst/kernel/session.c +++ b/iscsi-scst/kernel/session.c @@ -102,7 +102,7 @@ static int iscsi_session_alloc(struct iscsi_target *target, if (!session->sess_params.rdma_extensions) { err = iscsi_threads_pool_get( - (bool)scst_get_acg_tgt_priv(session->scst_sess->acg), + scst_get_acg_tgt_priv(session->scst_sess->acg) != NULL, &session->scst_sess->acg->acg_cpu_mask, &session->sess_thr_pool); if (err != 0) diff --git a/iscsi-scst/kernel/target.c b/iscsi-scst/kernel/target.c index 3abe23f21..3b563139f 100644 --- a/iscsi-scst/kernel/target.c +++ b/iscsi-scst/kernel/target.c @@ -665,7 +665,7 @@ static ssize_t iscsi_acg_sess_dedicated_threads_show(struct kobject *kobj, TRACE_ENTRY(); acg = container_of(kobj, struct scst_acg, acg_kobj); - dedicated = (bool)scst_get_acg_tgt_priv(acg); + dedicated = scst_get_acg_tgt_priv(acg) != NULL; pos = sprintf(buf, "%d\n%s", dedicated, dedicated ? SCST_SYSFS_KEY_MARK "\n" : ""); From 5358fb06f823181930f15587ba124b6cca0436d8 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 1 Jun 2017 04:04:45 +0000 Subject: [PATCH 4/5] scst: remove a few unnecessary shadow declarations Remove a few "shadow" declarations that appear unnecessary and probably unintended. (These are cases where a declaration in an inner scope hides another declaration of the same name in an outer scope.) Not all shadow declarations are superfluous -- so this particular compiler warning is one that cannot be simply heeded while half asleep. But these particular ones I removed appear to be superfluous. Signed-off-by: David Butterfield git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7201 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- scst/src/scst_lib.c | 4 ---- scst/src/scst_targ.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 9393364b9..08c09684d 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6129,8 +6129,6 @@ static void scst_ws_write_cmd_finished(struct scst_cmd *cmd) wsp->ws_cur_in_flight--; if (cmd->status != 0) { - int rc; - TRACE_DBG("Write cmd %p (ws cmd %p) finished not successfully", cmd, ws_cmd); sBUG_ON(cmd->resp_data_len != 0); @@ -6560,8 +6558,6 @@ static void scst_cwr_read_cmd_finished(struct scst_cmd *cmd) TRACE_DBG("READ cmd %p finished (cwr cmd %p)", cmd, cwr_cmd); if (cmd->status != 0) { - int rc; - TRACE_DBG("Read cmd %p (cwr cmd %p) finished not successfully", cmd, cwr_cmd); sBUG_ON(cmd->resp_data_len != 0); diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index b6d53b6cd..344a71bc0 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -4141,7 +4141,7 @@ next: if (likely(scst_cmd_completed_good(cmd))) { if (cmd->deferred_dif_read_check) { - int rc = scst_dif_process_read(cmd); + rc = scst_dif_process_read(cmd); if (unlikely(rc != 0)) { cmd->deferred_dif_read_check = 0; @@ -7441,7 +7441,6 @@ static int scst_mgmt_affected_cmds_done(struct scst_mgmt_cmd *mcmd) list_for_each_entry(s, &tgt->sess_list, sess_list_entry) { for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) { struct list_head *head = &s->sess_tgt_dev_list[i]; - struct scst_tgt_dev *tgt_dev; list_for_each_entry(tgt_dev, head, sess_tgt_dev_list_entry) { From a614104023ca54a36ebff8e1a68f39e88bef9266 Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Thu, 1 Jun 2017 04:08:02 +0000 Subject: [PATCH 5/5] usr: fix -Wmissing-prototypes warnings Fix all twelve [-Wmissing-prototypes] warnings by adding "static" to their declarations. Signed-off-by: David Butterfield git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7202 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- usr/fileio/common.c | 8 ++++---- usr/fileio/fileio.c | 8 ++++---- usr/stpgd/stpgd_main.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/usr/fileio/common.c b/usr/fileio/common.c index 2591cd7b3..ed112222c 100644 --- a/usr/fileio/common.c +++ b/usr/fileio/common.c @@ -120,7 +120,7 @@ static int set_sense(uint8_t *buffer, int len, int key, int asc, int ascq) * scst_set_invalid_field_in_parm_list() */ -void set_cmd_error(struct vdisk_cmd *vcmd, int key, int asc, int ascq) +static void set_cmd_error(struct vdisk_cmd *vcmd, int key, int asc, int ascq) { struct scst_user_scsi_cmd_reply_exec *reply = &vcmd->reply->exec_reply; @@ -137,7 +137,7 @@ void set_cmd_error(struct vdisk_cmd *vcmd, int key, int asc, int ascq) return; } -void set_busy(struct vdisk_cmd *vcmd) +static void set_busy(struct vdisk_cmd *vcmd) { TRACE_ENTRY(); @@ -189,7 +189,7 @@ out: return res; } -struct vdisk_tgt_dev *find_tgt_dev(struct vdisk_dev *dev, uint64_t sess_h) +static struct vdisk_tgt_dev *find_tgt_dev(struct vdisk_dev *dev, uint64_t sess_h) { unsigned int i; struct vdisk_tgt_dev *res = NULL; @@ -203,7 +203,7 @@ struct vdisk_tgt_dev *find_tgt_dev(struct vdisk_dev *dev, uint64_t sess_h) return res; } -struct vdisk_tgt_dev *find_empty_tgt_dev(struct vdisk_dev *dev) +static struct vdisk_tgt_dev *find_empty_tgt_dev(struct vdisk_dev *dev) { unsigned int i; struct vdisk_tgt_dev *res = NULL; diff --git a/usr/fileio/fileio.c b/usr/fileio/fileio.c index 2c51ab6f9..bd97594fa 100644 --- a/usr/fileio/fileio.c +++ b/usr/fileio/fileio.c @@ -203,7 +203,7 @@ static void *align_alloc(size_t size) return memalign(PAGE_SIZE, size); } -void sigalrm_handler(int signo) +static void sigalrm_handler(int signo) { int res, i; @@ -234,7 +234,7 @@ out: return; } -void sigusr1_handler(int signo) +static void sigusr1_handler(int signo) { int res, i; @@ -258,7 +258,7 @@ out: return; } -int prealloc_buffers(struct vdisk_dev *dev) +static int prealloc_buffers(struct vdisk_dev *dev) { int i, c, res = 0; @@ -300,7 +300,7 @@ out: return res; } -int start(int argc, char **argv) +static int start(int argc, char **argv) { int res = 0; int fd; diff --git a/usr/stpgd/stpgd_main.c b/usr/stpgd/stpgd_main.c index be0796248..a99b87b20 100644 --- a/usr/stpgd/stpgd_main.c +++ b/usr/stpgd/stpgd_main.c @@ -94,7 +94,7 @@ static void stpg_handle_tm_received(struct scst_event_user *event_user) */ } -int invoke_stpg(const uint8_t *device_name, +static int invoke_stpg(const uint8_t *device_name, const struct scst_event_stpg_descr *descr, pid_t *out_pid) { char *args[7], *env[7]; @@ -175,7 +175,7 @@ out: } /* Returns 0, if the pid is still running, >0 if it was exited or <0 error code */ -int wait_until_finished(pid_t pid, unsigned long deadline, int *status, int child) +static int wait_until_finished(pid_t pid, unsigned long deadline, int *status, int child) { int res; time_t start, end; @@ -204,7 +204,7 @@ int wait_until_finished(pid_t pid, unsigned long deadline, int *status, int chil return res; } -int handle_stpg_received(struct scst_event_user *event_user) +static int handle_stpg_received(struct scst_event_user *event_user) { const struct scst_event_stpg_payload *p = (struct scst_event_stpg_payload *)event_user->out_event.payload; int num, k; @@ -426,7 +426,7 @@ out: return res; } -void sig_chld(int signal) +static void sig_chld(int signal) { /* Check just in case */ if (signal == SIGCHLD) {