SUNRPC: Clean up functions that free address_strings array
authorChuck Lever <chuck.lever@oracle.com>
Mon, 14 Jan 2008 17:32:20 +0000 (12:32 -0500)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 30 Jan 2008 07:06:08 +0000 (02:06 -0500)
Clean up: document the rule (kfree) and the exceptions
(RPC_DISPLAY_PROTO and RPC_DISPLAY_NETID) when freeing the objects in
a transport's address_strings array.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
net/sunrpc/xprtrdma/transport.c
net/sunrpc/xprtsock.c

index d1389afc8342270a5df2ff7cc2e3177a33f7ea7e..02c522c17de599f5ea4d776038ff1e0e5d268642 100644 (file)
@@ -212,12 +212,16 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt)
 static void
 xprt_rdma_free_addresses(struct rpc_xprt *xprt)
 {
-       kfree(xprt->address_strings[RPC_DISPLAY_ADDR]);
-       kfree(xprt->address_strings[RPC_DISPLAY_PORT]);
-       kfree(xprt->address_strings[RPC_DISPLAY_ALL]);
-       kfree(xprt->address_strings[RPC_DISPLAY_HEX_ADDR]);
-       kfree(xprt->address_strings[RPC_DISPLAY_HEX_PORT]);
-       kfree(xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR]);
+       unsigned int i;
+
+       for (i = 0; i < RPC_DISPLAY_MAX; i++)
+               switch (i) {
+               case RPC_DISPLAY_PROTO:
+               case RPC_DISPLAY_NETID:
+                       continue;
+               default:
+                       kfree(xprt->address_strings[i]);
+               }
 }
 
 static void
index b9b94f49c62029be52e5736365ddfa6544ebe8e4..30e7ac243a90bf2347fc36bdac30004f21e84d40 100644 (file)
@@ -398,12 +398,16 @@ static void xs_format_ipv6_peer_addresses(struct rpc_xprt *xprt,
 
 static void xs_free_peer_addresses(struct rpc_xprt *xprt)
 {
-       kfree(xprt->address_strings[RPC_DISPLAY_ADDR]);
-       kfree(xprt->address_strings[RPC_DISPLAY_PORT]);
-       kfree(xprt->address_strings[RPC_DISPLAY_ALL]);
-       kfree(xprt->address_strings[RPC_DISPLAY_HEX_ADDR]);
-       kfree(xprt->address_strings[RPC_DISPLAY_HEX_PORT]);
-       kfree(xprt->address_strings[RPC_DISPLAY_UNIVERSAL_ADDR]);
+       unsigned int i;
+
+       for (i = 0; i < RPC_DISPLAY_MAX; i++)
+               switch (i) {
+               case RPC_DISPLAY_PROTO:
+               case RPC_DISPLAY_NETID:
+                       continue;
+               default:
+                       kfree(xprt->address_strings[i]);
+               }
 }
 
 #define XS_SENDMSG_FLAGS       (MSG_DONTWAIT | MSG_NOSIGNAL)