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

Jinpu Wang
2020-01-16T16:48:34Z

On Thu, Jan 16, 2020 at 4:53 PM Jason Gunthorpe <jgg@ziepe.ca> wrote:
>
> 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
Thanks, in fact, it's just a function not used, will remove.