]> git.karo-electronics.de Git - linux-beck.git/commitdiff
IB/usnic: simplify IS_ERR_OR_NULL to IS_ERR
authorJulia Lawall <Julia.Lawall@lip6.fr>
Fri, 11 Nov 2016 19:04:26 +0000 (20:04 +0100)
committerDoug Ledford <dledford@redhat.com>
Wed, 14 Dec 2016 17:57:54 +0000 (12:57 -0500)
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>
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c
drivers/infiniband/hw/usnic/usnic_ib_verbs.c

index 5b0248adf4ce661a3088673afa3683cf486130e4..2b1a3819627f8b71133ab834f9ed4ced0da27122 100644 (file)
@@ -117,10 +117,10 @@ static int enable_qp_grp(struct usnic_ib_qp_grp *qp_grp)
        vnic_idx = usnic_vnic_get_index(qp_grp->vf->vnic);
 
        res_chunk = get_qp_res_chunk(qp_grp);
-       if (IS_ERR_OR_NULL(res_chunk)) {
+       if (IS_ERR(res_chunk)) {
                usnic_err("Unable to get qp res with err %ld\n",
                                PTR_ERR(res_chunk));
-               return res_chunk ? PTR_ERR(res_chunk) : -ENOMEM;
+               return PTR_ERR(res_chunk);
        }
 
        for (i = 0; i < res_chunk->cnt; i++) {
@@ -158,10 +158,10 @@ static int disable_qp_grp(struct usnic_ib_qp_grp *qp_grp)
        vnic_idx = usnic_vnic_get_index(qp_grp->vf->vnic);
 
        res_chunk = get_qp_res_chunk(qp_grp);
-       if (IS_ERR_OR_NULL(res_chunk)) {
+       if (IS_ERR(res_chunk)) {
                usnic_err("Unable to get qp res with err %ld\n",
                        PTR_ERR(res_chunk));
-               return res_chunk ? PTR_ERR(res_chunk) : -ENOMEM;
+               return PTR_ERR(res_chunk);
        }
 
        for (i = 0; i < res_chunk->cnt; i++) {
@@ -186,11 +186,11 @@ static int init_filter_action(struct usnic_ib_qp_grp *qp_grp,
        struct usnic_vnic_res_chunk *res_chunk;
 
        res_chunk = usnic_ib_qp_grp_get_chunk(qp_grp, USNIC_VNIC_RES_TYPE_RQ);
-       if (IS_ERR_OR_NULL(res_chunk)) {
+       if (IS_ERR(res_chunk)) {
                usnic_err("Unable to get %s with err %ld\n",
                        usnic_vnic_res_type_to_str(USNIC_VNIC_RES_TYPE_RQ),
                        PTR_ERR(res_chunk));
-               return res_chunk ? PTR_ERR(res_chunk) : -ENOMEM;
+               return PTR_ERR(res_chunk);
        }
 
        uaction->vnic_idx = usnic_vnic_get_index(qp_grp->vf->vnic);
index a5bfbba6bbac0e9d918462ebb37d041608b9d321..79766db1dc6cde9e4902dafaa9fc4942e034f73d 100644 (file)
@@ -87,12 +87,12 @@ static int usnic_ib_fill_create_qp_resp(struct usnic_ib_qp_grp *qp_grp,
        resp.bar_len = bar->len;
 
        chunk = usnic_ib_qp_grp_get_chunk(qp_grp, USNIC_VNIC_RES_TYPE_RQ);
-       if (IS_ERR_OR_NULL(chunk)) {
+       if (IS_ERR(chunk)) {
                usnic_err("Failed to get chunk %s for qp_grp %d with err %ld\n",
                        usnic_vnic_res_type_to_str(USNIC_VNIC_RES_TYPE_RQ),
                        qp_grp->grp_id,
                        PTR_ERR(chunk));
-               return chunk ? PTR_ERR(chunk) : -ENOMEM;
+               return PTR_ERR(chunk);
        }
 
        WARN_ON(chunk->type != USNIC_VNIC_RES_TYPE_RQ);
@@ -101,12 +101,12 @@ static int usnic_ib_fill_create_qp_resp(struct usnic_ib_qp_grp *qp_grp,
                resp.rq_idx[i] = chunk->res[i]->vnic_idx;
 
        chunk = usnic_ib_qp_grp_get_chunk(qp_grp, USNIC_VNIC_RES_TYPE_WQ);
-       if (IS_ERR_OR_NULL(chunk)) {
+       if (IS_ERR(chunk)) {
                usnic_err("Failed to get chunk %s for qp_grp %d with err %ld\n",
                        usnic_vnic_res_type_to_str(USNIC_VNIC_RES_TYPE_WQ),
                        qp_grp->grp_id,
                        PTR_ERR(chunk));
-               return chunk ? PTR_ERR(chunk) : -ENOMEM;
+               return PTR_ERR(chunk);
        }
 
        WARN_ON(chunk->type != USNIC_VNIC_RES_TYPE_WQ);
@@ -115,12 +115,12 @@ static int usnic_ib_fill_create_qp_resp(struct usnic_ib_qp_grp *qp_grp,
                resp.wq_idx[i] = chunk->res[i]->vnic_idx;
 
        chunk = usnic_ib_qp_grp_get_chunk(qp_grp, USNIC_VNIC_RES_TYPE_CQ);
-       if (IS_ERR_OR_NULL(chunk)) {
+       if (IS_ERR(chunk)) {
                usnic_err("Failed to get chunk %s for qp_grp %d with err %ld\n",
                        usnic_vnic_res_type_to_str(USNIC_VNIC_RES_TYPE_CQ),
                        qp_grp->grp_id,
                        PTR_ERR(chunk));
-               return chunk ? PTR_ERR(chunk) : -ENOMEM;
+               return PTR_ERR(chunk);
        }
 
        WARN_ON(chunk->type != USNIC_VNIC_RES_TYPE_CQ);