[PATCH 2/16] drivers/infiniband/hw/cxgb4: Remove unnecessary errorcode assignment

From: Julia Lawall
Date: Mon Aug 16 2010 - 12:25:11 EST


From: Julia Lawall <julia@xxxxxxx>

This code initializes ret to -ENOMEM, but actually ret is not used in the
code starting at err7, and -ENOMEM is always returned in this case, so the
initialization of ret is unnecessary.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
local idexpression x;
constant C;
@@

if (...) { ...
x = -C
... when != x
(
return <+...x...+>;
|
return NULL;
|
return;
|
* return ...;
)
}
// </smpl>

Signed-off-by: Julia Lawall <julia@xxxxxxx>

---
drivers/infiniband/hw/cxgb4/qp.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c
index 93f6e5b..73e00ed 100644
--- a/drivers/infiniband/hw/cxgb4/qp.c
+++ b/drivers/infiniband/hw/cxgb4/qp.c
@@ -130,11 +130,9 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
/* build fw_ri_res_wr */
wr_len = sizeof *res_wr + 2 * sizeof *res;

- skb = alloc_skb(wr_len, GFP_KERNEL);
- if (!skb) {
- ret = -ENOMEM;
+ skb = alloc_skb(wr_len, GFP_KERNEL | __GFP_NOFAIL);
+ if (!skb)
goto err7;
- }
set_wr_txq(skb, CPL_PRIORITY_CONTROL, 0);

res_wr = (struct fw_ri_res_wr *)__skb_put(skb, wr_len);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/