Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

IB/usnic: simplify IS_ERR_OR_NULL to IS_ERR

The function usnic_ib_qp_grp_get_chunk only returns an ERR_PTR value or a
valid pointer, never NULL. The same is true of get_qp_res_chunk, which
just returns the result of calling usnic_ib_qp_grp_get_chunk. Simplify
IS_ERR_OR_NULL to IS_ERR in both cases.

The semantic patch that makes this change is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression t,e;
@@

t = \(usnic_ib_qp_grp_get_chunk(...)\|get_qp_res_chunk(...)\)
... when != t=e
- IS_ERR_OR_NULL(t)
+ IS_ERR(t)

@@
expression t,e,e1;
@@

t = \(usnic_ib_qp_grp_get_chunk(...)\|get_qp_res_chunk(...)\)
... when != t=e
?- t ? PTR_ERR(t) : e1
+ PTR_ERR(t)
... when any
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

Julia Lawall and committed by
Doug Ledford
5f4c7e4e 9315bc9a

+12 -12
+6 -6
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c
··· 117 117 vnic_idx = usnic_vnic_get_index(qp_grp->vf->vnic); 118 118 119 119 res_chunk = get_qp_res_chunk(qp_grp); 120 - if (IS_ERR_OR_NULL(res_chunk)) { 120 + if (IS_ERR(res_chunk)) { 121 121 usnic_err("Unable to get qp res with err %ld\n", 122 122 PTR_ERR(res_chunk)); 123 - return res_chunk ? PTR_ERR(res_chunk) : -ENOMEM; 123 + return PTR_ERR(res_chunk); 124 124 } 125 125 126 126 for (i = 0; i < res_chunk->cnt; i++) { ··· 158 158 vnic_idx = usnic_vnic_get_index(qp_grp->vf->vnic); 159 159 160 160 res_chunk = get_qp_res_chunk(qp_grp); 161 - if (IS_ERR_OR_NULL(res_chunk)) { 161 + if (IS_ERR(res_chunk)) { 162 162 usnic_err("Unable to get qp res with err %ld\n", 163 163 PTR_ERR(res_chunk)); 164 - return res_chunk ? PTR_ERR(res_chunk) : -ENOMEM; 164 + return PTR_ERR(res_chunk); 165 165 } 166 166 167 167 for (i = 0; i < res_chunk->cnt; i++) { ··· 186 186 struct usnic_vnic_res_chunk *res_chunk; 187 187 188 188 res_chunk = usnic_ib_qp_grp_get_chunk(qp_grp, USNIC_VNIC_RES_TYPE_RQ); 189 - if (IS_ERR_OR_NULL(res_chunk)) { 189 + if (IS_ERR(res_chunk)) { 190 190 usnic_err("Unable to get %s with err %ld\n", 191 191 usnic_vnic_res_type_to_str(USNIC_VNIC_RES_TYPE_RQ), 192 192 PTR_ERR(res_chunk)); 193 - return res_chunk ? PTR_ERR(res_chunk) : -ENOMEM; 193 + return PTR_ERR(res_chunk); 194 194 } 195 195 196 196 uaction->vnic_idx = usnic_vnic_get_index(qp_grp->vf->vnic);
+6 -6
drivers/infiniband/hw/usnic/usnic_ib_verbs.c
··· 87 87 resp.bar_len = bar->len; 88 88 89 89 chunk = usnic_ib_qp_grp_get_chunk(qp_grp, USNIC_VNIC_RES_TYPE_RQ); 90 - if (IS_ERR_OR_NULL(chunk)) { 90 + if (IS_ERR(chunk)) { 91 91 usnic_err("Failed to get chunk %s for qp_grp %d with err %ld\n", 92 92 usnic_vnic_res_type_to_str(USNIC_VNIC_RES_TYPE_RQ), 93 93 qp_grp->grp_id, 94 94 PTR_ERR(chunk)); 95 - return chunk ? PTR_ERR(chunk) : -ENOMEM; 95 + return PTR_ERR(chunk); 96 96 } 97 97 98 98 WARN_ON(chunk->type != USNIC_VNIC_RES_TYPE_RQ); ··· 101 101 resp.rq_idx[i] = chunk->res[i]->vnic_idx; 102 102 103 103 chunk = usnic_ib_qp_grp_get_chunk(qp_grp, USNIC_VNIC_RES_TYPE_WQ); 104 - if (IS_ERR_OR_NULL(chunk)) { 104 + if (IS_ERR(chunk)) { 105 105 usnic_err("Failed to get chunk %s for qp_grp %d with err %ld\n", 106 106 usnic_vnic_res_type_to_str(USNIC_VNIC_RES_TYPE_WQ), 107 107 qp_grp->grp_id, 108 108 PTR_ERR(chunk)); 109 - return chunk ? PTR_ERR(chunk) : -ENOMEM; 109 + return PTR_ERR(chunk); 110 110 } 111 111 112 112 WARN_ON(chunk->type != USNIC_VNIC_RES_TYPE_WQ); ··· 115 115 resp.wq_idx[i] = chunk->res[i]->vnic_idx; 116 116 117 117 chunk = usnic_ib_qp_grp_get_chunk(qp_grp, USNIC_VNIC_RES_TYPE_CQ); 118 - if (IS_ERR_OR_NULL(chunk)) { 118 + if (IS_ERR(chunk)) { 119 119 usnic_err("Failed to get chunk %s for qp_grp %d with err %ld\n", 120 120 usnic_vnic_res_type_to_str(USNIC_VNIC_RES_TYPE_CQ), 121 121 qp_grp->grp_id, 122 122 PTR_ERR(chunk)); 123 - return chunk ? PTR_ERR(chunk) : -ENOMEM; 123 + return PTR_ERR(chunk); 124 124 } 125 125 126 126 WARN_ON(chunk->type != USNIC_VNIC_RES_TYPE_CQ);