Skip to contentSkip to conversation

scsi: sli4: Remove code duplication

PATCH Superseded [email protected] 3 participants 3 messages Aug 16, 2023 – Aug 17, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: sli4: Remove code duplication

From: Rajeshwar R Shinde <[email protected]>

In the function sli_xmit_bls_rsp64_wqe, the 'if' and 'else' conditions evaluates the same expression and gives same output. So removing the redundant code duplication to optimise the code.

This fixes warning such as:
drivers/scsi/elx/libefc_sli/sli4.c:2320:2-4: WARNING: possible condition with no effect (if == else)

---
 drivers/scsi/elx/libefc_sli/sli4.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/elx/libefc_sli/sli4.c +2 -6
index 8f96049f62dd..5e7fb110bc3f 100644
@@ -2317,12 +2317,8 @@ sli_xmit_bls_rsp64_wqe(struct sli4 *sli, void *buf,
 		SLI4_GENERIC_CONTEXT_VPI << SLI4_BLS_RSP_WQE_CT_SHFT;
 		bls->context_tag = cpu_to_le16(params->vpi);
 
-		if (params->s_id != U32_MAX)
-			bls->local_n_port_id_dword |=
-				cpu_to_le32(params->s_id & 0x00ffffff);
-		else
-			bls->local_n_port_id_dword |=
-				cpu_to_le32(params->s_id & 0x00ffffff);
+		bls->local_n_port_id_dword |=
+			cpu_to_le32(params->s_id & 0x00ffffff);
 
 		dw_ridflags = (dw_ridflags & ~SLI4_BLS_RSP_RID) |
 			       (params->d_id & SLI4_BLS_RSP_RID);
Signature · 6 lines
2.25.1

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#1 lore raw

Hi--

Quoted 8 lines · On 8/16/23 01:50, [email protected] wrote:

From: Rajeshwar R Shinde <[email protected]>

In the function sli_xmit_bls_rsp64_wqe, the 'if' and 'else' conditions evaluates the same expression and gives same output. So removing the redundant code duplication to optimise the code.

This fixes warning such as:
drivers/scsi/elx/libefc_sli/sli4.c:2320:2-4: WARNING: possible condition with no effect (if == else)

What tool produces this message?

Quoted 11 lines
---
 drivers/scsi/elx/libefc_sli/sli4.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/scsi/elx/libefc_sli/sli4.c +0 -0
index 8f96049f62dd..5e7fb110bc3f 100644
@@ -2317,12 +2317,8 @@ sli_xmit_bls_rsp64_wqe(struct sli4 *sli, void *buf,
 		SLI4_GENERIC_CONTEXT_VPI << SLI4_BLS_RSP_WQE_CT_SHFT;

drivers/scsi/elx/libefc_sli/sli4.c sli_xmit_bls_rsp64_wqe(struct sli4 *sli, void *buf, · line 2321

Quoted 10 lines
drivers/scsi/elx/libefc_sli/sli4.c +2 -6
 		bls->context_tag = cpu_to_le16(params->vpi);
 
-		if (params->s_id != U32_MAX)
-			bls->local_n_port_id_dword |=
-				cpu_to_le32(params->s_id & 0x00ffffff);
-		else
-			bls->local_n_port_id_dword |=
-				cpu_to_le32(params->s_id & 0x00ffffff);
+		bls->local_n_port_id_dword |=
+			cpu_to_le32(params->s_id & 0x00ffffff);

That could be correct. Or there could be a bug there. Who knows? I don't.

But maybe it doesn't matter since AFAICT that field isn't used anywhere after it is set.

Quoted 3 lines
drivers/scsi/elx/libefc_sli/sli4.c +0 -0
 		dw_ridflags = (dw_ridflags & ~SLI4_BLS_RSP_RID) |
 			       (params->d_id & SLI4_BLS_RSP_RID);
Signature · 5 lines
~Randy
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
#2 lore raw
Quoted 47 lines · Randy Dunlap

Hi--

Quoted 4 lines · On 8/16/23 01:50, [email protected] wrote:

From: Rajeshwar R Shinde <[email protected]>

In the function sli_xmit_bls_rsp64_wqe, the 'if' and 'else' conditions evaluates the same expression and gives same output. So removing the

redundant

Quoted 4 lines

code duplication to optimise the code.

This fixes warning such as:
drivers/scsi/elx/libefc_sli/sli4.c:2320:2-4: WARNING: possible condition

with no effect (if == else)

What tool produces this message?

Review

Quoted 6 lines
---
 drivers/scsi/elx/libefc_sli/sli4.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
(quoted diff) +0 -0

b/drivers/scsi/elx/libefc_sli/sli4.c

drivers/scsi/elx/libefc_sli/sli4.c sli_xmit_bls_rsp64_wqe(struct sli4 *sli, void

Quoted 4 lines

index 8f96049f62dd..5e7fb110bc3f 100644

drivers/scsi/elx/libefc_sli/sli4.c +0 -0
@@ -2317,12 +2317,8 @@ sli_xmit_bls_rsp64_wqe(struct sli4 *sli, void

*buf,

drivers/scsi/elx/libefc_sli/sli4.c sli_xmit_bls_rsp64_wqe(struct sli4 *sli, void *buf, · line 2321

Quoted 11 lines
drivers/scsi/elx/libefc_sli/sli4.c +2 -6
              SLI4_GENERIC_CONTEXT_VPI << SLI4_BLS_RSP_WQE_CT_SHFT;
              bls->context_tag = cpu_to_le16(params->vpi);
 
-             if (params->s_id != U32_MAX)
-                     bls->local_n_port_id_dword |=
-                             cpu_to_le32(params->s_id & 0x00ffffff);
-             else
-                     bls->local_n_port_id_dword |=
-                             cpu_to_le32(params->s_id & 0x00ffffff);
+             bls->local_n_port_id_dword |=
+                     cpu_to_le32(params->s_id & 0x00ffffff);

That could be correct. Or there could be a bug there. Who knows? I don't.

But maybe it doesn't matter since AFAICT that field isn't used anywhere after it is set.

Quoted 1 line
Quoted 6 lines
Quoted 2 lines

dw_ridflags = (dw_ridflags & ~SLI4_BLS_RSP_RID) |
(params->d_id & SLI4_BLS_RSP_RID);

--
~Randy

The expectation here is that the s_id will be valid when the RPI
is not registered.
This value will be used as the S_ID for the BLS reply sequence.

Change looks good.

Signature · 11 lines
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees