From patchwork Wed Sep 20 19:12:39 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: 9962161 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 3732D60234 for ; Wed, 20 Sep 2017 19:13:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A8F428B40 for ; Wed, 20 Sep 2017 19:13:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F67A29113; Wed, 20 Sep 2017 19:13:16 +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 B491928B40 for ; Wed, 20 Sep 2017 19:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751710AbdITTNA (ORCPT ); Wed, 20 Sep 2017 15:13:00 -0400 Received: from mout.web.de ([212.227.15.4]:58242 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751851AbdITTM6 (ORCPT ); Wed, 20 Sep 2017 15:12:58 -0400 Received: from [192.168.1.2] ([77.181.108.184]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MGzFy-1e7Lbe22wk-00Dp2r; Wed, 20 Sep 2017 21:12:40 +0200 Subject: [PATCH 2/3] [media] dvb-ttusb-budget: Improve two size determinations in ttusb_probe() From: SF Markus Elfring To: linux-media@vger.kernel.org, Arvind Yadav , "Gustavo A. R. Silva" , Hans Verkuil , Mauro Carvalho Chehab Cc: LKML , kernel-janitors@vger.kernel.org References: <1ad3c3ce-3738-fee1-2ee5-37142fa1bc70@users.sourceforge.net> Message-ID: <404d5faa-432b-9649-4b9e-f0cdf1c18338@users.sourceforge.net> Date: Wed, 20 Sep 2017 21:12:39 +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: <1ad3c3ce-3738-fee1-2ee5-37142fa1bc70@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:4VQL2lix8eS3G4Dkc+5l4uU0FwLvVw13A1/mBwrRwZ5ouEbU6gA dp1vfdiWBgDkRJBll03pwf+71fN8/sKKCHLAsrMAxOq/gXqyfMxBdmVtVTraSenuwPu9uIW YIrUplysCVGgxMz4Z5GHBELLcbq2/rncZbV63Ej7Vf18M8SYpDf2pe6Xcsl/MWoAnZvx4Re wLWGuOPDJ+ZkepTLxO2YQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:O7aQzZBd/u8=:Mhk90+M4NVBcUHDtRilW0X Bc9FaCPfFo5aMGqVJOvd2RE2BzxALuEjaBoYSUg0xG4z4BHkPahID9LANIxBC31IPU4RgVS8w /UbjaT2B8+/uQu/aLwNdUn6frCUg/RXxUHL5bYztPAbCFYHfvouLt2C+Cv8FjV2/xQ4XY8dBn /BBIY1J1E0/agdSsUJ7AhPlXAEZFg+hCr93eBox9Jf3ACDiKxrJia7M+5Y0faZNwWvMqO7EZj T38Y7ewJpKugHqvbuWoD9LOc2ZCVX+bQkBehDbeqjFwXDtjG96HTRRFTENFO0PBmiZOsd3sKg 0QiG5sPyva6aAMjldMX0/QLlBpwmayO0cs9jKk7aHutlQYMoHX3c+eDRKg4hfAyTvoLN3boxJ I/U4imbQWjlTmo1t5OInYB9IOreRoi2F3906lBnH2ydhW1GL7+0D11o76zrT6008cFBsV2WGE NndJjTpum/EAwVaM+P37O6arNNT0zXpNVAL5GMF6d5xKc7Hou9+e/ktcrY9rXelRvOw7csv8+ hqiIjmlQnQfz5ut6XgTW130JDDEpUMYwtg0eQe+2tv+ij7bCZjQThHtM9LL3a7v0LvCJ5oBiO OxRDUvi6v/suM/T9cutT0P1/XD0tOMkgnCDWOxt6YWxPyVKossG5S8nS9Xo+lcFZZW5LtE2mZ IBu8uaVFN6YjFt0BapLfHdtodUEDwYEgGaJX3ti0MjxVyjFomUqbvADTnEZOL/suMuZfd5Pxy mWnDurtWv+AGBtk7HZK5oFsF57D3LHHOvC59ACOw7B8Nvie7odFg8y9h04ueUVWzEYgUitVyO 9RN75Fbb4oOXCtalRUBP5O8LVJ6+F2507krbtZ4UMb2fsIlw18= 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 20:46:11 +0200 * The script "checkpatch.pl" pointed information out like the following. ERROR: do not use assignment in if condition Thus fix an affected source code place. * Replace the specification of data structures by variable references 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-budget/dvb-ttusb-budget.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c index 38394c9ecc67..fef3c8554e91 100644 --- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c @@ -1657,7 +1657,8 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i if (intf->altsetting->desc.bInterfaceNumber != 1) return -ENODEV; - if (!(ttusb = kzalloc(sizeof(struct ttusb), GFP_KERNEL))) + ttusb = kzalloc(sizeof(*ttusb), GFP_KERNEL); + if (!ttusb) return -ENOMEM; ttusb->dev = udev; @@ -1692,7 +1693,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i ttusb->adapter.priv = ttusb; /* i2c */ - memset(&ttusb->i2c_adap, 0, sizeof(struct i2c_adapter)); + memset(&ttusb->i2c_adap, 0, sizeof(ttusb->i2c_adap)); strcpy(ttusb->i2c_adap.name, "TTUSB DEC"); i2c_set_adapdata(&ttusb->i2c_adap, ttusb);