[stgt] [PATCH] spc.c: fix compiler warnings

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Mon Apr 2 21:17:37 CEST 2012


On Sun, 01 Apr 2012 21:12:58 +0200
Arne Redlich <arne.redlich at googlemail.com> wrote:

> gcc-4.6 points out a number of variables that are set but never
> used - remove them.
> 
> Signed-off-by: Arne Redlich <arne.redlich at googlemail.com>
> ---
>  usr/spc.c |   31 +++++--------------------------
>  1 files changed, 5 insertions(+), 26 deletions(-)
> 
> diff --git a/usr/spc.c b/usr/spc.c
> index 44cd193..93aa062 100644
> --- a/usr/spc.c
> +++ b/usr/spc.c
> @@ -262,7 +262,7 @@ int spc_report_luns(int host_no, struct scsi_cmd *cmd)
>  	struct scsi_lu *lu;
>  	struct list_head *dev_list = &cmd->c_target->device_list;
>  	uint64_t lun, *data;
> -	int idx, alen, oalen, nr_luns;
> +	int idx, alen, nr_luns;
>  	unsigned char key = ILLEGAL_REQUEST;
>  	uint16_t asc = ASC_INVALID_FIELD_IN_CDB;
>  	uint8_t *scb = cmd->scb;
> @@ -279,8 +279,6 @@ int spc_report_luns(int host_no, struct scsi_cmd *cmd)
>  	memset(data, 0, alen);
>  
>  	alen &= ~(8 - 1);
> -	oalen = alen;
> -
>  	alen -= 8;
>  	idx = 1;
>  	nr_luns = 0;
> @@ -720,7 +718,6 @@ static int report_opcodes_all(struct scsi_cmd *cmd, int rctd,
>  int spc_report_supported_opcodes(int host_no, struct scsi_cmd *cmd)
>  {
>  	uint8_t reporting_options;
> -	uint8_t requested_opcode;
>  	uint16_t requested_service_action;
>  	uint32_t alloc_len;
>  	int rctd;
> @@ -728,8 +725,6 @@ int spc_report_supported_opcodes(int host_no, struct scsi_cmd *cmd)
>  
>  	reporting_options = cmd->scb[2] & 0x07;
>  
> -	requested_opcode = cmd->scb[3];
> -
>  	requested_service_action = cmd->scb[4];
>  	requested_service_action <<= 8;
>  	requested_service_action |= cmd->scb[5];
> @@ -1097,23 +1092,15 @@ static int spc_pr_reserve(int host_no, struct scsi_cmd *cmd)
>  	uint16_t asc = ASC_INVALID_FIELD_IN_CDB;
>  	uint8_t key = ILLEGAL_REQUEST;
>  	uint8_t pr_scope, pr_type;
> -	uint8_t *buf;
> -	uint64_t res_key, sa_res_key;
> -	int ret;
>  	struct registration *reg, *holder;
> +	int ret = check_pr_out_basic_parameter(cmd);

Is this necessary? I prefer to declaring a valuable and initialization
by a function separately.


> -	ret = check_pr_out_basic_parameter(cmd);
>  	if (ret)
>  		goto sense;
>  
>  	pr_scope = (cmd->scb[2] & 0xf0) >> 4;
>  	pr_type = cmd->scb[2] & 0x0f;
>  
> -	buf = scsi_get_out_buffer(cmd);
> -
> -	res_key = get_unaligned_be64(buf);
> -	sa_res_key = get_unaligned_be64(buf + 8);
> -
>  	switch (pr_type) {
>  	case PR_TYPE_WRITE_EXCLUSIVE:
>  	case PR_TYPE_EXCLUSIVE_ACCESS:
> @@ -1162,7 +1149,7 @@ static int spc_pr_release(int host_no, struct scsi_cmd *cmd)
>  	uint8_t key = ILLEGAL_REQUEST;
>  	uint8_t pr_scope, pr_type;
>  	uint8_t *buf;
> -	uint64_t res_key, sa_res_key;
> +	uint64_t res_key;
>  	int ret;
>  	struct registration *reg, *holder, *sibling;
>  
> @@ -1176,7 +1163,6 @@ static int spc_pr_release(int host_no, struct scsi_cmd *cmd)
>  	buf = scsi_get_out_buffer(cmd);
>  
>  	res_key = get_unaligned_be64(buf);
> -	sa_res_key = get_unaligned_be64(buf + 8);
>  
>  	reg = lookup_registration_by_nexus(cmd->dev, cmd->it_nexus);
>  	if (!reg)
> @@ -1233,7 +1219,7 @@ static int spc_pr_clear(int host_no, struct scsi_cmd *cmd)
>  	uint16_t asc = ASC_INVALID_FIELD_IN_CDB;
>  	uint8_t key = ILLEGAL_REQUEST;
>  	uint8_t *buf;
> -	uint64_t res_key, sa_res_key;
> +	uint64_t res_key;
>  	int ret;
>  	struct registration *reg, *holder, *sibling, *n;
>  
> @@ -1244,7 +1230,6 @@ static int spc_pr_clear(int host_no, struct scsi_cmd *cmd)
>  	buf = scsi_get_out_buffer(cmd);
>  
>  	res_key = get_unaligned_be64(buf);
> -	sa_res_key = get_unaligned_be64(buf + 8);
>  
>  	reg = lookup_registration_by_nexus(cmd->dev, cmd->it_nexus);
>  	if (!reg)
> @@ -1282,7 +1267,7 @@ static int spc_pr_preempt(int host_no, struct scsi_cmd *cmd)
>  {
>  	uint16_t asc = ASC_INVALID_FIELD_IN_CDB;
>  	uint8_t key = ILLEGAL_REQUEST;
> -	int ret, abort;
> +	int ret;
>  	int res_released = 0, remove_all_reg = 0;
>  	uint64_t res_key, sa_res_key;
>  	uint8_t pr_scope, pr_type;
> @@ -1293,8 +1278,6 @@ static int spc_pr_preempt(int host_no, struct scsi_cmd *cmd)
>  	if (ret)
>  		goto sense;
>  
> -	abort = ((cmd->scb[1] & 0x1f) == PR_OUT_PREEMPT_AND_ABORT);
> -
>  	pr_scope = (cmd->scb[2] & 0xf0) >> 4;
>  	pr_type = cmd->scb[2] & 0x0f;
>  
> @@ -1375,7 +1358,6 @@ static int spc_pr_register_and_move(int host_no, struct scsi_cmd *cmd)
>  	uint16_t asc = ASC_INVALID_FIELD_IN_CDB;
>  	uint8_t key = ILLEGAL_REQUEST;
>  	char *buf;
> -	uint8_t pr_scope, pr_type;
>  	uint8_t unreg;
>  	uint64_t res_key, sa_res_key;
>  	uint32_t addlen, idlen;
> @@ -1384,9 +1366,6 @@ static int spc_pr_register_and_move(int host_no, struct scsi_cmd *cmd)
>  	int (*id)(int, uint64_t, char *, int);
>  	char tpid[300]; /* large enough? */
>  
> -	pr_scope = (cmd->scb[2] & 0xf0) >> 4;
> -	pr_type = cmd->scb[2] & 0x0f;
> -
>  	if (get_unaligned_be16(cmd->scb + 7) < len)
>  		goto sense;
>  
> -- 
> 1.7.9.1
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe stgt" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list