Skip to contentSkip to conversation

target/iscsi: fix possible condition with no effect (if == else)

PATCH In review Hariprasad Kelam 2 participants 2 messages May 25, 2019 – May 27, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/iscsi: fix possible condition with no effect (if == else)

fix below warning reported by coccicheck

drivers/target/iscsi/iscsi_target_nego.c:175:6-8: WARNING: possible condition with no effect (if == else)

---
 drivers/target/iscsi/iscsi_target_nego.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/target/iscsi/iscsi_target_nego.c +1 -6
index 8a5e8d1..b6fb70a 100644
@@ -168,12 +168,7 @@ static u32 iscsi_handle_authentication(
 	else if (strstr("CHAP", authtype))
 		return chap_main_loop(conn, auth, in_buf, out_buf,
 				&in_length, out_length);
-	else if (strstr("SPKM1", authtype))
-		return 2;
-	else if (strstr("SPKM2", authtype))
-		return 2;
-	else if (strstr("KRB5", authtype))
-		return 2;
+	/* ret 2 in  SPKM1,SPKM2,KRB5 cases */
 	else
 		return 2;
 }
Signature · 1 line
2.7.4
#1 lore raw
Quoted 18 lines · Hariprasad Kelam

fix below warning reported by coccicheck

drivers/target/iscsi/iscsi_target_nego.c:175:6-8: WARNING: possible condition with no effect (if = else)

---
 drivers/target/iscsi/iscsi_target_nego.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/target/iscsi/iscsi_target_nego.c +0 -0
index 8a5e8d1..b6fb70a 100644
@@ -168,12 +168,7 @@ static u32 iscsi_handle_authentication(
 	else if (strstr("CHAP", authtype))
 		return chap_main_loop(conn, auth, in_buf, out_buf,
 				&in_length, out_length);

drivers/target/iscsi/iscsi_target_nego.c static u32 iscsi_handle_authentication( · line 174

Quoted 10 lines
drivers/target/iscsi/iscsi_target_nego.c +1 -6
-	else if (strstr("SPKM1", authtype))
-		return 2;
-	else if (strstr("SPKM2", authtype))
-		return 2;
-	else if (strstr("KRB5", authtype))
-		return 2;
+	/* ret 2 in  SPKM1,SPKM2,KRB5 cases */
 	else
 		return 2;
 }

Looks okay, though I'd prefer to drop the unnecessary "else" too. The CANSRP hunk can also be removed here. I.e. something like:

drivers/target/iscsi/iscsi_target_nego.c +2 -13
@@ -160,22 +160,11 @@ static u32 iscsi_handle_authentication(
 
        if (strstr("None", authtype))
                return 1;
-#ifdef CANSRP
-       else if (strstr("SRP", authtype))
-               return srp_main_loop(conn, auth, in_buf, out_buf,
-                               &in_length, out_length);
-#endif
        else if (strstr("CHAP", authtype))
                return chap_main_loop(conn, auth, in_buf, out_buf,
                                &in_length, out_length);
-       else if (strstr("SPKM1", authtype))
-               return 2;
-       else if (strstr("SPKM2", authtype))
-               return 2;
-       else if (strstr("KRB5", authtype))
-               return 2;
-       else
-               return 2;
+       /* SRP, SPKM1, SPKM2 and KRB5 are unsupported */
+       return 2;
 }
 

Cheers, David