Re: [PATCH rdma-next 2/9] RDMA: Promote field_avail() macro to be general code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

> +/**
> + * 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..

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux