Re: [PATCH v3 4/4] RDMA, core and ULPs: Declare ib_post_send() and ib_post_recv() arguments const

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

 



On Thu, 2018-07-12 at 12:12 +0300, Max Gurtovoy wrote:
> On 7/10/2018 9:27 PM, Bart Van Assche wrote:
> > -int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, struct ib_recv_wr *wr,
> > -			  struct ib_recv_wr **bad_wr)
> > +int bnxt_re_post_srq_recv(struct ib_srq *ib_srq, const struct ib_recv_wr *wr,
> > +			  const struct ib_recv_wr **bad_wr)
> 
> should **bad_wr be const here ?

Hello Max,

When replying to a large e-mail, please trim the e-mail you are replying to.
Otherwise it's hard to find the replies.

Regarding your question: since *wr is const and since wr is one of the possible
values that can be assigned to *bad_wr, **bad_wr has to be declared const too.

> > diff --git a/net/sunrpc/xprtrdma/verbs.c b/net/sunrpc/xprtrdma/verbs.c
> > index 112a15abc4a4..02d8fdad12ff 100644
> > --- a/net/sunrpc/xprtrdma/verbs.c
> > +++ b/net/sunrpc/xprtrdma/verbs.c
> > @@ -1516,7 +1516,8 @@ void
> >   rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
> >   {
> >   	struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
> > -	struct ib_recv_wr *wr, *bad_wr;
> > +	struct ib_recv_wr *wr;
> > +	struct ib_recv_wr *bad_wr;
> 
> const ?

In this case it is on purpose that bad_wr was not declared const.

> > -	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr, &bad_wr);
> > +	rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr,
> > +			  (const struct ib_recv_wr **)&bad_wr);
> 
> is this cast needed ?

Yes, because of the following loop:

> >  		for (wr = bad_wr; wr; wr = wr->next) {
> >   			struct rpcrdma_rep *rep;

Bart.



��.n��������+%������w��{.n�����{���fk��ܨ}���Ơz�j:+v�����w����ޙ��&�)ߡ�a����z�ޗ���ݢj��w�f




[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