diff options
author | Roland Dreier <rolandd@cisco.com> | 2005-10-25 18:13:54 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2005-10-25 18:13:54 -0400 |
commit | 7cc656efb560cda66b5ed48444cad7556ea4fe99 (patch) | |
tree | bfc4d1e256e755623c9782b1a0883fc337d88e6e | |
parent | 547e3090738b04be650770b64265835dbb6ddf92 (diff) |
[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>
-rw-r--r-- | drivers/infiniband/core/mad_rmpp.c | 31 |
1 files changed, 15 insertions, 16 deletions
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c index ba112cd5f93c..3249e1d8c07b 100644 --- a/drivers/infiniband/core/mad_rmpp.c +++ b/drivers/infiniband/core/mad_rmpp.c | |||
@@ -151,28 +151,27 @@ static void ack_recv(struct mad_rmpp_recv *rmpp_recv, | |||
151 | ib_free_send_mad(msg); | 151 | ib_free_send_mad(msg); |
152 | } | 152 | } |
153 | 153 | ||
154 | static int alloc_response_msg(struct ib_mad_agent *agent, | 154 | static struct ib_mad_send_buf *alloc_response_msg(struct ib_mad_agent *agent, |
155 | struct ib_mad_recv_wc *recv_wc, | 155 | struct ib_mad_recv_wc *recv_wc) |
156 | struct ib_mad_send_buf **msg) | ||
157 | { | 156 | { |
158 | struct ib_mad_send_buf *m; | 157 | struct ib_mad_send_buf *msg; |
159 | struct ib_ah *ah; | 158 | struct ib_ah *ah; |
160 | 159 | ||
161 | ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc, | 160 | ah = ib_create_ah_from_wc(agent->qp->pd, recv_wc->wc, |
162 | recv_wc->recv_buf.grh, agent->port_num); | 161 | recv_wc->recv_buf.grh, agent->port_num); |
163 | if (IS_ERR(ah)) | 162 | if (IS_ERR(ah)) |
164 | return PTR_ERR(ah); | 163 | return (void *) ah; |
165 | 164 | ||
166 | m = ib_create_send_mad(agent, recv_wc->wc->src_qp, | 165 | msg = ib_create_send_mad(agent, recv_wc->wc->src_qp, |
167 | recv_wc->wc->pkey_index, 1, | 166 | recv_wc->wc->pkey_index, 1, |
168 | IB_MGMT_RMPP_HDR, IB_MGMT_RMPP_DATA, GFP_KERNEL); | 167 | IB_MGMT_RMPP_HDR, IB_MGMT_RMPP_DATA, |
169 | if (IS_ERR(m)) { | 168 | GFP_KERNEL); |
169 | if (IS_ERR(msg)) | ||
170 | ib_destroy_ah(ah); | 170 | ib_destroy_ah(ah); |
171 | return PTR_ERR(m); | 171 | else |
172 | } | 172 | msg->ah = ah; |
173 | m->ah = ah; | 173 | |
174 | *msg = m; | 174 | return msg; |
175 | return 0; | ||
176 | } | 175 | } |
177 | 176 | ||
178 | void ib_rmpp_send_handler(struct ib_mad_send_wc *mad_send_wc) | 177 | 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, | |||
191 | struct ib_rmpp_mad *rmpp_mad; | 190 | struct ib_rmpp_mad *rmpp_mad; |
192 | int ret; | 191 | int ret; |
193 | 192 | ||
194 | ret = alloc_response_msg(&agent->agent, recv_wc, &msg); | 193 | msg = alloc_response_msg(&agent->agent, recv_wc); |
195 | if (ret) | 194 | if (IS_ERR(msg)) |
196 | return; | 195 | return; |
197 | 196 | ||
198 | rmpp_mad = msg->mad; | 197 | rmpp_mad = msg->mad; |