linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Doug Ledford <dledford@redhat.com>,
	Gal Pressman <galpress@amazon.com>,
	linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next v1 03/11] RDMA/efa: Use in-kernel offsetofend() to check field availability
Date: Fri, 13 Mar 2020 15:57:14 +0200	[thread overview]
Message-ID: <20200313135714.GH31504@unreal> (raw)
In-Reply-To: <20200313134456.GA24733@ziepe.ca>

On Fri, Mar 13, 2020 at 10:44:56AM -0300, Jason Gunthorpe wrote:
> On Tue, Mar 10, 2020 at 11:14:30AM +0200, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@mellanox.com>
> >
> > Remove custom and duplicated variant of offsetofend().
> >
> > Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> >  drivers/infiniband/hw/efa/efa_verbs.c | 7 ++-----
> >  1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/efa/efa_verbs.c b/drivers/infiniband/hw/efa/efa_verbs.c
> > index bf3120f140f7..5c57098a4aee 100644
> > +++ b/drivers/infiniband/hw/efa/efa_verbs.c
> > @@ -144,9 +144,6 @@ static inline bool is_rdma_read_cap(struct efa_dev *dev)
> >  	return dev->dev_attr.device_caps & EFA_ADMIN_FEATURE_DEVICE_ATTR_DESC_RDMA_READ_MASK;
> >  }
> >
> > -#define field_avail(x, fld, sz) (offsetof(typeof(x), fld) + \
> > -				 sizeof_field(typeof(x), fld) <= (sz))
> > -
> >  #define is_reserved_cleared(reserved) \
> >  	!memchr_inv(reserved, 0, sizeof(reserved))
> >
> > @@ -609,7 +606,7 @@ struct ib_qp *efa_create_qp(struct ib_pd *ibpd,
> >  	if (err)
> >  		goto err_out;
> >
> > -	if (!field_avail(cmd, driver_qp_type, udata->inlen)) {
> > +	if (offsetofend(typeof(cmd), driver_qp_type) > udata->inlen) {
>
> The > needs to be >=, and generally we write compares as
>    'variable XX constant'

Why ">="
The original code is
if (!field_avail(cmd, driver_qp_type, udata->inlen))
==>
if (!(offsetof(typeof(cmd), driver_qp_type) + sizeof_field(typeof(cmd), driver_qp_type,) <= (udata->inlen))
===>
if (!(offsetofend(typeof(cmd), driver_qp_type) <= (udata->inlen))
===>
if (offsetofend(typeof(cmd), driver_qp_type) > (udata->inlen)

like I wrote.

>


>
> > @@ -896,7 +893,7 @@ int efa_create_cq(struct ib_cq *ibcq, const struct ib_cq_init_attr *attr,
> >  		goto err_out;
> >  	}
> >
> > -	if (!field_avail(cmd, num_sub_cqs, udata->inlen)) {
> > +	if (offsetofend(typeof(cmd), num_sub_cqs) > udata->inlen) {
>
> Same
>
> Jason

  reply	other threads:[~2020-03-13 13:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10  9:14 [PATCH rdma-next v1 00/11] Add Enhanced Connection Established (ECE) Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 01/11] RDMA/cm: Add Enhanced Connection Establishment (ECE) bits Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 02/11] RDMA/mlx4: Delete duplicated offsetofend implementation Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 03/11] RDMA/efa: Use in-kernel offsetofend() to check field availability Leon Romanovsky
2020-03-13 13:44   ` Jason Gunthorpe
2020-03-13 13:57     ` Leon Romanovsky [this message]
2020-03-13 14:26       ` Jason Gunthorpe
2020-03-13 14:38         ` Leon Romanovsky
2020-03-15  7:44   ` Gal Pressman
2020-03-18  9:13     ` Leon Romanovsky
2020-03-19  0:08   ` Jason Gunthorpe
2020-03-10  9:14 ` [PATCH rdma-next v1 04/11] RDMA/mlx5: Use offsetofend() instead of duplicated variant Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 05/11] RDMA/cm: Delete not implemented CM peer to peer communication Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 06/11] RDMA/uapi: Add ECE definitions to UCMA Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 07/11] RDMA/ucma: Extend ucma_connect to receive ECE parameters Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 08/11] RDMA/ucma: Deliver ECE parameters through UCMA events Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 09/11] RDMA/cm: Send and receive ECE parameter over the wire Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 10/11] RDMA/cma: Connect ECE to rdma_accept Leon Romanovsky
2020-03-10  9:14 ` [PATCH rdma-next v1 11/11] RDMA/cma: Provide ECE reject reason Leon Romanovsky
2020-03-13 13:54   ` Jason Gunthorpe
2020-03-13 13:59     ` Leon Romanovsky
2020-03-13 13:53 ` [PATCH rdma-next v1 00/11] Add Enhanced Connection Established (ECE) Jason Gunthorpe
2020-03-13 14:00   ` Leon Romanovsky

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=20200313135714.GH31504@unreal \
    --to=leon@kernel.org \
    --cc=dledford@redhat.com \
    --cc=galpress@amazon.com \
    --cc=jgg@ziepe.ca \
    --cc=linux-rdma@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).