在 2021/12/24 16:43, John Garry 写道:
On 24/12/2021 06:07, chenxiang wrote:
From: Xiang Chen chenxiang66@hisilicon.com
For scsilun, it will be overwrote and not necessary to be set as 0.
overwritten
Signed-off-by: Xiang Chen chenxiang66@hisilicon.com
drivers/scsi/scsi_common.c | 2 -- 1 file changed, 2 deletions(-)
diff --git a/drivers/scsi/scsi_common.c b/drivers/scsi/scsi_common.c index 6e50e81a8216..5e7267b15f49 100644 --- a/drivers/scsi/scsi_common.c +++ b/drivers/scsi/scsi_common.c @@ -115,8 +115,6 @@ void int_to_scsilun(u64 lun, struct scsi_lun *scsilun) { int i;
- memset(scsilun->scsi_lun, 0, sizeof(scsilun->scsi_lun));
for (i = 0; i < sizeof(lun); i += 2) {
What if scsi_lun is not divisible by 2? The last byte would not be zeroed then.
From the comment of the function, the scsi lun is always 8-bytes vlaue, and i don't think it will become the value which is not divisible by 2. I think if the length of scsi lun is not divisible by 2, it should overwritten the value one byte by one byte.
scsilun->scsi_lun[i] = (lun >> 8) & 0xFF; scsilun->scsi_lun[i+1] = lun & 0xFF;
.