From patchwork Thu Jan 25 18:53:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 10184657 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 C76F360388 for ; Thu, 25 Jan 2018 18:54:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B596227F91 for ; Thu, 25 Jan 2018 18:54:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A8CEC28741; Thu, 25 Jan 2018 18:54:03 +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 528E227F91 for ; Thu, 25 Jan 2018 18:54:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751256AbeAYSyC (ORCPT ); Thu, 25 Jan 2018 13:54:02 -0500 Received: from mout.web.de ([212.227.15.4]:63143 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751183AbeAYSyB (ORCPT ); Thu, 25 Jan 2018 13:54:01 -0500 Received: from [192.168.1.2] ([92.227.186.52]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MHp7t-1edxhr0M2v-003hRz; Thu, 25 Jan 2018 19:53:50 +0100 Subject: [PATCH 2/3] Input: ims-pcu: Improve a size determination in two functions From: SF Markus Elfring To: linux-input@vger.kernel.org, Arvind Yadav , Dmitry Torokhov , Joe Perches , Johan Hovold , Zhen Lei Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <1819bb70-3c2c-a86a-29a2-5fb049c3f194@users.sourceforge.net> Date: Thu, 25 Jan 2018 19:53:48 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:Jci1KLZDvRS+v38H1Phwssfw+TlkLkvUfkcKF0EprbyMnAVIwNY 1YqxoHxubgyBPXR0lB8jW/xPDeBVoQ1I3ilHzSckIm9DOj5CKmCrsyc73t8XK8f8qsWAstg UTxPk8C9ebLsu/Qx4dChxIPZlM+xZyfH0HNBLwTvDPADaPgYeHyvXNFJ38EXyyOBsd0VSz2 1oiAGnkorVDBY7g+MsM+A== X-UI-Out-Filterresults: notjunk:1; V01:K0:py/csLaaOcE=:XB319WpqDQlcExL3FRVzSh xalkiC0ahVsRqZK/mhjETvWSNhTs6iSokkbDnbPiihYU/c9Zjp82JcC/BWY+PIYegqFzPcDct ds9fieRc+GC0PDR7p5TwyPhWnX7JSsZEz4qd/PJUFX+AhXis2cZQKdWsQk6LvVzLwwAFKJ6WV XVudMZB1FZdRK0/XYire1cStRNLiHJSJBPbMF3WX4U4Pu3vH3zE7hE+zFB0rRNGCbVqSOK0v9 kWSFomYSPp39y7Et99Nx02Gx4S32OtFCT1A73SCeipf42Syxj8WcXqlFTSCVfzjU3ijkavpZx Qun8KTGCy/wtxVGZjzHzB5J5BU/rOK5Uqe8sd5A1mZdv1boofXJjLH5ZxMTZj6OSFcBH3rK5r Yf8UByFZiVh5qxcZeziQYHyMKbATxu0Bhno4bZBVUej4FiKNiT8w7lVL+Yjgwq5CiM1aVvQTu VKRekziLHbW19FZtVCko69nUZTa7jGpOovE1jb3oFIzcn0Kdx/HpxFKtKEr5BBtXbBKJIBi8I DKntrD6Xb6nikNoASctDJKKCHIQjHrTgPKs8rQAZCY8jW2vJDaevKQuJ0B13RvxDCvL6ieSi9 cL4DbuU2G26vc3gWbcUSORREd7MPTrnf+odGCPihYKcagFAg+X8TLfQ6hsIygrY6pD9UZzKTZ UrUN1GXxAxJynyiluc4FNNtdlUGL5CDPXqAsIWhH34QZk7TIUtYL++DDHKPW+4gCjQjySVDfC bdA51g7Tgc4rYIL5yj6mOwEW5pe9qS8LhwRpQxxy2xc16/O3Fv8gELQ8XBBRyyWIjxAYHWeYF I5DSZBFjLwNz4YObzYdy5UmPbj7GVMgWTFfNdDvEqnd+4A5dsQ= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Thu, 25 Jan 2018 19:20:38 +0100 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. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/input/misc/ims-pcu.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c index 4aca2a02ff6d..d7778b273151 100644 --- a/drivers/input/misc/ims-pcu.c +++ b/drivers/input/misc/ims-pcu.c @@ -288,12 +288,10 @@ static void ims_pcu_gamepad_report(struct ims_pcu *pcu, u32 data) static int ims_pcu_setup_gamepad(struct ims_pcu *pcu) { - struct ims_pcu_gamepad *gamepad; - struct input_dev *input; int error; + struct ims_pcu_gamepad *gamepad = kzalloc(sizeof(*gamepad), GFP_KERNEL); + struct input_dev *input = input_allocate_device(); - gamepad = kzalloc(sizeof(struct ims_pcu_gamepad), GFP_KERNEL); - input = input_allocate_device(); if (!gamepad || !input) { dev_err(pcu->dev, "Not enough memory for gamepad device\n"); @@ -2003,10 +2001,9 @@ static int ims_pcu_probe(struct usb_interface *intf, const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(intf); - struct ims_pcu *pcu; int error; + struct ims_pcu *pcu = kzalloc(sizeof(*pcu), GFP_KERNEL); - pcu = kzalloc(sizeof(struct ims_pcu), GFP_KERNEL); if (!pcu) return -ENOMEM;