Commit 4053a4be authored by Dan Carpenter's avatar Dan Carpenter Committed by James Bottomley

[SCSI] be2iscsi: cleanup a min_t() call

"sense_len" was declared as int type but actually it only stores a
u16 value that comes from hardware.  The cast to u16 in min_t()
confuses static analysis because it truncates the int to u16 so I've
fixed the declaration to reflect that "sense_len" is just a u16.

Also there was a call to cpu_to_be16() which I've changed to
be16_to_cpu().  The functions are equivalent, but obviously the
hardware is big endian and we're doing the min_t() comparison on CPU
endian values.

This whole patch is just a cleanup and doesn't affect how the code
works.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Acked-by: default avatarJayamohan Kallickal <Jayamohan.kallickal@emulex.com>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 7af0abbc
...@@ -1105,7 +1105,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn, ...@@ -1105,7 +1105,6 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
struct be_status_bhs *sts_bhs = struct be_status_bhs *sts_bhs =
(struct be_status_bhs *)io_task->cmd_bhs; (struct be_status_bhs *)io_task->cmd_bhs;
struct iscsi_conn *conn = beiscsi_conn->conn; struct iscsi_conn *conn = beiscsi_conn->conn;
unsigned int sense_len;
unsigned char *sense; unsigned char *sense;
u32 resid = 0, exp_cmdsn, max_cmdsn; u32 resid = 0, exp_cmdsn, max_cmdsn;
u8 rsp, status, flags; u8 rsp, status, flags;
...@@ -1153,9 +1152,11 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn, ...@@ -1153,9 +1152,11 @@ be_complete_io(struct beiscsi_conn *beiscsi_conn,
} }
if (status == SAM_STAT_CHECK_CONDITION) { if (status == SAM_STAT_CHECK_CONDITION) {
u16 sense_len;
unsigned short *slen = (unsigned short *)sts_bhs->sense_info; unsigned short *slen = (unsigned short *)sts_bhs->sense_info;
sense = sts_bhs->sense_info + sizeof(unsigned short); sense = sts_bhs->sense_info + sizeof(unsigned short);
sense_len = cpu_to_be16(*slen); sense_len = be16_to_cpu(*slen);
memcpy(task->sc->sense_buffer, sense, memcpy(task->sc->sense_buffer, sense,
min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE)); min_t(u16, sense_len, SCSI_SENSE_BUFFERSIZE));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment