From: Leon Romanovsky <leon@kernel.org>
To: Jason Gunthorpe <jgg@mellanox.com>
Cc: Doug Ledford <dledford@redhat.com>,
Gal Pressman <galpress@amazon.com>,
linux-rdma@vger.kernel.org, Mark Zhang <markz@mellanox.com>,
Yishai Hadas <yishaih@mellanox.com>
Subject: Re: [PATCH rdma-next 2/9] RDMA: Promote field_avail() macro to be general code
Date: Sun, 8 Mar 2020 09:18:58 +0200 [thread overview]
Message-ID: <20200308071858.GR184088@unreal> (raw)
In-Reply-To: <20200305151850.GZ26318@mellanox.com>
On Thu, Mar 05, 2020 at 11:18:50AM -0400, Jason Gunthorpe wrote:
> On Thu, Mar 05, 2020 at 05:00:58PM +0200, Leon Romanovsky wrote:
> >
> > +/**
> > + * FIELD_SIZEOF - get the size of a struct's field
> > + * @t: the target struct
> > + * @f: the target struct's field
> > + * Return: the size of @f in the struct definition without having a
> > + * declared instance of @t.
> > + */
> > +#define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
>
> This is already sizeof_field
Ohh, thanks
>
> > +/**
> > + * field_avail - check if specific field exists in provided data
> > + * @x: the source data, usually struct received from the user
> > + * @fld: field name
> > + * @sz: size of the data
> > + */
> > +#define field_avail(x, fld, sz) \
> > + (offsetof(typeof(x), fld) + FIELD_SIZEOF(typeof(x), fld) <= (sz))
>
> This is just offsetofend, I'm not sure there is such a reason to even
> have this field_avail macro really..
Even better.
Thanks
>
> Jason
next prev parent reply other threads:[~2020-03-08 7:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-05 15:00 [PATCH rdma-next 0/9] Add Enhanced Connection Established (ECE) Leon Romanovsky
2020-03-05 15:00 ` [PATCH rdma-next 1/9] RDMA/cm: Add Enhanced Connection Establishment (ECE) bits Leon Romanovsky
2020-03-05 15:00 ` [PATCH rdma-next 2/9] RDMA: Promote field_avail() macro to be general code Leon Romanovsky
2020-03-05 15:18 ` Jason Gunthorpe
2020-03-08 7:18 ` Leon Romanovsky [this message]
2020-03-05 15:00 ` [PATCH rdma-next 3/9] RDMA/cm: Delete not implemented CM peer to peer communication Leon Romanovsky
2020-03-05 15:01 ` [PATCH rdma-next 4/9] RDMA/uapi: Add ECE definitions to UCMA Leon Romanovsky
2020-03-05 15:01 ` [PATCH rdma-next 5/9] RDMA/ucma: Extend ucma_connect to receive ECE parameters Leon Romanovsky
2020-03-05 15:01 ` [PATCH rdma-next 6/9] RDMA/ucma: Deliver ECE parameters through UCMA events Leon Romanovsky
2020-03-05 15:01 ` [PATCH rdma-next 7/9] RDMA/cm: Send and receive ECE parameter over the wire Leon Romanovsky
2020-03-05 15:01 ` [PATCH rdma-next 8/9] RDMA/cma: Connect ECE to rdma_accept Leon Romanovsky
2020-03-05 15:01 ` [PATCH rdma-next 9/9] RDMA/cma: Provide ECE reject reason 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=20200308071858.GR184088@unreal \
--to=leon@kernel.org \
--cc=dledford@redhat.com \
--cc=galpress@amazon.com \
--cc=jgg@mellanox.com \
--cc=linux-rdma@vger.kernel.org \
--cc=markz@mellanox.com \
--cc=yishaih@mellanox.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;
as well as URLs for NNTP newsgroup(s).