From patchwork Sun Dec 25 18:49:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9488325 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 43167601D7 for ; Sun, 25 Dec 2016 18:49:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D945205B0 for ; Sun, 25 Dec 2016 18:49:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E97B25250; Sun, 25 Dec 2016 18:49:15 +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 742CE205B0 for ; Sun, 25 Dec 2016 18:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932547AbcLYStL (ORCPT ); Sun, 25 Dec 2016 13:49:11 -0500 Received: from mout.web.de ([212.227.15.3]:60017 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932254AbcLYStK (ORCPT ); Sun, 25 Dec 2016 13:49:10 -0500 Received: from [192.168.1.2] ([77.182.80.223]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MXYTG-1c0xRp0Ojm-00WYIp; Sun, 25 Dec 2016 19:49:03 +0100 Subject: [PATCH 16/19] [media] uvc_video: Adjust 18 checks for null pointers To: linux-media@vger.kernel.org, Laurent Pinchart , Mauro Carvalho Chehab References: <47aa4314-74ec-b2bf-ee3b-aad4d6e9f0a2@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Sun, 25 Dec 2016 19:49:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: <47aa4314-74ec-b2bf-ee3b-aad4d6e9f0a2@users.sourceforge.net> X-Provags-ID: V03:K0:aPYJBKVKIOe+NamMS35U6o1qrsSD5ULkUJUoQppb+hBLdYxjUo7 QpdnZeLRBxKRK9AZ3Fd7UiN7j9vaBFr3kB1SKscpfv2k5qlmDMkt2s9ZujZgRCx6ZjgnsjV w3Y0C+AVbRQHitnclgunkkRm+3Sw9BTQDtcIl8Dx3laI6wr63RPUZVXaRJb9T5S7UBe2pOL ubyCR1boYO4XZfp7zsVBQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:8PZDNUFJXVQ=:P+6fmRo+5GqnH2OW2WQesO nm0wgk7kOSggoQnhTqARSl5xxv350gx0VkRsbwDAVGFKwbRumR2xcHFm1CIL0WZMCVuzlUlyR 4UXNZgB60wReErWuItoVOEcICK3Mk17ppWi7F8GhZsk+O5JLXSH3ckMXU1tuhz2ZL5smNEjt/ gDZeSplAa1LczWfze2S2JOjMvAsPCOoBMY4bzwQuemtokgsci9wJjT1MkcGtWjR3KBHZJawHN VuPuE92nQrfvccQKOsIK4KZwAdsyFCL/Tz00QsVNrEe7M6/4uWQe/7bJMnzkqWUvvP+DDGRxX h3ZtwhUA7XnUMkzXySoer1FVwBrJbcZsNaANniRSkUounZf6F9i49fDReTQoVgM4t744HYeeL TQzdXcT+f3TaQPrZogjhfYiportibVlen/fur7zPWaBGs2vncbuK5t7QPx/9qsOVAJHvTx4pd IYcUCmFb1Fjy/INHmvTMn4KvLI3YABIGm1NJ/wHskIOwA83SaLQBhZindtUPm4XfPznc1BRCJ TAlWaiXGn/DVdR/9oiHvBQr9+kF43ulCX8buzX2rg9GDTJpYHQW94eCSiAtVV4xWPstW4weoz gmovdJ9PT2zJzYJ3BlGyaJkPjC4DeI3Scw8rfYm5gS7dLn0cUYontrZjNujnW/KMOemEWtmQL zsyvGKPXyiUNz3qHP7ZaMgC88aaErkvSa7bU1DSaKiIOA84aOZnSFezK4GJ17vt7dWfPRt2bO cWsfKsUwGg+KM/fnpjePry3bHOPwSubXDJLlVCmkZlnbxcKLvFHQLahF1HR18IbIS978OJkxV TtgjdNs 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: Sun, 25 Dec 2016 18:26:21 +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/media/usb/uvc/uvc_video.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index 0ed3453b1c75..617f2090aa55 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c @@ -100,7 +100,7 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, } } - if (format == NULL) + if (!format) return; for (i = 0; i < format->nframes; ++i) { @@ -110,7 +110,7 @@ static void uvc_fixup_video_ctrl(struct uvc_streaming *stream, } } - if (frame == NULL) + if (!frame) return; if (!(format->flags & UVC_FMT_FLAG_COMPRESSED) || @@ -176,7 +176,7 @@ static int uvc_get_video_ctrl(struct uvc_streaming *stream, return -EIO; data = kmalloc(size, GFP_KERNEL); - if (data == NULL) + if (!data) return -ENOMEM; ret = __uvc_query_ctrl(stream->dev, query, 0, stream->intfnum, @@ -260,7 +260,7 @@ static int uvc_set_video_ctrl(struct uvc_streaming *stream, size = stream->dev->uvc_version >= 0x0110 ? 34 : 26; data = kzalloc(size, GFP_KERNEL); - if (data == NULL) + if (!data) return -ENOMEM; *(__le16 *)&data[0] = cpu_to_le16(ctrl->bmHint); @@ -420,7 +420,7 @@ uvc_video_clock_decode(struct uvc_streaming *stream, struct uvc_buffer *buf, * kernel timestamps and store them with the SCR STC and SOF fields * in the ring buffer */ - if (has_pts && buf != NULL) + if (has_pts && buf) buf->pts = get_unaligned_le32(&data[2]); if (!has_scr) @@ -503,7 +503,7 @@ static int uvc_video_clock_init(struct uvc_streaming *stream) clock->samples = kmalloc_array(clock->size, sizeof(*clock->samples), GFP_KERNEL); - if (clock->samples == NULL) + if (!clock->samples) return -ENOMEM; uvc_video_clock_reset(stream); @@ -994,7 +994,7 @@ static int uvc_video_decode_start(struct uvc_streaming *stream, /* Store the payload FID bit and return immediately when the buffer is * NULL. */ - if (buf == NULL) { + if (!buf) { stream->last_fid = fid; return -ENODATA; } @@ -1169,7 +1169,7 @@ static void uvc_video_decode_isoc(struct urb *urb, struct uvc_streaming *stream, "USB isochronous frame lost (%d).\n", urb->iso_frame_desc[i].status); /* Mark the buffer as faulty. */ - if (buf != NULL) + if (buf) buf->error = 1; continue; } @@ -1233,7 +1233,7 @@ static void uvc_video_decode_bulk(struct urb *urb, struct uvc_streaming *stream, } while (ret == -EAGAIN); /* If an error occurred skip the rest of the payload. */ - if (ret < 0 || buf == NULL) { + if (ret < 0 || !buf) { stream->bulk.skip_payload = 1; } else { memcpy(stream->bulk.header, mem, ret); @@ -1250,7 +1250,7 @@ static void uvc_video_decode_bulk(struct urb *urb, struct uvc_streaming *stream, */ /* Process video data. */ - if (!stream->bulk.skip_payload && buf != NULL) + if (!stream->bulk.skip_payload && buf) uvc_video_decode_data(stream, buf, mem, len); /* Detect the payload end by a URB smaller than the maximum size (or @@ -1258,7 +1258,7 @@ static void uvc_video_decode_bulk(struct urb *urb, struct uvc_streaming *stream, */ if (urb->actual_length < urb->transfer_buffer_length || stream->bulk.payload_size >= stream->bulk.max_payload_size) { - if (!stream->bulk.skip_payload && buf != NULL) { + if (!stream->bulk.skip_payload && buf) { uvc_video_decode_end(stream, buf, stream->bulk.header, stream->bulk.payload_size); if (buf->state == UVC_BUF_STATE_READY) @@ -1278,7 +1278,7 @@ static void uvc_video_encode_bulk(struct urb *urb, struct uvc_streaming *stream, u8 *mem = urb->transfer_buffer; int len = stream->urb_size, ret; - if (buf == NULL) { + if (!buf) { urb->transfer_buffer_length = 0; return; } @@ -1450,7 +1450,7 @@ static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers) for (i = 0; i < UVC_URBS; ++i) { urb = stream->urb[i]; - if (urb == NULL) + if (!urb) continue; usb_kill_urb(urb); @@ -1511,7 +1511,7 @@ static int uvc_init_video_isoc(struct uvc_streaming *stream, for (i = 0; i < UVC_URBS; ++i) { urb = usb_alloc_urb(npackets, gfp_flags); - if (urb == NULL) { + if (!urb) { uvc_uninit_video(stream, 1); return -ENOMEM; } @@ -1577,7 +1577,7 @@ static int uvc_init_video_bulk(struct uvc_streaming *stream, for (i = 0; i < UVC_URBS; ++i) { urb = usb_alloc_urb(0, gfp_flags); - if (urb == NULL) { + if (!urb) { uvc_uninit_video(stream, 1); return -ENOMEM; } @@ -1641,7 +1641,7 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags) alts = &intf->altsetting[i]; ep = uvc_find_endpoint(alts, stream->header.bEndpointAddress); - if (ep == NULL) + if (!ep) continue; /* Check if the bandwidth is high enough. */ @@ -1653,7 +1653,7 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags) } } - if (best_ep == NULL) { + if (!best_ep) { uvc_trace(UVC_TRACE_VIDEO, "No fast enough alt setting for requested bandwidth.\n"); return -EIO; @@ -1671,7 +1671,7 @@ static int uvc_init_video(struct uvc_streaming *stream, gfp_t gfp_flags) /* Bulk endpoint, proceed to URB initialization. */ ep = uvc_find_endpoint(&intf->altsetting[0], stream->header.bEndpointAddress); - if (ep == NULL) + if (!ep) return -EIO; ret = uvc_init_video_bulk(stream, ep, gfp_flags);