net/sunrpc: Remove uses of NIPQUAD, use %pI4
Subsystems (3)
PATCH RESEND 1/1 net/sunrpc: Remove uses of NIPQUAD, use %pI4
Originally submitted Jan 1, 2010
http://patchwork.kernel.org/patch/71221/
Convert NIPQUAD to the %pI4 format extension where possible Convert %02x%02x%02x%02x/NIPQUAD to %08x/ntohl
--- net/sunrpc/xprtrdma/transport.c | 3 +-- net/sunrpc/xprtsock.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-)
net/sunrpc/xprtrdma/transport.c +1 -2
@@ -165,8 +165,7 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt) xprt->address_strings[RPC_DISPLAY_PROTO ] ="rdma" ; - (void )snprintf (buf,sizeof (buf),"%02x%02x%02x%02x" , -NIPQUAD (sin->sin_addr.s_addr)); + (void )snprintf (buf,sizeof (buf),"%08x" ,ntohl (sin->sin_addr.s_addr)); xprt->address_strings[RPC_DISPLAY_HEX_ADDR ] =kstrdup (buf,GFP_KERNEL ); (void )snprintf (buf,sizeof (buf),"%4hx" ,rpc_get_port (sap));
net/sunrpc/xprtsock.c +2 -3
@@ -297,12 +297,11 @@ static void xs_format_common_peer_addresses(struct rpc_xprt *xprt)switch (sap->sa_family) {case AF_INET : sin =xs_addr_in (xprt); - (void )snprintf (buf,sizeof (buf),"%02x%02x%02x%02x" , -NIPQUAD (sin->sin_addr.s_addr)); +snprintf (buf,sizeof (buf),"%08x" ,ntohl (sin->sin_addr.s_addr));break ;case AF_INET6 : sin6 =xs_addr_in6 (xprt); - (void )snprintf (buf,sizeof (buf),"%pi6" , &sin6->sin6_addr); +snprintf (buf,sizeof (buf),"%pi6" , &sin6->sin6_addr);break ;default :BUG ();
David Miller
maintainerFrom: Joe Perches <[email protected]>
Date: Fri, 05 Mar 2010 22:46:20 -0800
Quoted 7 lines
Originally submitted Jan 1, 2010
http://patchwork.kernel.org/patch/71221/Convert NIPQUAD to the %pI4 format extension where possible Convert %02x%02x%02x%02x/NIPQUAD to %08x/ntohl
Signed-off-by Joe Perches <[email protected]>
Trond, are you going to integrate this?
Otherwise I'm going to.
Quoted 6 lines · David Miller
From: Joe Perches <[email protected]>
Date: Fri, 05 Mar 2010 22:46:20 -0800Quoted 3 lines
Originally submitted Jan 1, 2010
http://patchwork.kernel.org/patch/71221/
Quoted 8 lines
Quoted 4 lines
Convert NIPQUAD to the %pI4 format extension where possible Convert %02x%02x%02x%02x/NIPQUAD to %08x/ntohl
Signed-off-by Joe Perches <[email protected]>Trond, are you going to integrate this?
Otherwise I'm going to.
If you're planning another push to Linus then feel free to push this too.
If not, then I do have a couple of small cleanups and fixes that I want to push before the merge window closes, so I could send Joe's patch together with those...
Cheers
Trond
Quoted 32 lines · Joe Perches
Originally submitted Jan 1, 2010
http://patchwork.kernel.org/patch/71221/Convert NIPQUAD to the %pI4 format extension where possible Convert %02x%02x%02x%02x/NIPQUAD to %08x/ntohl
Signed-off-by Joe Perches<[email protected]>--- net/sunrpc/xprtrdma/transport.c | 3 +-- net/sunrpc/xprtsock.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-)net/sunrpc/xprtrdma/transport.c +1
-2@@ -165,8 +165,7 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt) xprt->address_strings[RPC_DISPLAY_PROTO ] ="rdma" ; - (void )snprintf (buf,sizeof (buf),"%02x%02x%02x%02x" , -NIPQUAD (sin->sin_addr.s_addr)); + (void )snprintf (buf,sizeof (buf),"%08x" ,ntohl (sin->sin_addr.s_addr)); xprt->address_strings[RPC_DISPLAY_HEX_ADDR ] =kstrdup (buf,GFP_KERNEL ); (void )snprintf (buf,sizeof (buf),"%4hx" ,rpc_get_port (sap));net/sunrpc/xprtsock.c +0
-0@@ -297,12 +297,11 @@ static void xs_format_common_peer_addresses(struct rpc_xprt *xprt)switch (sap->sa_family) {
net/sunrpc/xprtsock.c static void xs_format_common_peer_addresses(struct rpc_xprt *xprt) · line 304
Quoted 10 lines
net/sunrpc/xprtsock.c +2
-3case AF_INET : sin =xs_addr_in (xprt); - (void )snprintf (buf,sizeof (buf),"%02x%02x%02x%02x" , -NIPQUAD (sin->sin_addr.s_addr)); +snprintf (buf,sizeof (buf),"%08x" ,ntohl (sin->sin_addr.s_addr));break ;case AF_INET6 : sin6 =xs_addr_in6 (xprt); - (void )snprintf (buf,sizeof (buf),"%pi6" ,&sin6->sin6_addr); +snprintf (buf,sizeof (buf),"%pi6" ,&sin6->sin6_addr);
Why remove the (void) here, but not in xprtrdma/transport.c? IMO the (void) cast should be left in place at all three call sites.
Quoted 9 lines
net/sunrpc/xprtsock.c +0
-1break ;default :BUG (); --To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 1 line
chuck[dot]lever[at]oracle[dot]com
Quoted 2 lines · Chuck Lever
Why remove the (void) here, but not in
xprtrdma/transport.c? IMO the (void) cast should be left in place at all three call sites.
I didn't notice it in xprtrdma/transport.c, otherwise I'd've removed it there too.
When the result is not used, snprintf is most commonly not cast at all.
(There's a space and a tab in the brackets of the grep string)
$ grep -rP --include=*.[ch] "^[ ]+snprintf\s*\(" * | wc -l
1301$ grep -rP --include=*.[ch] "^[ ]+\(\s*void\s*\)\s*snprintf\s*\(" * | wc -l
9net/sunrpc/ has 7 of those.
I'll get around to submitting patches for all of them.
PATCH 1/1 net/sunrpc: Convert (void)snprintf to snprintf
In reply to Chuck Lever(Applies on top of "Remove uses of NIPQUAD, use %pI4")
Casts to void of snprintf are most uncommon in kernel source. 9 use casts, 1301 do not.
Remove the remaining uses in net/sunrpc/
--- net/sunrpc/xprtrdma/transport.c | 6 +++--- net/sunrpc/xprtsock.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
net/sunrpc/xprtrdma/transport.c +3 -3
@@ -160,15 +160,15 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt) (void )rpc_ntop (sap, buf,sizeof (buf)); xprt->address_strings[RPC_DISPLAY_ADDR ] =kstrdup (buf,GFP_KERNEL ); - (void )snprintf (buf,sizeof (buf),"%u" ,rpc_get_port (sap)); +snprintf (buf,sizeof (buf),"%u" ,rpc_get_port (sap)); xprt->address_strings[RPC_DISPLAY_PORT ] =kstrdup (buf,GFP_KERNEL ); xprt->address_strings[RPC_DISPLAY_PROTO ] ="rdma" ; - (void )snprintf (buf,sizeof (buf),"%08x" ,ntohl (sin->sin_addr.s_addr)); +snprintf (buf,sizeof (buf),"%08x" ,ntohl (sin->sin_addr.s_addr)); xprt->address_strings[RPC_DISPLAY_HEX_ADDR ] =kstrdup (buf,GFP_KERNEL ); - (void )snprintf (buf,sizeof (buf),"%4hx" ,rpc_get_port (sap)); +snprintf (buf,sizeof (buf),"%4hx" ,rpc_get_port (sap)); xprt->address_strings[RPC_DISPLAY_HEX_PORT ] =kstrdup (buf,GFP_KERNEL );/* netid */
net/sunrpc/xprtsock.c +2 -2
@@ -314,10 +314,10 @@ static void xs_format_common_peer_ports(struct rpc_xprt *xprt)struct sockaddr *sap =xs_addr (xprt);char buf[128 ]; - (void )snprintf (buf,sizeof (buf),"%u" ,rpc_get_port (sap)); +snprintf (buf,sizeof (buf),"%u" ,rpc_get_port (sap)); xprt->address_strings[RPC_DISPLAY_PORT ] =kstrdup (buf,GFP_KERNEL ); - (void )snprintf (buf,sizeof (buf),"%4hx" ,rpc_get_port (sap)); +snprintf (buf,sizeof (buf),"%4hx" ,rpc_get_port (sap)); xprt->address_strings[RPC_DISPLAY_HEX_PORT ] =kstrdup (buf,GFP_KERNEL ); }
David Miller
maintainerRe: [PATCH] net/sunrpc: Convert (void)snprintf to snprintf
From: Joe Perches <[email protected]>
Date: Mon, 08 Mar 2010 08:38:30 -0800
Quoted 8 lines
(Applies on top of "Remove uses of NIPQUAD, use %pI4")
Casts to void of snprintf are most uncommon in kernel source. 9 use casts, 1301 do not.
Remove the remaining uses in
net/sunrpc/Signed-off-by Joe Perches <[email protected]>
Also applied, thanks Joe.
From: Joe Perches <[email protected]>
Date: Fri, 05 Mar 2010 22:46:20 -0800
Quoted 7 lines
Originally submitted Jan 1, 2010
http://patchwork.kernel.org/patch/71221/Convert NIPQUAD to the %pI4 format extension where possible Convert %02x%02x%02x%02x/NIPQUAD to %08x/ntohl
Signed-off-by Joe Perches <[email protected]>
Applied.