[PATCH 11/22] SUNRPC: Clean up one_sock_name()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Clean up svc_one_sock_name() by setting up automatic variables for
frequently used expressions.

Signed-off-by: Chuck Lever <chuck.lever@xxxxxxxxxx>
---

 net/sunrpc/svcsock.c |   26 +++++++++++++++-----------
 1 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index c148de9..e0d74f6 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -246,26 +246,30 @@ out:
  */
 static int svc_one_sock_name(struct svc_sock *svsk, char *buf, int remaining)
 {
+	struct sock *sk = svsk->sk_sk;
+	char *proto_name;
 	int len;
 
-	switch(svsk->sk_sk->sk_family) {
+	proto_name = "tcp";
+	if (sk->sk_protocol == IPPROTO_UDP)
+		proto_name = "udp";
+
+	switch (sk->sk_family) {
 	case AF_INET:
-		len = snprintf(buf, remaining, "ipv4 %s %u.%u.%u.%u %d\n",
-			      svsk->sk_sk->sk_protocol==IPPROTO_UDP?
-			      "udp" : "tcp",
-			      NIPQUAD(inet_sk(svsk->sk_sk)->rcv_saddr),
-			      inet_sk(svsk->sk_sk)->num);
+		len = snprintf(buf, remaining, "ipv4 %s " NIPQUAD_FMT " %d\n",
+				proto_name,
+				NIPQUAD(inet_sk(sk)->rcv_saddr),
+				inet_sk(sk)->num);
 		break;
 	case AF_INET6:
 		len = snprintf(buf, remaining, "ipv6 %s " NIP6_FMT " %d\n",
-				svsk->sk_sk->sk_protocol == IPPROTO_UDP ?
-				"udp" : "tcp",
-				NIP6(inet6_sk(svsk->sk_sk)->rcv_saddr),
-				inet_sk(svsk->sk_sk)->num);
+				proto_name,
+				NIP6(inet6_sk(sk)->rcv_saddr),
+				inet_sk(sk)->num);
 		break;
 	default:
 		len = snprintf(buf, remaining, "*unknown-%d*\n",
-			       svsk->sk_sk->sk_family);
+				sk->sk_family);
 	}
 
 	if (len >= remaining) {

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux