diff mbox series

[10/10] cifs: Use switch/case to dissect negprot reply ctxts

Message ID f046f81ff9cb3fbba28e65d15fc14d0c82affca2.1678885349.git.vl@samba.org (mailing list archive)
State New, archived
Headers show
Series Some cleanups for fs/cifs | expand

Commit Message

Volker Lendecke March 15, 2023, 1:05 p.m. UTC
Easier to read than nested if/else statements

Signed-off-by: Volker Lendecke <vl@samba.org>
---
 fs/cifs/smb2pdu.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 0c1dc33aff05..567f2017d143 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -718,23 +718,30 @@  static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp,
 		if (clen > len_of_ctxts)
 			break;
 
-		if (pctx->ContextType == SMB2_PREAUTH_INTEGRITY_CAPABILITIES)
+		switch (pctx->ContextType) {
+		case SMB2_PREAUTH_INTEGRITY_CAPABILITIES:
 			decode_preauth_context(
 				(struct smb2_preauth_neg_context *)pctx);
-		else if (pctx->ContextType == SMB2_ENCRYPTION_CAPABILITIES)
+			break;
+		case SMB2_ENCRYPTION_CAPABILITIES:
 			rc = decode_encrypt_ctx(server,
 				(struct smb2_encryption_neg_context *)pctx);
-		else if (pctx->ContextType == SMB2_COMPRESSION_CAPABILITIES)
+			break;
+		case SMB2_COMPRESSION_CAPABILITIES:
 			decode_compress_ctx(server,
 				(struct smb2_compression_capabilities_context *)pctx);
-		else if (pctx->ContextType == SMB2_POSIX_EXTENSIONS_AVAILABLE)
+			break;
+		case SMB2_POSIX_EXTENSIONS_AVAILABLE:
 			server->posix_ext_supported = true;
-		else if (pctx->ContextType == SMB2_SIGNING_CAPABILITIES)
+			break;
+		case SMB2_SIGNING_CAPABILITIES:
 			decode_signing_ctx(server,
 				(struct smb2_signing_capabilities *)pctx);
-		else
+			break;
+		default:
 			cifs_server_dbg(VFS, "unknown negcontext of type %d ignored\n",
 				le16_to_cpu(pctx->ContextType));
+		}
 
 		if (rc)
 			break;