Skip to content

Commit

Permalink
SUNRPC: Clean up one_sock_name()
Browse files Browse the repository at this point in the history
Clean up svc_one_sock_name() by setting up automatic variables for
frequently used expressions.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Apr 28, 2009
1 parent 58de2f8 commit 017cb47
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions net/sunrpc/svcsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,26 +242,27 @@ static int svc_sendto(struct svc_rqst *rqstp, struct xdr_buf *xdr)
*/
static int svc_one_sock_name(struct svc_sock *svsk, char *buf, int remaining)
{
const struct sock *sk = svsk->sk_sk;
const char *proto_name = sk->sk_protocol == IPPROTO_UDP ?
"udp" : "tcp";
int len;

switch(svsk->sk_sk->sk_family) {
switch (sk->sk_family) {
case PF_INET:
len = snprintf(buf, remaining, "ipv4 %s %pI4 %d\n",
svsk->sk_sk->sk_protocol == IPPROTO_UDP ?
"udp" : "tcp",
&inet_sk(svsk->sk_sk)->rcv_saddr,
inet_sk(svsk->sk_sk)->num);
proto_name,
&inet_sk(sk)->rcv_saddr,
inet_sk(sk)->num);
break;
case PF_INET6:
len = snprintf(buf, remaining, "ipv6 %s %pI6 %d\n",
svsk->sk_sk->sk_protocol == IPPROTO_UDP ?
"udp" : "tcp",
&inet6_sk(svsk->sk_sk)->rcv_saddr,
inet_sk(svsk->sk_sk)->num);
proto_name,
&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) {
Expand Down

0 comments on commit 017cb47

Please sign in to comment.