From patchwork Mon Mar 6 17:42:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9607237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7BA2760414 for ; Mon, 6 Mar 2017 17:49:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 32DEE205A8 for ; Mon, 6 Mar 2017 17:49:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 261182766D; Mon, 6 Mar 2017 17:49:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 94E5E205A8 for ; Mon, 6 Mar 2017 17:49:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753532AbdCFRtf (ORCPT ); Mon, 6 Mar 2017 12:49:35 -0500 Received: from mout.web.de ([212.227.17.12]:51249 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753261AbdCFRte (ORCPT ); Mon, 6 Mar 2017 12:49:34 -0500 Received: from [192.168.1.2] ([78.48.114.236]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MGiUP-1cXUGK44Tx-00DZs4; Mon, 06 Mar 2017 18:42:46 +0100 Subject: [PATCH 3/5] IB/nes: Adjust 16 checks for null pointers To: linux-rdma@vger.kernel.org, Doug Ledford , Faisal Latif , Hal Rosenstock , Sean Hefty References: <502a5a6f-ee91-dd2f-cdc7-63f396059529@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <34a4575b-d8fd-755a-9eaa-5ba7bcec994f@users.sourceforge.net> Date: Mon, 6 Mar 2017 18:42:44 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <502a5a6f-ee91-dd2f-cdc7-63f396059529@users.sourceforge.net> X-Provags-ID: V03:K0:qL8C6Fn4AQEQQ8Uk+eEc/j/MY6RPbN32rq+Yii0P+tz2XBitsWJ q5bEpaBIg3UgZoKaONB6PmHPbSJqHFqHDumBPdZHff5mhaBjuFu1uZqMXXGAABbclHAfnzN HHTLC9xFpj0mLsgPVfGfdSOu0gByfb2Kzd4YnPiuJMkDQzs3Po+g6YJ/jg6pSwFpRMvrQq9 0Cye8RMgNN3HjZk33gB+A== X-UI-Out-Filterresults: notjunk:1; V01:K0:qifWX5NrgWA=:X8VkTekxZPR3RMBpFnr0X4 +2MB+3G9kQsIDwzPV3PfKzvxXxo7fRGS9+7fQLeObNdTXOeP92Gsr36SwpYvuWpLOqLW5V+1M rtWY2B1M//Nr7wE8zIcbAqjNBxGCCNKxbpSpOEzDWP422aSNr5wj8Jw2puWEY54u6cbwXXPiK UntW9XTfbHGYW6CXj3iNw3Sfu4KVyQ3eLNrln/+hF5PVkE0+AufAinMtVGLEa6Gg2RWTs9hoG 5OQ6QZAPW+Y9QcuUxlPqzjsYRZ7g2PfYTpB41KWdrvjtq6N0lzzqAHKALYIayQyR0+ktsnsbU A5kzGCZ10amBMigR2ZMzbhMtWquDyE1UjUAAHMHBSgSX+2kQPnCrtn3Dnezfxb8nNA4icy8tB tfaaB9L5jbT9+QOMPNzxkTDBpae3S+2hDDktBAMGiZUfaBCO0KDrZdp4Z8fyuNlfJuZHcZ9/3 vq3VL0xxhTwL6+Qh1ef1K+D5hv46yxI7ETmrTysFwUavUEqGO6U1r6jyRzSqzDICl60MnM6Ul HEhMl3VbePhSuUMjw9+wKUnBkrB0n8shscNpwnPpiYGcK2IC7h37Y4sDRvZoSSejHjVd/FKW8 fpnDFNlJ3da0sps650/IumUWrSmSWPv9ZVOMMb/eyrAOFPiZyRAV6aRAmOZBYcdnm1R+9CV7k Z8ESMlaq5RLN5aofFFZpQxClm7lEFw/XE0HfYVLliS1DqknGwD1wH3OzWQHxzzZwOWQ3FFcfk EwGPj8zmtVGYwfVTyV/vIAlJMXRLCTAW7xv9jwo+sqBtHNyN2bogZbg1l7IcNRU1mvHRxlJwX s1+D7zP Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 6 Mar 2017 16:54:03 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script "checkpatch.pl" pointed information out like the following. Comparison to NULL could be written !… Thus fix the affected source code places. Signed-off-by: Markus Elfring --- drivers/infiniband/hw/nes/nes_verbs.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index a28dfeaa1f45..f79ea50e3ab5 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c @@ -106,7 +106,7 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd, enum ib_mw_type type, /* Register the region with the adapter */ cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { kfree(nesmr); nes_free_resource(nesadapter, nesadapter->allocated_mrs, stag_index); return ERR_PTR(-ENOMEM); @@ -171,7 +171,7 @@ static int nes_dealloc_mw(struct ib_mw *ibmw) /* Deallocate the window with the adapter */ cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { nes_debug(NES_DBG_MR, "Failed to get a cqp_request.\n"); return -ENOMEM; } @@ -224,7 +224,7 @@ static int alloc_fast_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd, cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { nes_debug(NES_DBG_MR, "Failed to get a cqp_request.\n"); return -ENOMEM; } @@ -627,7 +627,7 @@ static int nes_mmap(struct ib_ucontext *context, struct vm_area_struct *vma) return -EFAULT; } nesqp = nes_ucontext->mmap_nesqp[index]; - if (nesqp == NULL) { + if (!nesqp) { nes_debug(NES_DBG_MMAP, "wq %lu has a NULL QP base.\n", index); return -EFAULT; } @@ -1228,7 +1228,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd, /* Create the QP */ cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { nes_debug(NES_DBG_QP, "Failed to get a cqp_request\n"); nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num); nes_free_qp_mem(nesdev, nesqp,virt_wqs); @@ -1539,7 +1539,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, /* send CreateCQ request to CQP */ cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { nes_debug(NES_DBG_CQ, "Failed to get a cqp_request.\n"); if (!context) pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, @@ -1697,7 +1697,7 @@ static int nes_destroy_cq(struct ib_cq *ib_cq) u32 opcode = 0; int ret; - if (ib_cq == NULL) + if (!ib_cq) return 0; nescq = to_nescq(ib_cq); @@ -1709,7 +1709,7 @@ static int nes_destroy_cq(struct ib_cq *ib_cq) /* Send DestroyCQ request to CQP */ cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { nes_debug(NES_DBG_CQ, "Failed to get a cqp_request.\n"); return -ENOMEM; } @@ -1788,8 +1788,7 @@ static u32 root_256(struct nes_device *nesdev, if (pbl_count_4k == 1) { new_root->pbl_vbase = pci_alloc_consistent(nesdev->pcidev, 512, &new_root->pbl_pbase); - - if (new_root->pbl_vbase == NULL) + if (!new_root->pbl_vbase) return 0; leaf_pbl = (u64)root_vpbl->pbl_pbase; @@ -1847,7 +1846,7 @@ static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd, /* Register the region with the adapter */ cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { nes_debug(NES_DBG_MR, "Failed to get a cqp_request.\n"); return -ENOMEM; } @@ -2509,7 +2508,7 @@ static int nes_dereg_mr(struct ib_mr *ib_mr) /* Deallocate the region with the adapter */ cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { nes_debug(NES_DBG_MR, "Failed to get a cqp_request.\n"); return -ENOMEM; } @@ -2673,7 +2672,7 @@ int nes_hw_modify_qp(struct nes_device *nesdev, struct nes_qp *nesqp, nesqp->hwqp.qp_id, atomic_read(&nesqp->refcount)); cqp_request = nes_get_cqp_request(nesdev); - if (cqp_request == NULL) { + if (!cqp_request) { nes_debug(NES_DBG_MOD_QP, "Failed to get a cqp_request.\n"); return -ENOMEM; } @@ -2793,7 +2792,7 @@ int nes_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, spin_unlock_irqrestore(&nesqp->lock, qplockflags); return -EINVAL; } - if (nesqp->cm_id == NULL) { + if (!nesqp->cm_id) { nes_debug(NES_DBG_MOD_QP, "QP%u: Failing attempt to move QP to RTS without a CM_ID. \n", nesqp->hwqp.qp_id ); spin_unlock_irqrestore(&nesqp->lock, qplockflags); @@ -3696,9 +3695,9 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev) struct nes_device *nesdev = nesvnic->nesdev; nesibdev = (struct nes_ib_device *)ib_alloc_device(sizeof(struct nes_ib_device)); - if (nesibdev == NULL) { + if (!nesibdev) return NULL; - } + strlcpy(nesibdev->ibdev.name, "nes%d", IB_DEVICE_NAME_MAX); nesibdev->ibdev.owner = THIS_MODULE; @@ -3772,7 +3771,7 @@ struct nes_ib_device *nes_init_ofa_device(struct net_device *netdev) nesibdev->ibdev.drain_rq = nes_drain_rq; nesibdev->ibdev.iwcm = kzalloc(sizeof(*nesibdev->ibdev.iwcm), GFP_KERNEL); - if (nesibdev->ibdev.iwcm == NULL) { + if (!nesibdev->ibdev.iwcm) { ib_dealloc_device(&nesibdev->ibdev); return NULL; } @@ -3844,7 +3843,7 @@ void nes_port_ibevent(struct nes_vnic *nesvnic) */ void nes_destroy_ofa_device(struct nes_ib_device *nesibdev) { - if (nesibdev == NULL) + if (!nesibdev) return; nes_unregister_ofa_device(nesibdev);