From patchwork Thu Sep 14 10:33:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9952703 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 7B2A460317 for ; Thu, 14 Sep 2017 10:34:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5AA9E28A2D for ; Thu, 14 Sep 2017 10:34:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E88E28E6C; Thu, 14 Sep 2017 10:34:04 +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 2F0EE28A2D for ; Thu, 14 Sep 2017 10:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751672AbdINKdt (ORCPT ); Thu, 14 Sep 2017 06:33:49 -0400 Received: from mout.web.de ([217.72.192.78]:64216 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751413AbdINKds (ORCPT ); Thu, 14 Sep 2017 06:33:48 -0400 Received: from [192.168.1.2] ([85.182.44.111]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MgO8g-1e66jf0PGI-00Nkky; Thu, 14 Sep 2017 12:33:37 +0200 Subject: [PATCH 3/8] [media] ttusb_dec: Improve a size determination in three functions From: SF Markus Elfring To: linux-media@vger.kernel.org, Arvind Yadav , Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab , Sakari Ailus Cc: LKML , kernel-janitors@vger.kernel.org References: <66b087d3-6dd3-1e1c-d33d-e34c9e2ffe25@users.sourceforge.net> Message-ID: Date: Thu, 14 Sep 2017 12:33:36 +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: <66b087d3-6dd3-1e1c-d33d-e34c9e2ffe25@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:Jk+Fg8gToxxmCHtNLwlk7z6R+URCp5uwwZrXLwBNDq8FmvXRDr8 /UFFhBWtvimyZcg7y4Vl2seS3tbthISh7jWtkV/Jh8OAfHxwjbjPWP9hpuvUmiprVnXw+uG gZ6qmjpHsY7352KkuxKAEPD1yVsOAYYH/Wew8NdjQ+4yGJ1oy7189QrTpL5GKQt9xHXZCrZ QITNW5eRcK/wQHfAKWPag== X-UI-Out-Filterresults: notjunk:1; V01:K0:kY3Fj3yffA0=:HXUIRi4jzUJnOlFdRT5LJ1 6/eG4hce7JzYI11eslN2coATmaDl21t4sqv0NraopQtM0IyzCt2mjmINmRumqGefXIPoeBW1G RubzmifWmRFgDVhoaCt1PD/r36B2jCp/c0W1LoNhIuBVBeI6MkndCgYVD8Tzu21eyqLfJw6wq 7xqUUNTA3pXNL3Z1UzHxRfKeFAxZbPn0/Apnm4icW8O6OHr1LmO259DWC+dIXnHMinR/BcaXJ FXNZkkckXAi5nXkHrgIEqrZpOiXNlGosrmeS5GQ+t6rGtOG3RMKYbKBFtTwMPyEJ9UjmPbv4O tML6qg+VM+OVlHK5+rBaUOuB1s+AfeBJ4rlO3TFC9+PZr3VW6pY6Y2Q4zVdzZYvCB4SBn7iyl itPRrogPCxbNLxgoFAaRP+Et3k8oUklT/fYefHDU+BuvZVjvK5qzwnU3kUHFB0puvJSr1u3NY 3Ak/o9UNIMp243c3knzo7fEJvSbur17W2j4YYx0kNcsmjokiB2VXbB8XGqOkyrATHno9lA+cc vEJiRYPVKZJSfCUhsBY7W5xaD8rixw5lS6vARjFVOh/mCzPp/KK2LFDp0K8zBn5IzLkVUDpsX +DRjRIHUi9oLZIOtNGDtCdDFDXJTR4KXn9WTKXhXiSDExMeNqzSet+B3BnR0hq3sdo3Azj+UB cGdr1ekny+Of5dFVb1Kopdi7VrDJ+Ti56om4il62D2D5hGETpoCAaJQd4jLcGd5PmejUMyhyp sNXcEgLY6A9va9kOYDX9ew/0RFq1qEF0nLoIdwgVKUyxgyAL9S5+twUQ3XmQBA3nmsHJjkkrR lsYWHWcSTgqWSvzRwk71ybh3o/htKi+oxAKuFB3rph5ZfIYHTQ= 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, 13 Sep 2017 19:56:38 +0200 * The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix a few source code places. * Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/media/usb/ttusb-dec/ttusb_dec.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c index 901cb221aad2..76070da3b7c7 100644 --- a/drivers/media/usb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c @@ -821,8 +821,8 @@ static void ttusb_dec_process_urb(struct urb *urb) b = urb->transfer_buffer + d->offset; length = d->actual_length; - if ((frame = kmalloc(sizeof(struct urb_frame), - GFP_ATOMIC))) { + frame = kmalloc(sizeof(*frame), GFP_ATOMIC); + if (frame) { unsigned long flags; memcpy(frame->data, b, length); @@ -1073,8 +1073,8 @@ static int ttusb_dec_start_sec_feed(struct dvb_demux_feed *dvbdmxfeed) if (!result) { if (c_length == 2) { - if (!(finfo = kmalloc(sizeof(struct filter_info), - GFP_ATOMIC))) + finfo = kmalloc(sizeof(*finfo), GFP_ATOMIC); + if (!finfo) return -ENOMEM; finfo->stream_id = c[1]; @@ -1658,7 +1658,8 @@ static int ttusb_dec_probe(struct usb_interface *intf, udev = interface_to_usbdev(intf); - if (!(dec = kzalloc(sizeof(struct ttusb_dec), GFP_KERNEL))) { + dec = kzalloc(sizeof(*dec), GFP_KERNEL); + if (!dec) { printk("%s: couldn't allocate memory.\n", __func__); return -ENOMEM; }