Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932463AbeAHMu6 (ORCPT + 1 other); Mon, 8 Jan 2018 07:50:58 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:51928 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932413AbeAHMu4 (ORCPT ); Mon, 8 Jan 2018 07:50:56 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 08 Jan 2018 13:50:55 +0100 From: haver To: SF Markus Elfring Cc: kernel-janitors@vger.kernel.org, Arnd Bergmann , Greg Kroah-Hartman , "Guilherme G. Piccoli" , LKML , =?UTF-8?Q?J=C3=B6rg-Stephan_Vogt?= , Michael Jung , =?UTF-8?Q?Michael_R=C3=BCttger?= Subject: Re: [PATCH 3/3] GenWQE: Adjust 12 checks for null pointers In-Reply-To: <49115f17-73f9-de03-d0cd-7a76c3c43dcc@users.sourceforge.net> References: <49115f17-73f9-de03-d0cd-7a76c3c43dcc@users.sourceforge.net> User-Agent: Roundcube Webmail/1.0.1 X-TM-AS-GCONF: 00 x-cbid: 18010812-0016-0000-0000-00000814AE88 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00008339; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000245; SDB=6.00972007; UDB=6.00492385; IPR=6.00751957; BA=6.00005767; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00018922; XFM=3.00000015; UTC=2018-01-08 12:50:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010812-0017-0000-0000-00003CF3FE29 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-08_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801080187 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: Hi Markus, On 2018-01-08 10:43, SF Markus Elfring wrote: > 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; > } I personally like the explicit compare (ptr != NULL) more than the !ptr notation. When was the checkpatch.pl script modified to suggest the latter notation? Is there any advantage other than the shorter notation? Regards Frank