Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756431AbeAHJno (ORCPT + 1 other); Mon, 8 Jan 2018 04:43:44 -0500 Received: from mout.web.de ([212.227.15.3]:60375 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756194AbeAHJnk (ORCPT ); Mon, 8 Jan 2018 04:43:40 -0500 Subject: [PATCH 3/3] GenWQE: Adjust 12 checks for null pointers From: SF Markus Elfring To: kernel-janitors@vger.kernel.org, Arnd Bergmann , Frank Haverkamp , Greg Kroah-Hartman , "Guilherme G. Piccoli" Cc: LKML , =?UTF-8?Q?J=c3=b6rg-Stephan_Vogt?= , Michael Jung , =?UTF-8?Q?Michael_R=c3=bcttger?= References: Message-ID: <49115f17-73f9-de03-d0cd-7a76c3c43dcc@users.sourceforge.net> Date: Mon, 8 Jan 2018 10:43:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:OTFpGLVvs7gGUmbLlL1FEeN/+asqr3v5YXKEHm9x43Pp4yW5WcA vXPh/Y4kUQQijnaAxEnLt+YqEBMEI7zOqdPYCJhU6oGA68mRB/cLJU3GdGc7xvp2cMgscK4 TYGIR6qss7PdiMP5HTZKRKTNIgUjDiYn2DPefzFK50N98HCuvHnoddT2ES6a7NGQ6YIMcQH 9ZVODgFeAJfOEvTBmCmjA== X-UI-Out-Filterresults: notjunk:1;V01:K0:2MwsLNVOa/0=:OhLfjOhnTtIngazGTiXp/c dQf+tSoJFMn1Feh5FbmkjsxyAisSSQ0TCgW4SwGyFWNPFVgdehdh0FHTUnfdMbky0phnpg/e5 G32CLsnMXTMVnyk63Cz0QwImI0EEmsE3Bf9J2H7dGOCO4+RUiYrcGddPmDMOvqpSXIY8tGlkL 8KhtvLp9/IrneZdz6NtsEJQlE9dYS89fhecrgwS3WiFAvj6RJeY190IFLwyzgW4v/ZpVHRBjy IuVE7NK+vv2IpKA79N5yFZxLHtBeSY/sqJFOiWgqP9iGoDy2pegKywpzoVfdoSWU56PcqFqHn SlaXhhI3Yh9dSnWWTQET4IVeIawzOHLjKiO+veajiNys58dH3tl5/aEHsA1u23t++g+VOdOpR XyyfImuIZOsi0gssToyXgUp/bOZyX4Vb9D/W3+q6MhiyAwPnhEJOZPPPOmPqKSVNR83tq/FJz lDy4LLtUUIlPAJeYyekDpol1hRAkGtXr/h+Il+hYRJRMl6vBOw6yRfD+geISAiOpm1fJ6OrNF ouYeuXDN/JbkfZqgMDwlHuw3TJa98ZjnY45cvX8tMokhBpT1upGsRoqkD+4CZKW1JvmOaCErU Rg6507YmKs7z34jWM626PlJnrc1PKs/WC7UbD6BvizaqceErud56IMt5hnhO68u72F2JAtCOD gp8rU4Xn9ioDoxiuMHu3uaHr54bmnAoylDG8vFv4XzbLSkcDLOa7ahkw4dF58Ni2MBK5wYPVi oM1mS+U+z5j2zoUVM+tN9396zmcVWDkjN1xP12VQo/mFkKNCkOsxkZrhV2b+CE7j9DrNNdjm3 NPWAdxJ/gkxWL7RSTl3Snif139KXEzKK5Iyv06eLtv4tqkrixE= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Markus Elfring Date: Mon, 8 Jan 2018 10:21:25 +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/misc/genwqe/card_utils.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/misc/genwqe/card_utils.c b/drivers/misc/genwqe/card_utils.c index 0b466664c908..84408dc69020 100644 --- a/drivers/misc/genwqe/card_utils.c +++ b/drivers/misc/genwqe/card_utils.c @@ -58,7 +58,7 @@ int __genwqe_writeq(struct genwqe_dev *cd, u64 byte_offs, u64 val) if (cd->err_inject & GENWQE_INJECT_HARDWARE_FAILURE) return -EIO; - if (cd->mmio == NULL) + if (!cd->mmio) return -EIO; if (pci_channel_offline(pci_dev)) @@ -88,7 +88,7 @@ u64 __genwqe_readq(struct genwqe_dev *cd, u64 byte_offs) (byte_offs == IO_SLC_CFGREG_GFIR)) return 0x00000000ffff0000ull; - if (cd->mmio == NULL) + if (!cd->mmio) return 0xffffffffffffffffull; return be64_to_cpu((__force __be64)__raw_readq(cd->mmio + byte_offs)); @@ -109,7 +109,7 @@ int __genwqe_writel(struct genwqe_dev *cd, u64 byte_offs, u32 val) if (cd->err_inject & GENWQE_INJECT_HARDWARE_FAILURE) return -EIO; - if (cd->mmio == NULL) + if (!cd->mmio) return -EIO; if (pci_channel_offline(pci_dev)) @@ -131,7 +131,7 @@ u32 __genwqe_readl(struct genwqe_dev *cd, u64 byte_offs) if (cd->err_inject & GENWQE_INJECT_HARDWARE_FAILURE) return 0xffffffff; - if (cd->mmio == NULL) + if (!cd->mmio) return 0xffffffff; return be32_to_cpu((__force __be32)__raw_readl(cd->mmio + byte_offs)); @@ -227,7 +227,7 @@ void *__genwqe_alloc_consistent(struct genwqe_dev *cd, size_t size, void __genwqe_free_consistent(struct genwqe_dev *cd, size_t size, void *vaddr, dma_addr_t dma_handle) { - if (vaddr == NULL) + if (!vaddr) return; dma_free_coherent(&cd->pci_dev->dev, size, vaddr, dma_handle); @@ -323,7 +323,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, sgl->sgl = __genwqe_alloc_consistent(cd, sgl->sgl_size, &sgl->sgl_dma_addr); - if (sgl->sgl == NULL) { + if (!sgl->sgl) { dev_err(&pci_dev->dev, "[%s] err: no memory available!\n", __func__); return -ENOMEM; @@ -333,7 +333,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, if ((sgl->fpage_size != 0) && (sgl->fpage_size != PAGE_SIZE)) { sgl->fpage = __genwqe_alloc_consistent(cd, PAGE_SIZE, &sgl->fpage_dma_addr); - if (sgl->fpage == NULL) + if (!sgl->fpage) goto err_out; /* Sync with user memory */ @@ -346,7 +346,7 @@ int genwqe_alloc_sync_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, if (sgl->lpage_size != 0) { sgl->lpage = __genwqe_alloc_consistent(cd, PAGE_SIZE, &sgl->lpage_dma_addr); - if (sgl->lpage == NULL) + if (!sgl->lpage) goto err_out1; /* Sync with user memory */ @@ -406,15 +406,12 @@ int genwqe_setup_sgl(struct genwqe_dev *cd, struct genwqe_sgl *sgl, /* DMA mapping for requested page, offs, size */ size_to_map = min(size, PAGE_SIZE - map_offs); - if ((p == 0) && (sgl->fpage != NULL)) { + if (p == 0 && sgl->fpage) daddr = sgl->fpage_dma_addr + map_offs; - - } else if ((p == sgl->nr_pages - 1) && - (sgl->lpage != NULL)) { + else if ((p == sgl->nr_pages - 1) && sgl->lpage) daddr = sgl->lpage_dma_addr; - } else { + else daddr = dma_list[p] + map_offs; - } size -= size_to_map; map_offs = 0; @@ -538,7 +535,7 @@ static int genwqe_free_user_pages(struct page **page_list, unsigned int i; for (i = 0; i < nr_pages; i++) { - if (page_list[i] != NULL) { + if (page_list[i]) { if (dirty) set_page_dirty_lock(page_list[i]); put_page(page_list[i]); @@ -577,7 +574,7 @@ int genwqe_user_vmap(struct genwqe_dev *cd, struct dma_mapping *m, void *uaddr, unsigned long data, offs; struct pci_dev *pci_dev = cd->pci_dev; - if ((uaddr == NULL) || (size == 0)) { + if (!uaddr || size == 0) { m->size = 0; /* mark unused and not added */ return -EINVAL; } -- 2.15.1