All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@dreamhost.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 1/4] ceph: make use of "else" where appropriate
Date: Tue, 28 Feb 2012 19:12:09 -0800	[thread overview]
Message-ID: <4F4D9789.2080903@dreamhost.com> (raw)
In-Reply-To: <4F4D96F4.3080707@dreamhost.com>

Rearrange ceph_tcp_connect() a bit, making use of "else" rather than
re-testing a value with consecutive "if" statements.  Don't record a
connection's socket pointer unless the connect operation is
successful.

Signed-off-by: Alex Elder <elder@dreamhost.com>
---
  net/ceph/messenger.c |   11 ++++-------
  1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 068cb7e..c9a413a 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -247,7 +247,6 @@ static struct socket *ceph_tcp_connect(struct 
ceph_connection *con)
  			       IPPROTO_TCP, &sock);
  	if (ret)
  		return ERR_PTR(ret);
-	con->sock = sock;
  	sock->sk->sk_allocation = GFP_NOFS;

  #ifdef CONFIG_LOCKDEP
@@ -264,18 +263,16 @@ static struct socket *ceph_tcp_connect(struct 
ceph_connection *con)
  		dout("connect %s EINPROGRESS sk_state = %u\n",
  		     ceph_pr_addr(&con->peer_addr.in_addr),
  		     sock->sk->sk_state);
-		ret = 0;
-	}
-	if (ret < 0) {
+	} else if (ret < 0) {
  		pr_err("connect %s error %d\n",
  		       ceph_pr_addr(&con->peer_addr.in_addr), ret);
  		sock_release(sock);
-		con->sock = NULL;
  		con->error_msg = "connect error";
-	}

-	if (ret < 0)
  		return ERR_PTR(ret);
+	}
+	con->sock = sock;
+
  	return sock;
  }

-- 
1.7.5.4


  reply	other threads:[~2012-02-29  3:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-29  3:09 [PATCH 0/4] ceph: minor cleanups Alex Elder
2012-02-29  3:12 ` Alex Elder [this message]
2012-02-29  3:12 ` [PATCH 2/4] ceph: kill addr_str_lock spinlock; use atomic instead Alex Elder
2012-02-29  3:12 ` [PATCH 3/4] ceph: eliminate some needless casts Alex Elder
2012-02-29  3:12 ` [PATCH 4/4] ceph: eliminate some abusive casts Alex Elder
2012-03-02 19:25 ` [PATCH 0/4] ceph: minor cleanups Sage Weil

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=4F4D9789.2080903@dreamhost.com \
    --to=elder@dreamhost.com \
    --cc=ceph-devel@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 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.