On Mon, Nov 25, 2019 at 02:40:33PM +0000, Jason Gunthorpe wrote: > On Fri, Nov 22, 2019 at 08:55:09AM +0200, Leon Romanovsky wrote: > > 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. > > I'm surprised we don't access the GIDs, how does that work? Never mind, we are talking about different things. > > Jason