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