Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: target: iscsi: Use int type to store negative value

Change the 'ret' variable in iscsit_tmr_task_reassign() from u64 to int,
as it needs to store either negative value or zero returned by
iscsit_find_cmd_for_recovery().

Storing the negative error codes in unsigned type, or performing equality
comparisons (e.g., ret == -2), doesn't cause an issue at runtime [1] but
can be confusing. Additionally, assigning negative error codes to
unsigned type may trigger a GCC warning when the -Wsign-conversion flag
is enabled.

No effect on runtime.

Link: https://lore.kernel.org/all/x3wogjf6vgpkisdhg3abzrx7v7zktmdnfmqeih5kosszmagqfs@oh3qxrgzkikf/ #1
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Qianfeng Rong and committed by
Martin K. Petersen
b0aca7ae b620462b

+2 -1
+2 -1
drivers/target/iscsi/iscsi_target_tmr.c
··· 112 112 struct iscsi_tmr_req *tmr_req = cmd->tmr_req; 113 113 struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; 114 114 struct iscsi_tm *hdr = (struct iscsi_tm *) buf; 115 - u64 ret, ref_lun; 115 + u64 ref_lun; 116 + int ret; 116 117 117 118 pr_debug("Got TASK_REASSIGN TMR ITT: 0x%08x," 118 119 " RefTaskTag: 0x%08x, ExpDataSN: 0x%08x, CID: %hu\n",