Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Volker Lendecke <vl@samba.org>
To: linux-cifs@vger.kernel.org
Cc: Volker Lendecke <vl@samba.org>
Subject: [PATCH 10/10] cifs: Use switch/case to dissect negprot reply ctxts
Date: Wed, 15 Mar 2023 13:05:31 +0000	[thread overview]
Message-ID: <f046f81ff9cb3fbba28e65d15fc14d0c82affca2.1678885349.git.vl@samba.org> (raw)
In-Reply-To: <cover.1678885349.git.vl@samba.org>

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 --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;
-- 
2.30.2


  parent reply	other threads:[~2023-03-15 13:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15 13:05 [PATCH 00/10] Some cleanups for fs/cifs Volker Lendecke
2023-03-15 13:05 ` [PATCH 01/10] cifs: Simplify some callers of compound_send_recv() Volker Lendecke
2023-03-15 13:05 ` [PATCH 02/10] cifs: Make "resp_buf_type" initialization consistent Volker Lendecke
2023-03-15 19:33   ` kernel test robot
2023-03-20  5:57   ` Dan Carpenter
2023-03-15 13:05 ` [PATCH 03/10] cifs: Slightly simplify cifs_readdir() Volker Lendecke
2023-03-15 13:05 ` [PATCH 04/10] " Volker Lendecke
2023-03-15 13:05 ` [PATCH 05/10] cifs: Simplify SMB2_OP_RMDIR with CREATE_DELETE_ON_CLOSE Volker Lendecke
2023-03-15 13:05 ` [PATCH 06/10] cifs: Slightly refactor smb2_compound_op() Volker Lendecke
2023-03-15 13:05 ` [PATCH 07/10] cifs: Reduce copy&paste in smb2_compound_op() Volker Lendecke
2023-03-15 13:05 ` [PATCH 08/10] cifs: Avoid two "else" branches Volker Lendecke
2023-03-15 13:05 ` [PATCH 09/10] cifs: Store smb3_create_tag_posix just once Volker Lendecke
2023-03-15 13:05 ` Volker Lendecke [this message]
2023-03-15 14:49 ` [PATCH 00/10] Some cleanups for fs/cifs Tom Talpey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f046f81ff9cb3fbba28e65d15fc14d0c82affca2.1678885349.git.vl@samba.org \
    --to=vl@samba.org \
    --cc=linux-cifs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox