From patchwork Tue Aug 29 05:34:01 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: 9926759 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 6370260380 for ; Tue, 29 Aug 2017 05:34:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B6DA287D6 for ; Tue, 29 Aug 2017 05:34:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5085A287E2; Tue, 29 Aug 2017 05:34:23 +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=unavailable 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 E587F287D6 for ; Tue, 29 Aug 2017 05:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751237AbdH2FeJ (ORCPT ); Tue, 29 Aug 2017 01:34:09 -0400 Received: from mout.web.de ([212.227.15.14]:50274 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751215AbdH2FeI (ORCPT ); Tue, 29 Aug 2017 01:34:08 -0400 Received: from [192.168.1.2] ([77.181.80.150]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lxf5f-1dTKQj1rwZ-017ApA; Tue, 29 Aug 2017 07:34:02 +0200 Subject: [PATCH 3/4] [media] zr364xx: Adjust ten checks for null pointers From: SF Markus Elfring To: linux-media@vger.kernel.org, linux-usb@vger.kernel.org, Antoine Jacquet , Mauro Carvalho Chehab Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <8a949a7b-f42a-f875-d4d7-4e0bc1f39102@users.sourceforge.net> Date: Tue, 29 Aug 2017 07:34:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:qR0y4e5VIf5QOvm9/m5kYBlSJrpbaooGTp5MCz5AzoH5qjMfo2B 0dfGCLS+8iGWzOf+RDsgSIVk14x8hzBrvmZeQUC8+gwo7NBQZpQI32D46391tC+Ceu6JjGe uC/9yorDF97B8r5ejvL/QxSiivjgsLu2LH3MAzkGsskEJNal0+WCrVWPhj2r8QI7NEb3vAN 6KUYvc5VPHj3BfA4XjYhA== X-UI-Out-Filterresults: notjunk:1; V01:K0:jyOrt+SsLfE=:XoEWS6w27DhKdUydn6gAXc UEP3zmtjXL+gzsmwV2MVnoU/s649vQA4nLgRTMQUfr+zp/nbLRUvOg5ZA54/5HXexR8sAeKZz Whnw0xcR+9UiOxEyKboGC1RHO1JKNFqialncb2JFkRtBJlch5iB/reUzavFPefUH5vBXpHxQK pMSA/0Rhuw8NCBT7GsUXdwlfqr+JVBtmyHtVzcLmYXxAz/RnvVOqSOheuzkTPAKAaqeevcVDi 5mgKgzdDUlhsEE3SzO0TJX3gcVFv7Z+rnHFXh8AGpdGapUyyrMXViK6aHYz814U3o4Ybw/yO3 T2w7/l7B724KKZQbSvkbpW1xWZLq7dYU29OGBwd+A88qrHc6Rm/lpcqrY3RFRheGXRjh1vynq ZcWiY4WPmzPuAUENf4WKuyYYSy5nlhQsNspqgbIEvVSvn2u0SH2rH05aoqLEbJkjIRpatVZgZ lHZ06DehIWExS1SnL+OnNMa7RY/6QUClf+LDR1uVrjgdImLWRcdBXFDOwh0RVS0ZeqJei1T6g 5ls4uWgv7jxivXWoaQB40JqHJXiEvcTzfbB+MOkE9w6zxQvzkFjE+1OBCLSyfqsju51EjsezD 1eXCwjd4pDETV8HYdkyDWrF0h9z1Ai9I9IFQhDcyUlte65JP1jbGW3yJfCzZ70q3r+ZeETuRa dPYl1edORZra9MPMWetV9F5bZWs8358/bumBJ2ZdqYzVGa9abb3mFAEd3PTGQMr1zPfsHHHzP 2xfTpatDl5Vlu0gi8WyagM6PdXfXFeCCdpY2KV342SEl+P1mY4kmDMo1J9ywd5hm0QecR0hX8 X31C2/SWO8YQkyurdXlp93CyHwiqYhvjAq1xlwz1iGydrCn1jc= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 28 Aug 2017 22:40:47 +0200 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/media/usb/zr364xx/zr364xx.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/media/usb/zr364xx/zr364xx.c b/drivers/media/usb/zr364xx/zr364xx.c index 37cd6e20e68a..4cc6d2a9d91f 100644 --- a/drivers/media/usb/zr364xx/zr364xx.c +++ b/drivers/media/usb/zr364xx/zr364xx.c @@ -385,9 +385,9 @@ static int buffer_prepare(struct videobuf_queue *vq, struct videobuf_buffer *vb, vb); int rc; - DBG("%s, field=%d, fmt name = %s\n", __func__, field, cam->fmt != NULL ? - cam->fmt->name : ""); - if (cam->fmt == NULL) + DBG("%s, field=%d, fmt name = %s\n", __func__, field, + cam->fmt ? cam->fmt->name : ""); + if (!cam->fmt) return -EINVAL; buf->vb.size = cam->width * cam->height * (cam->fmt->depth >> 3); @@ -787,7 +787,7 @@ static int zr364xx_vidioc_try_fmt_vid_cap(struct file *file, void *priv, struct zr364xx_camera *cam = video_drvdata(file); char pixelformat_name[5]; - if (cam == NULL) + if (!cam) return -ENODEV; if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) { @@ -817,7 +817,7 @@ static int zr364xx_vidioc_g_fmt_vid_cap(struct file *file, void *priv, { struct zr364xx_camera *cam; - if (file == NULL) + if (!file) return -ENODEV; cam = video_drvdata(file); @@ -979,13 +979,13 @@ static void read_pipe_completion(struct urb *purb) pipe_info = purb->context; _DBG("%s %p, status %d\n", __func__, purb, purb->status); - if (pipe_info == NULL) { + if (!pipe_info) { printk(KERN_ERR KBUILD_MODNAME ": no context!\n"); return; } cam = pipe_info->cam; - if (cam == NULL) { + if (!cam) { printk(KERN_ERR KBUILD_MODNAME ": no context!\n"); return; } @@ -1069,7 +1069,7 @@ static void zr364xx_stop_readpipe(struct zr364xx_camera *cam) { struct zr364xx_pipeinfo *pipe_info; - if (cam == NULL) { + if (!cam) { printk(KERN_ERR KBUILD_MODNAME ": invalid device\n"); return; } @@ -1273,7 +1273,7 @@ static int zr364xx_mmap(struct file *file, struct vm_area_struct *vma) struct zr364xx_camera *cam = video_drvdata(file); int ret; - if (cam == NULL) { + if (!cam) { DBG("%s: cam == NULL\n", __func__); return -ENODEV; } @@ -1357,7 +1357,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam) pipe->transfer_buffer = kzalloc(pipe->transfer_size, GFP_KERNEL); - if (pipe->transfer_buffer == NULL) { + if (!pipe->transfer_buffer) { DBG("out of memory!\n"); return -ENOMEM; } @@ -1373,7 +1373,7 @@ static int zr364xx_board_init(struct zr364xx_camera *cam) DBG("valloc %p, idx %lu, pdata %p\n", &cam->buffer.frame[i], i, cam->buffer.frame[i].lpvbits); - if (cam->buffer.frame[i].lpvbits == NULL) { + if (!cam->buffer.frame[i].lpvbits) { printk(KERN_INFO KBUILD_MODNAME ": out of memory. Using less frames\n"); break; }