scst: scst_finish_cmd() not try to left-shift lba of -1

Change scst_finish_cmd() so that it does not attempt to left-shift lba when it
is -1 (the error value).  Left-shifting of a negative value is undefined in C.

Signed-off-by: David Butterfield <dab21774@gmail.com>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7172 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2017-05-11 03:57:04 +00:00
parent db31c1d56b
commit c0758f4699

View File

@@ -4721,6 +4721,7 @@ static int scst_finish_cmd(struct scst_cmd *cmd)
struct scst_session *sess = cmd->sess;
struct scst_io_stat_entry *stat;
int block_shift, align_len;
uint64_t lba;
TRACE_ENTRY();
@@ -4753,12 +4754,14 @@ static int scst_finish_cmd(struct scst_cmd *cmd)
block_shift = cmd->dev->block_shift;
/* Let's track only 4K unaligned cmds at the moment */
align_len = (block_shift != 0) ? 4095 : 0;
lba = cmd->lba;
} else {
block_shift = 0;
align_len = 0;
lba = 0;
}
if (unlikely(((cmd->lba << block_shift) & align_len) != 0) ||
if (unlikely(((lba << block_shift) & align_len) != 0) ||
unlikely(((cmd->bufflen + cmd->out_bufflen) & align_len) != 0))
stat->unaligned_cmd_count++;