Skip to contentSkip to conversation

cifs: revert needless change in decode_negTokenInit

PATCH In review Jeff Layton 3 participants 3 messages Aug 30, 2010 1 message not in the archive

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

PATCH 1/1 cifs: revert needless change in decode_negTokenInit

9fbc590860e75785bdaf8b83e48fabfe4d4f7d58 needlessly changed some "else if" statements in decode_negTokenInit to "if's". Not only was the change not needed, but it's less efficient than the existing code.

When compare_oid returns true, then it's guaranteed to return false in the other cases. Therefore, there's no reason to keep comparing it.

Cc Shirish Pargaonkar <[email protected]>
---
 fs/cifs/asn1.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
fs/cifs/asn1.c +3 -3
index 21f0fbd..cfd1ce3 100644
@@ -597,13 +597,13 @@ decode_negTokenInit(unsigned char *security_blob, int length,
 				if (compare_oid(oid, oidlen, MSKRB5_OID,
 						MSKRB5_OID_LEN))
 					server->sec_mskerberos = true;
-				if (compare_oid(oid, oidlen, KRB5U2U_OID,
+				else if (compare_oid(oid, oidlen, KRB5U2U_OID,
 						     KRB5U2U_OID_LEN))
 					server->sec_kerberosu2u = true;
-				if (compare_oid(oid, oidlen, KRB5_OID,
+				else if (compare_oid(oid, oidlen, KRB5_OID,
 						     KRB5_OID_LEN))
 					server->sec_kerberos = true;
-				if (compare_oid(oid, oidlen, NTLMSSP_OID,
+				else if (compare_oid(oid, oidlen, NTLMSSP_OID,
 						     NTLMSSP_OID_LEN))
 					server->sec_ntlmssp = true;
 
Signature · 1 line
1.7.2.2

A message that is not in the archive (sent off-list or not yet received): 1283173524-31920-1-git-send-email-jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org

#2 lore raw
Quoted 37 lines · Jeff Layton

9fbc590860e75785bdaf8b83e48fabfe4d4f7d58 needlessly changed some "else if" statements in decode_negTokenInit to "if's". Not only was the change not needed, but it's less efficient than the existing code.

When compare_oid returns true, then it's guaranteed to return false in the other cases. Therefore, there's no reason to keep comparing it.

Cc Shirish Pargaonkar <[email protected]>

---
 fs/cifs/asn1.c |    6 +++---

 1 files changed, 3 insertions(+), 3 deletions(-)
fs/cifs/asn1.c +3 -4
index 21f0fbd..cfd1ce3 100644
@@ -597,13 +597,13 @@ decode_negTokenInit(unsigned char *security_blob, int length,
                                if (compare_oid(oid, oidlen, MSKRB5_OID,
                                                MSKRB5_OID_LEN))
                                        server->sec_mskerberos = true;
-                               if (compare_oid(oid, oidlen, KRB5U2U_OID,
+                               else if (compare_oid(oid, oidlen, KRB5U2U_OID,
                                                     KRB5U2U_OID_LEN))
                                        server->sec_kerberosu2u = true;
-                               if (compare_oid(oid, oidlen, KRB5_OID,
+                               else if (compare_oid(oid, oidlen, KRB5_OID,
                                                     KRB5_OID_LEN))
                                        server->sec_kerberos = true;
-                               if (compare_oid(oid, oidlen, NTLMSSP_OID,
+                               else if (compare_oid(oid, oidlen, NTLMSSP_OID,
                                                     NTLMSSP_OID_LEN))
                                        server->sec_ntlmssp = true;
 
--

1.7.2.2

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Agree. I misunderstood the code. In function decode_negTokenInit, this comparison
is repeated (while) for every auth mech returned by server that neg prot response.

#3 lore raw
In reply to a message not in the archive

merged

Quoted 42 lines · Jeff Layton

9fbc590860e75785bdaf8b83e48fabfe4d4f7d58 needlessly changed some "else if" statements in decode_negTokenInit to "if's". Not only was the change not needed, but it's less efficient than the existing code.

When compare_oid returns true, then it's guaranteed to return false in the other cases. Therefore, there's no reason to keep comparing it.

Cc Shirish Pargaonkar <[email protected]>

---
 fs/cifs/asn1.c |    6 +++---

 1 files changed, 3 insertions(+), 3 deletions(-)
fs/cifs/asn1.c +3 -4
index 21f0fbd..cfd1ce3 100644
@@ -597,13 +597,13 @@ decode_negTokenInit(unsigned char *security_blob, int length,
                                if (compare_oid(oid, oidlen, MSKRB5_OID,
                                                MSKRB5_OID_LEN))
                                        server->sec_mskerberos = true;
-                               if (compare_oid(oid, oidlen, KRB5U2U_OID,
+                               else if (compare_oid(oid, oidlen, KRB5U2U_OID,
                                                     KRB5U2U_OID_LEN))
                                        server->sec_kerberosu2u = true;
-                               if (compare_oid(oid, oidlen, KRB5_OID,
+                               else if (compare_oid(oid, oidlen, KRB5_OID,
                                                     KRB5_OID_LEN))
                                        server->sec_kerberos = true;
-                               if (compare_oid(oid, oidlen, NTLMSSP_OID,
+                               else if (compare_oid(oid, oidlen, NTLMSSP_OID,
                                                     NTLMSSP_OID_LEN))
                                        server->sec_ntlmssp = true;
 
--

1.7.2.2

--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in the body of a message to [email protected] More majordomo info at  http://vger.kernel.org/majordomo-info.html

Signature · 3 lines
Thanks,

Steve