From: Pekka Enberg <penberg@cs.helsinki.fi>
To: sfrench@samba.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 5/6] cifs: reduce deep nesting
Date: Sat, 15 Jan 2005 15:30:18 +0200 [thread overview]
Message-ID: <1105795818.9555.9.camel@localhost> (raw)
In-Reply-To: <1105795751.9555.7.camel@localhost>
This patch converts deep if statement nesting to use gotos in few places.
Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
---
cifsfs.c | 51 +++++++++++++++++++++++++++++++--------------------
connect.c | 44 ++++++++++++++++++++------------------------
2 files changed, 51 insertions(+), 44 deletions(-)
Index: linux/fs/cifs/cifsfs.c
===================================================================
--- linux.orig/fs/cifs/cifsfs.c 2005-01-11 08:04:55.007622032 +0200
+++ linux/fs/cifs/cifsfs.c 2005-01-11 08:04:57.454250088 +0200
@@ -839,26 +839,37 @@
}
rc = cifs_init_inodecache();
- if (!rc) {
- rc = cifs_init_mids();
- if (!rc) {
- rc = cifs_init_request_bufs();
- if (!rc) {
- rc = register_filesystem(&cifs_fs_type);
- if (!rc) {
- rc = (int)kernel_thread(cifs_oplock_thread, NULL,
- CLONE_FS | CLONE_FILES | CLONE_VM);
- if(rc > 0)
- return 0;
- else
- cERROR(1,("error %d create oplock thread",rc));
- }
- cifs_destroy_request_bufs();
- }
- cifs_destroy_mids();
- }
- cifs_destroy_inodecache();
- }
+ if (rc)
+ goto failed_init_inodecache;
+
+ rc = cifs_init_mids();
+ if (rc)
+ goto failed_init_mids;
+
+ rc = cifs_init_request_bufs();
+ if (rc)
+ goto failed_init_request_bufs;
+
+ rc = register_filesystem(&cifs_fs_type);
+ if (rc)
+ goto failed_register_filesystem;
+
+ rc = kernel_thread(cifs_oplock_thread, NULL,
+ CLONE_FS | CLONE_FILES | CLONE_VM);
+ if (rc <= 0)
+ goto failed_kernel_thread;
+
+ return 0;
+
+ failed_kernel_thread:
+ cERROR(1,("error %d create oplock thread",rc));
+ failed_register_filesystem:
+ cifs_destroy_request_bufs();
+ failed_init_request_bufs:
+ cifs_destroy_mids();
+ failed_init_mids:
+ cifs_destroy_inodecache();
+ failed_init_inodecache:
#ifdef CONFIG_PROC_FS
cifs_proc_clean();
#endif
Index: linux/fs/cifs/connect.c
===================================================================
--- linux.orig/fs/cifs/connect.c 2005-01-11 08:04:50.326333696 +0200
+++ linux/fs/cifs/connect.c 2005-01-11 08:04:57.457249632 +0200
@@ -122,11 +122,9 @@
read_lock(&GlobalSMBSeslock);
list_for_each(tmp, &GlobalSMBSessionList) {
ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
- if (ses->server) {
- if (ses->server == server) {
- ses->status = CifsNeedReconnect;
- ses->ipc_tid = 0;
- }
+ if (ses->server && ses->server == server) {
+ ses->status = CifsNeedReconnect;
+ ses->ipc_tid = 0;
}
/* else tcp and smb sessions need reconnection */
}
@@ -857,33 +855,31 @@
char *userName, struct TCP_Server_Info **psrvTcp)
{
struct list_head *tmp;
- struct cifsSesInfo *ses;
+ struct cifsSesInfo *ret = NULL;
*psrvTcp = NULL;
read_lock(&GlobalSMBSeslock);
list_for_each(tmp, &GlobalSMBSessionList) {
- ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
- if (ses->server) {
- if((target_ip_addr &&
- (ses->server->addr.sockAddr.sin_addr.s_addr
- == target_ip_addr->s_addr)) || (target_ip6_addr
- && memcmp(&ses->server->addr.sockAddr6.sin6_addr,
- target_ip6_addr,sizeof(*target_ip6_addr)))){
- /* BB lock server and tcp session and increment use count here?? */
- *psrvTcp = ses->server; /* found a match on the TCP session */
- /* BB check if reconnection needed */
- if (strncmp
- (ses->userName, userName,
- MAX_USERNAME_SIZE) == 0){
- read_unlock(&GlobalSMBSeslock);
- return ses; /* found exact match on both tcp and SMB sessions */
- }
+ struct cifsSesInfo * ses = list_entry(tmp, struct cifsSesInfo, cifsSessionList);
+ if (!ses->server)
+ continue;
+ if((target_ip_addr &&
+ (ses->server->addr.sockAddr.sin_addr.s_addr
+ == target_ip_addr->s_addr)) || (target_ip6_addr
+ && memcmp(&ses->server->addr.sockAddr6.sin6_addr,
+ target_ip6_addr,sizeof(*target_ip6_addr)))){
+ /* BB lock server and tcp session and increment use count here?? */
+ *psrvTcp = ses->server; /* found a match on the TCP session */
+ /* BB check if reconnection needed */
+ if (strncmp(ses->userName, userName, MAX_USERNAME_SIZE) == 0) {
+ ret = ses;
+ goto out;
}
}
- /* else tcp and smb sessions need reconnection */
}
+ out:
read_unlock(&GlobalSMBSeslock);
- return NULL;
+ return ret;
}
static struct cifsTconInfo *
next prev parent reply other threads:[~2005-01-15 13:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-15 13:25 [PATCH 1/6] cifs: copy_to_user and copy_from_user fixes Pekka Enberg
2005-01-15 13:26 ` [PATCH 2/6] cifs: remove dead code Pekka Enberg
2005-01-15 13:28 ` [PATCH 3/6] cifs: enum conversion Pekka Enberg
2005-01-15 13:29 ` [PATCH 4/6] cifs: remove spurious casts Pekka Enberg
2005-01-15 13:30 ` Pekka Enberg [this message]
2005-01-15 13:31 ` [PATCH 6/6] cifs: convert schedule_timeout to msleep and ssleep Pekka Enberg
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=1105795818.9555.9.camel@localhost \
--to=penberg@cs.helsinki.fi \
--cc=linux-kernel@vger.kernel.org \
--cc=sfrench@samba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.