Re: [PATCH v7 06/25] RDMA/rtrs: client: main functionality

Jason Gunthorpe
2020-01-16T15:53:05Z

On Thu, Jan 16, 2020 at 04:43:41PM +0100, Jinpu Wang wrote:
> > > + wake_up(&clt->permits_wait);
> > > +}
> > > +EXPORT_SYMBOL(rtrs_clt_put_permit);
> > > +
> > > +struct rtrs_permit *rtrs_permit_from_pdu(void *pdu)
> > > +{
> > > + return pdu - sizeof(struct rtrs_permit);
> >
> > C standard doesn't allow pointer arithmetic on void*.
> gcc never complains, searched aournd:
> https://stackoverflow.com/questions/3523145/pointer-arithmetic-for-void-pointer-in-c
>
> You're right, will fix.

The kernel extensively uses a gcc extension treating arithmatic on a
void * as the same as a u8, you can leave it for kernel code.

But is generally a big question why code is written like that, always
better to use a struct and container_of

Jason