Skip to contentSkip to conversation

drivers/infiniband/core: Use an IS_ERR test rather than a NULL test

PATCH In review Julien Brunel 2 participants 2 messages Aug 7, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers/infiniband/core: Use an IS_ERR test rather than a NULL test

From: Julien Brunel <[email protected]>

In case of error, the function ib_create_send_mad returns an ERR pointer, but never returns a NULL pointer. So after a call to this function, a NULL test should be replaced by an IS_ERR test.

A simplified version of the semantic patch that makes this change is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@correct_null_test@
expression x,E;
statement S1, S2;
@@
x = ib_create_send_mad(...)
<... when != x = E
if (
(
- x@p2 != NULL
+ ! IS_ERR ( x )
|
- x@p2 = NULL
+ IS_ERR( x )
)
)
S1
else S2
...>
? x = E;
// </smpl>

---
 drivers/infiniband/core/mad_rmpp.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff -u -p a/drivers/infiniband/core/mad_rmpp.c
b/drivers/infiniband/core/mad_rmpp.c

drivers/infiniband/core/mad_rmpp.c +1 -1
@@ -133,7 +133,7 @@ static void ack_recv(struct mad_rmpp_rec
 	msg = ib_create_send_mad(&rmpp_recv->agent->agent, recv_wc->wc->src_qp,
 				 recv_wc->wc->pkey_index, 1, hdr_len,
 				 0, GFP_KERNEL);
-	if (!msg)
+	if (IS_ERR(msg))
 		return;
 
 	format_ack(msg, (struct ib_rmpp_mad *) recv_wc->recv_buf.mad, rmpp_recv);