[IB] simplify mad_rmpp.c:alloc_response_msg()
Change alloc_response_msg() in mad_rmpp.c to return the struct it allocates directly (or an error code a la ERR_PTR), rather than returning a status and passing the struct back in a pointer param. This simplifies the code and gets rid of warnings like drivers/infiniband/core/mad_rmpp.c: In function nack_recv: drivers/infiniband/core/mad_rmpp.c:192: warning: msg may be used uninitialized in this function with newer versions of gcc. Signed-off-by: Roland Dreier <rolandd@cisco.com>
This commit is contained in:
parent
547e309073
commit
7cc656efb5
@ -151,28 +151,27 @@ static void ack_recv(struct mad_rmpp_recv *rmpp_recv,
|
|||||||
ib_free_send_mad(msg);
|
ib_free_send_mad(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int alloc_response_msg(struct ib_mad_agent *agent,
|
static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent,
|
||||||
struct ib_mad_recv_wc *recv_wc,
|
struct ib_mad_recv_wc *recv_wc)
|
||||||
struct ib_mad_send_buf **msg)
|
|
||||||
{
|
{
|
||||||
struct ib_mad_send_buf *m;
|
struct ib_mad_send_buf *msg;
|
||||||
struct ib_ah *ah;
|
struct ib_ah *ah;
|
||||||
|
|
||||||
ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc,
|
ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc,
|
||||||
recv_wc->recv_buf.grh, agent->port_num);
|
recv_wc->recv_buf.grh, agent->port_num);
|
||||||
if (IS_ERR(ah))
|
if (IS_ERR(ah))
|
||||||
return PTR_ERR(ah);
|
return (void *) ah;
|
||||||
|
|
||||||
m = ib_create_send_mad(agent, recv_wc->wc->src_qp,
|
msg = ib_create_send_mad(agent, recv_wc->wc->src_qp,
|
||||||
recv_wc->wc->pkey_index, 1,
|
recv_wc->wc->pkey_index, 1,
|
||||||
IB_MGMT_RMPP_HDR, IB_MGMT_RMPP_DATA, GFP_KERNEL);
|
IB_MGMT_RMPP_HDR, IB_MGMT_RMPP_DATA,
|
||||||
if (IS_ERR(m)) {
|
GFP_KERNEL);
|
||||||
|
if (IS_ERR(msg))
|
||||||
ib_destroy_ah(ah);
|
ib_destroy_ah(ah);
|
||||||
return PTR_ERR(m);
|
else
|
||||||
}
|
msg->ah = ah;
|
||||||
m->ah = ah;
|
|
||||||
*msg = m;
|
return msg;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc)
|
void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc)
|
||||||
@ -191,8 +190,8 @@ static void nack_recv(struct ib_mad_agent_private *agent,
|
|||||||
struct ib_rmpp_mad *rmpp_mad;
|
struct ib_rmpp_mad *rmpp_mad;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = alloc_response_msg(&agent->agent, recv_wc, &msg);
|
msg = alloc_response_msg(&agent->agent, recv_wc);
|
||||||
if (ret)
|
if (IS_ERR(msg))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
rmpp_mad = msg->mad;
|
rmpp_mad = msg->mad;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user