diff mbox series

[net-next,v1] sunrpc: Use ERR_CAST() to return

Message ID 20240829130434.3335629-1-yanzhen@vivo.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next,v1] sunrpc: Use ERR_CAST() to return | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 13 of 13 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 17 this patch: 17
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 24 this patch: 24
netdev/source_inline success Was 0 now: 0

Commit Message

Yan Zhen Aug. 29, 2024, 1:04 p.m. UTC
Using ERR_CAST() is more reasonable and safer, When it is necessary
to convert the type of an error pointer and return it.

Signed-off-by: Yan Zhen <yanzhen@vivo.com>
---
 net/sunrpc/clnt.c                        | 2 +-
 net/sunrpc/xprtrdma/svc_rdma_transport.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Jeff Layton Aug. 29, 2024, 1:11 p.m. UTC | #1
On Thu, 2024-08-29 at 21:04 +0800, Yan Zhen wrote:
> Using ERR_CAST() is more reasonable and safer, When it is necessary
> to convert the type of an error pointer and return it.
> 
> Signed-off-by: Yan Zhen <yanzhen@vivo.com>
> ---
>  net/sunrpc/clnt.c                        | 2 +-
>  net/sunrpc/xprtrdma/svc_rdma_transport.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
> index 09f29a95f2bc..8ee87311b348 100644
> --- a/net/sunrpc/clnt.c
> +++ b/net/sunrpc/clnt.c
> @@ -603,7 +603,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
>  
>  	xprt = xprt_create_transport(&xprtargs);
>  	if (IS_ERR(xprt))
> -		return (struct rpc_clnt *)xprt;
> +		return ERR_CAST(xprt);
>  
>  	/*
>  	 * By default, kernel RPC client connects from a reserved port.
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> index 581cc5ed7c0c..c3fbf0779d4a 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> @@ -369,7 +369,7 @@ static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
>  	listen_id = svc_rdma_create_listen_id(net, sa, cma_xprt);
>  	if (IS_ERR(listen_id)) {
>  		kfree(cma_xprt);
> -		return (struct svc_xprt *)listen_id;
> +		return ERR_CAST(listen_id);
>  	}
>  	cma_xprt->sc_cm_id = listen_id;
>  

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Chuck Lever III Aug. 29, 2024, 2:53 p.m. UTC | #2
On Thu, Aug 29, 2024 at 09:04:34PM +0800, Yan Zhen wrote:
> Using ERR_CAST() is more reasonable and safer, When it is necessary
> to convert the type of an error pointer and return it.
> 
> Signed-off-by: Yan Zhen <yanzhen@vivo.com>
> ---
>  net/sunrpc/clnt.c                        | 2 +-
>  net/sunrpc/xprtrdma/svc_rdma_transport.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
> index 09f29a95f2bc..8ee87311b348 100644
> --- a/net/sunrpc/clnt.c
> +++ b/net/sunrpc/clnt.c
> @@ -603,7 +603,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
>  
>  	xprt = xprt_create_transport(&xprtargs);
>  	if (IS_ERR(xprt))
> -		return (struct rpc_clnt *)xprt;
> +		return ERR_CAST(xprt);
>  
>  	/*
>  	 * By default, kernel RPC client connects from a reserved port.
> diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> index 581cc5ed7c0c..c3fbf0779d4a 100644
> --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
> +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
> @@ -369,7 +369,7 @@ static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
>  	listen_id = svc_rdma_create_listen_id(net, sa, cma_xprt);
>  	if (IS_ERR(listen_id)) {
>  		kfree(cma_xprt);
> -		return (struct svc_xprt *)listen_id;
> +		return ERR_CAST(listen_id);
>  	}
>  	cma_xprt->sc_cm_id = listen_id;
>  
> -- 
> 2.34.1
> 
> 

These two hunks should go through separate trees, I think.

The clnt.c hunk needs to go through Anna and Trond's NFS client
tree, and the svc_rdma_transport.c hunk can go through the NFSD
tree (ie, To: me and Jeff).

Can you send two separate patches, please? The RDMA hunk looks OK to
me and I plan to apply it upon receipt of a separate patch.
diff mbox series

Patch

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 09f29a95f2bc..8ee87311b348 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -603,7 +603,7 @@  struct rpc_clnt *rpc_create(struct rpc_create_args *args)
 
 	xprt = xprt_create_transport(&xprtargs);
 	if (IS_ERR(xprt))
-		return (struct rpc_clnt *)xprt;
+		return ERR_CAST(xprt);
 
 	/*
 	 * By default, kernel RPC client connects from a reserved port.
diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
index 581cc5ed7c0c..c3fbf0779d4a 100644
--- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
+++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
@@ -369,7 +369,7 @@  static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
 	listen_id = svc_rdma_create_listen_id(net, sa, cma_xprt);
 	if (IS_ERR(listen_id)) {
 		kfree(cma_xprt);
-		return (struct svc_xprt *)listen_id;
+		return ERR_CAST(listen_id);
 	}
 	cma_xprt->sc_cm_id = listen_id;