public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Yu Jiaoliang <yujiaoliang@vivo.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
	Erick Archer <erick.archer@gmx.com>,
	Akiva Goldberger <agoldberger@nvidia.com>,
	Patrisious Haddad <phaddad@nvidia.com>,
	Mark Zhang <markzhang@nvidia.com>,
	Sagi Grimberg <sagi@grimberg.me>,
	Max Gurtovoy <mgurtovoy@nvidia.com>,
	Rohit Chavan <roheetchavan@gmail.com>,
	Or Har-Toov <ohartoov@nvidia.com>,
	Shigeru Yoshida <syoshida@redhat.com>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	opensource.kernel@vivo.com
Subject: Re: [PATCH v1 rdma-next] RDMA/core: Use ERR_CAST to return an error-valued pointer
Date: Thu, 5 Sep 2024 14:06:15 +0300	[thread overview]
Message-ID: <20240905110615.GU4026@unreal> (raw)
In-Reply-To: <20240905093445.1186581-1-yujiaoliang@vivo.com>

On Thu, Sep 05, 2024 at 05:34:40PM +0800, Yu Jiaoliang wrote:
> Instead of directly casting and returning (void *) pointer, use ERR_CAST
> to explicitly return an error-valued pointer. This makes the error handling
> more explicit and improves code clarity.
> 
> Signed-off-by: Yu Jiaoliang <yujiaoliang@vivo.com>
> ---
>  drivers/infiniband/core/mad_rmpp.c   | 2 +-
>  drivers/infiniband/core/uverbs_cmd.c | 2 +-
>  drivers/infiniband/core/verbs.c      | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

I see other places in the code that could benefit from this change.
Please do it for whole drivers/infiniband and group the patches.

Thanks

> 
> diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
> index 8af0619a39cd..b4b10e8a6495 100644
> --- a/drivers/infiniband/core/mad_rmpp.c
> +++ b/drivers/infiniband/core/mad_rmpp.c
> @@ -158,7 +158,7 @@ static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent,
>  	ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc,
>  				  recv_wc->recv_buf.grh, agent->port_num);
>  	if (IS_ERR(ah))
> -		return (void *) ah;
> +		return ERR_CAST(ah);
>  
>  	hdr_len = ib_get_mad_data_offset(recv_wc->recv_buf.mad->mad_hdr.mgmt_class);
>  	msg = ib_create_send_mad(agent, recv_wc->wc->src_qp,
> diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
> index 1b3ea71f2c33..35a83825f6ba 100644
> --- a/drivers/infiniband/core/uverbs_cmd.c
> +++ b/drivers/infiniband/core/uverbs_cmd.c
> @@ -192,7 +192,7 @@ _ib_uverbs_lookup_comp_file(s32 fd, struct uverbs_attr_bundle *attrs)
>  					       fd, attrs);
>  
>  	if (IS_ERR(uobj))
> -		return (void *)uobj;
> +		return ERR_CAST(uobj);
>  
>  	uverbs_uobject_get(uobj);
>  	uobj_put_read(uobj);
> diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
> index 473ee0831307..77268cce4d31 100644
> --- a/drivers/infiniband/core/verbs.c
> +++ b/drivers/infiniband/core/verbs.c
> @@ -572,7 +572,7 @@ struct ib_ah *rdma_create_ah(struct ib_pd *pd, struct rdma_ah_attr *ah_attr,
>  					   GFP_KERNEL : GFP_ATOMIC);
>  	if (IS_ERR(slave)) {
>  		rdma_unfill_sgid_attr(ah_attr, old_sgid_attr);
> -		return (void *)slave;
> +		return ERR_CAST(slave);
>  	}
>  	ah = _rdma_create_ah(pd, ah_attr, flags, NULL, slave);
>  	rdma_lag_put_ah_roce_slave(slave);
> -- 
> 2.34.1
> 

      reply	other threads:[~2024-09-05 11:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05  9:34 [PATCH v1 rdma-next] RDMA/core: Use ERR_CAST to return an error-valued pointer Yu Jiaoliang
2024-09-05 11:06 ` Leon Romanovsky [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240905110615.GU4026@unreal \
    --to=leon@kernel.org \
    --cc=agoldberger@nvidia.com \
    --cc=erick.archer@gmx.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=markzhang@nvidia.com \
    --cc=mgurtovoy@nvidia.com \
    --cc=ohartoov@nvidia.com \
    --cc=opensource.kernel@vivo.com \
    --cc=phaddad@nvidia.com \
    --cc=roheetchavan@gmail.com \
    --cc=sagi@grimberg.me \
    --cc=syoshida@redhat.com \
    --cc=yujiaoliang@vivo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox