On Thu, Nov 21, 2019 at 08:38:40PM +0000, Jason Gunthorpe wrote: > On Thu, Nov 21, 2019 at 08:12:29PM +0200, Leon Romanovsky wrote: > > +#define _IBA_GET_MEM(field_struct, field_offset, byte_size, ptr, out, bytes) \ > > + ({ \ > > + WARN_ON(bytes > byte_size); \ > > + if (out && bytes) { \ > > Why check for null? Caller should handle > > > + const field_struct *_ptr = ptr; \ > > + memcpy(out, (void *)_ptr + (field_offset), bytes); \ > > + } \ > > + }) > > +#define IBA_GET_MEM(field, ptr, out, bytes) _IBA_GET_MEM(field, ptr, out, bytes) > > This should really have some type safety, ie check that out is > something like 'struct ibv_guid *'a This GET_MEM is not used yet, because I didn't find a way to model properly access to private_data, ari, info and GIDs at the same time. We can drop this chunk if it bothers you. Thanks > > Jason