All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@dreamhost.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 3/4] libceph: make ceph_tcp_connect() return int
Date: Tue, 28 Feb 2012 20:46:38 -0800	[thread overview]
Message-ID: <4F4DADAE.2000708@dreamhost.com> (raw)
In-Reply-To: <4F4DAD34.2030202@dreamhost.com>

There is no real need for ceph_tcp_connect() to return the socket
pointer it creates, since it already assigns it to con->sock, which
is visible to the caller.  Instead, have it return an error code,
which tidies things up a bit.

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

diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
index 2e496e2..9a8a479 100644
--- a/net/ceph/messenger.c
+++ b/net/ceph/messenger.c
@@ -236,7 +236,7 @@ static void set_sock_callbacks(struct socket *sock,
  /*
   * initiate connection to a remote socket.
   */
-static struct socket *ceph_tcp_connect(struct ceph_connection *con)
+static int ceph_tcp_connect(struct ceph_connection *con)
  {
  	struct sockaddr_storage *paddr = &con->peer_addr.in_addr;
  	struct socket *sock;
@@ -246,7 +246,7 @@ static struct socket *ceph_tcp_connect(struct 
ceph_connection *con)
  	ret = sock_create_kern(con->peer_addr.in_addr.ss_family, SOCK_STREAM,
  			       IPPROTO_TCP, &sock);
  	if (ret)
-		return ERR_PTR(ret);
+		return ret;
  	sock->sk->sk_allocation = GFP_NOFS;

  #ifdef CONFIG_LOCKDEP
@@ -269,11 +269,11 @@ static struct socket *ceph_tcp_connect(struct 
ceph_connection *con)
  		sock_release(sock);
  		con->error_msg = "connect error";

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

-	return sock;
+	return 0;
  }

  static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)
@@ -1850,11 +1850,9 @@ more:
  		con->in_tag = CEPH_MSGR_TAG_READY;
  		dout("try_write initiating connect on %p new state %lu\n",
  		     con, con->state);
-		con->sock = ceph_tcp_connect(con);
-		if (IS_ERR(con->sock)) {
-			con->sock = NULL;
+		ret = ceph_tcp_connect(con);
+		if (ret < 0) {
  			con->error_msg = "connect error";
-			ret = -1;
  			goto out;
  		}
  	}
-- 
1.7.5.4


  parent reply	other threads:[~2012-02-29  4:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-29  4:44 [PATCH 0/4] libceph: miscellaneous cleanups Alex Elder
2012-02-29  4:46 ` [PATCH 1/4] libceph: make ceph_msgr_wq private Alex Elder
2012-02-29  4:46 ` [PATCH 2/4] libceph: encapsulate some messenger cleanup code Alex Elder
2012-02-29 17:44   ` [PATCH, v2] " Alex Elder
2012-02-29  4:46 ` Alex Elder [this message]
2012-02-29  4:46 ` [PATCH 4/4] libceph: a few small changes Alex Elder
2012-03-02 21:40   ` Sage Weil
2012-03-02 23:28     ` Alex Elder
2012-03-02 21:42 ` [PATCH 0/4] libceph: miscellaneous 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=4F4DADAE.2000708@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.