From patchwork Wed Sep 20 16:58:56 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: 9961867 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 DF4CE60234 for ; Wed, 20 Sep 2017 16:59:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFA36291B3 for ; Wed, 20 Sep 2017 16:59:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4646291B6; Wed, 20 Sep 2017 16:59: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 67CB9291B3 for ; Wed, 20 Sep 2017 16:59:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751786AbdITQ7J (ORCPT ); Wed, 20 Sep 2017 12:59:09 -0400 Received: from mout.web.de ([212.227.15.4]:62827 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751001AbdITQ7H (ORCPT ); Wed, 20 Sep 2017 12:59:07 -0400 Received: from [192.168.1.2] ([77.181.108.184]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MVtqS-1dsajJ24Uq-00X0UC; Wed, 20 Sep 2017 18:58:57 +0200 Subject: [PATCH 2/5] [media] s2255drv: Adjust 13 checks for null pointers From: SF Markus Elfring To: linux-media@vger.kernel.org, Arvind Yadav , Bhumika Goyal , Laurent Pinchart , Mauro Carvalho Chehab , Mike Isely , Sakari Ailus Cc: LKML , kernel-janitors@vger.kernel.org References: <55718a41-d76f-36bf-7197-db92014dcd3c@users.sourceforge.net> Message-ID: <66f0b95e-e717-7a50-39d2-05fcbf7b77bd@users.sourceforge.net> Date: Wed, 20 Sep 2017 18:58:56 +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: <55718a41-d76f-36bf-7197-db92014dcd3c@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:B/6qCNfyoRvvHrun4CzFQ/zY2eGtX0ADoV27sIKTXm+HqzFLHZB FdndkaqBevNa090ulSCiwij/rsmadHy6AbfCvU+KpC3NjNGA4BGfkDNMEXy5KvzM/d4b3vd aSYpvzf2weAxjdNthxx1PmnnznmSTdVEISTpgx+wXIT+uriPnKs1SIP4o24o3N7IrOJOZX/ tCXwPXKRMGxtBeHeJ8fHw== X-UI-Out-Filterresults: notjunk:1; V01:K0:fJ0OgeJDylI=:hfkYV6fZjdtaGl97wP7M5W JnCqf/pf02wxCGnDeFSOmgJsuZB0XfLKz4uT8owAvVOkbutKukZKbjMR1PBW5C87eY2KF1TtY nK0f1EWMqD38akvPXoPboPCddOBOeKT/gXkjJq5gUiKFC7fJOsLn19wPAToeg2dCG9G1ghKvr GrF4BPd8wcMEEQQdE6JHc68euHbtPmXUKsUhRH/m7PchARRIk0re+VTb94TTiPJ7ooa/e8PGi VaH6zMEDzPFjSQHgtPwNFtPgbzXdfU6n2+hxtMmsn/Hkl4gfen943lozzYRJXsshAVAVabMdH +pRxNoOH7s9cGouewcH1xliyIE0MV2B0h4Giu7fCFtmMeHb/49XrzJQM0mv2q89z+MNCAcynJ Fj1c1M5MW42bCNJrPcKeK8Y6abEIpiM6N5rm0vuyz/1Lds7L2kN6VyiqQRqVaLmp8/Z9TLki1 L7aeV+IMrTLkUVfhdWkrHSHpxl75XHmShew5dIbphgfHdKDxewsgupPdmyomBBKimRDt/aCD8 pbyosme5DF7gmwQ7SERnpge+cgKfe/yUB0SDRPzptH9N9cZV16bvBkqii+CUWxSrXc2WM4o+j Dhrrqc+c7KIV1Fg8R+p6bYA6ik3JHntzPGMcTB4vFoUjkIxi6aWGl+faMHObMMVPEXI++V3T7 jxzJ/tJRXbCnSD5uTAtTCAEKxqJ5IB8cEYrVUZDXm+l40SORHWCn1y2TGqgkmYxFvzcpzvdUw DXDGU5Wg/r4hBxNfYGtJzJlG6w9CAnQmZ02AzAHOPzxucPnZ6xg3xgD0wUXt7SCCkWM4p5/dF uqtPg91u6FqIY5Iic9CNKrQMj7TzFj2TdiFv2IojfjKEpDDmh8= 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: Wed, 20 Sep 2017 16:46:19 +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/s2255/s2255drv.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/media/usb/s2255/s2255drv.c b/drivers/media/usb/s2255/s2255drv.c index 29285e8cd742..aee83bf6fa94 100644 --- a/drivers/media/usb/s2255/s2255drv.c +++ b/drivers/media/usb/s2255/s2255drv.c @@ -516,6 +516,6 @@ static void s2255_fwchunk_complete(struct urb *urb) wake_up(&data->wait_fw); return; } - if (data->fw_urb == NULL) { + if (!data->fw_urb) { s2255_dev_err(&udev->dev, "disconnected\n"); atomic_set(&data->fw_state, S2255_FW_FAILED); @@ -680,5 +680,5 @@ static int buffer_prepare(struct vb2_buffer *vb) dprintk(vc->dev, 4, "%s\n", __func__); - if (vc->fmt == NULL) + if (!vc->fmt) return -EINVAL; if ((w < norm_minw(vc)) || @@ -785,6 +785,5 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, fmt = format_by_fourcc(f->fmt.pix.pixelformat); - - if (fmt == NULL) + if (!fmt) return -EINVAL; field = f->fmt.pix.field; @@ -853,6 +852,5 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, fmt = format_by_fourcc(f->fmt.pix.pixelformat); - - if (fmt == NULL) + if (!fmt) return -EINVAL; if (vb2_is_busy(q)) { @@ -936,6 +934,6 @@ static u32 get_transfer_size(struct s2255_mode *mode) unsigned int mask_mult; - if (mode == NULL) + if (!mode) return 0; if (mode->format == FORMAT_NTSC) { @@ -1390,4 +1388,4 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, fmt = format_by_fourcc(fe->pixel_format); - if (fmt == NULL) + if (!fmt) return -EINVAL; fe->type = V4L2_FRMSIZE_TYPE_DISCRETE; @@ -1412,5 +1410,5 @@ static int vidioc_enum_frameintervals(struct file *file, void *priv, fmt = format_by_fourcc(fe->pixel_format); - if (fmt == NULL) + if (!fmt) return -EINVAL; sizes = is_ntsc ? ntsc_sizes : pal_sizes; @@ -1834,6 +1832,5 @@ static int save_frame(struct s2255_dev *dev, struct s2255_pipeinfo *pipe_info) psrc = (u8 *)pipe_info->transfer_buffer + offset; - - if (frm->lpvbits == NULL) { + if (!frm->lpvbits) { dprintk(dev, 1, "s2255 frame buffer == NULL.%p %p %d %d", frm, dev, dev->cc, idx); @@ -1965,6 +1962,6 @@ static int s2255_create_sys_buffers(struct s2255_vc *vc) vc->buffer.frame[i].lpvbits = vmalloc(reqsize); vc->buffer.frame[i].size = reqsize; - if (vc->buffer.frame[i].lpvbits == NULL) { + if (!vc->buffer.frame[i].lpvbits) { pr_info("out of memory. using less frames\n"); vc->buffer.dwFrames = i; break; @@ -2007,6 +2004,6 @@ static int s2255_board_init(struct s2255_dev *dev) pipe->transfer_buffer = kzalloc(pipe->max_transfer_size, GFP_KERNEL); - if (pipe->transfer_buffer == NULL) { + if (!pipe->transfer_buffer) { dprintk(dev, 1, "out of memory!\n"); return -ENOMEM; } @@ -2068,8 +2065,8 @@ static void read_pipe_completion(struct urb *purb) pipe_info = purb->context; - if (pipe_info == NULL) { + if (!pipe_info) { dev_err(&purb->dev->dev, "no context!\n"); return; } dev = pipe_info->dev; - if (dev == NULL) { + if (!dev) { dev_err(&purb->dev->dev, "no context!\n"); @@ -2257,5 +2254,5 @@ static int s2255_probe(struct usb_interface *interface, dev->udev = usb_get_dev(interface_to_usbdev(interface)); - if (dev->udev == NULL) { + if (!dev->udev) { dev_err(&interface->dev, "null usb device\n"); retval = -ENODEV; goto errorUDEV;