drivers/target/iscsi/iscsi_target_tmr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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>
---
drivers/target/iscsi/iscsi_target_tmr.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c
index f60b156ede12..620de3910599 100644
--- a/drivers/target/iscsi/iscsi_target_tmr.c
+++ b/drivers/target/iscsi/iscsi_target_tmr.c
@@ -112,7 +112,8 @@ u8 iscsit_tmr_task_reassign(
struct iscsi_tmr_req *tmr_req = cmd->tmr_req;
struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req;
struct iscsi_tm *hdr = (struct iscsi_tm *) buf;
- u64 ret, ref_lun;
+ u64 ref_lun;
+ int ret;
pr_debug("Got TASK_REASSIGN TMR ITT: 0x%08x,"
" RefTaskTag: 0x%08x, ExpDataSN: 0x%08x, CID: %hu\n",
--
2.34.1
On Tue, 02 Sep 2025 20:50:14 +0800, Qianfeng Rong wrote: > 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. > > [...] Applied to 6.18/scsi-queue, thanks! [1/1] scsi: target: iscsi: Use int type to store negative value https://git.kernel.org/mkp/scsi/c/b0aca7ae8285 -- Martin K. Petersen
Qianfeng, > 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(). Applied to 6.18/scsi-staging, thanks! -- Martin K. Petersen
On 9/2/25 7:50 AM, Qianfeng Rong wrote: > 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> > --- > drivers/target/iscsi/iscsi_target_tmr.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/target/iscsi/iscsi_target_tmr.c b/drivers/target/iscsi/iscsi_target_tmr.c > index f60b156ede12..620de3910599 100644 > --- a/drivers/target/iscsi/iscsi_target_tmr.c > +++ b/drivers/target/iscsi/iscsi_target_tmr.c > @@ -112,7 +112,8 @@ u8 iscsit_tmr_task_reassign( > struct iscsi_tmr_req *tmr_req = cmd->tmr_req; > struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; > struct iscsi_tm *hdr = (struct iscsi_tm *) buf; > - u64 ret, ref_lun; > + u64 ref_lun; > + int ret; > > pr_debug("Got TASK_REASSIGN TMR ITT: 0x%08x," > " RefTaskTag: 0x%08x, ExpDataSN: 0x%08x, CID: %hu\n", Reviewed-by: Mike Christie <michael.christie@oracle.com>
© 2016 - 2025 Red Hat, Inc.