From patchwork Tue Feb 7 19:46:47 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: 9560983 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 3E17560236 for ; Tue, 7 Feb 2017 19:49:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 30CA128485 for ; Tue, 7 Feb 2017 19:49:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2562528487; Tue, 7 Feb 2017 19:49:46 +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 C5AF328485 for ; Tue, 7 Feb 2017 19:49:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754230AbdBGTrr (ORCPT ); Tue, 7 Feb 2017 14:47:47 -0500 Received: from mout.web.de ([212.227.17.12]:64609 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752042AbdBGTq6 (ORCPT ); Tue, 7 Feb 2017 14:46:58 -0500 Received: from [192.168.1.2] ([78.49.4.3]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M25FH-1cHKim0671-00u1J2; Tue, 07 Feb 2017 20:46:51 +0100 Subject: [PATCH 05/18] HID: Improve two size determinations in hid_open_report() To: linux-input@vger.kernel.org, Benjamin Tissoires , =?UTF-8?Q?Bruno_Pr=c3=a9mont?= , Jiri Kosina References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: <08ff35e1-d9f4-2296-c641-d6a28e951594@users.sourceforge.net> Date: Tue, 7 Feb 2017 20:46:47 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:VDDfeJ5e6/CAx6dLxm4JtNfBgmftgGPppC8fvbrbhnC6I+CE/r/ UAURGViVB0PXqknVhdbf1xJlllvAAxd8s/zlglAuJt+aveQhhnHQn6LBT6iPeexomoD+vep RRWf+L3efEtSIRznjy9rfpBZikg8m47LXTNf2ZKAtudc7J9TiikC3D2zUiKSphOu9G+hq5v 1sM00IIJqPK96h7q+Sc3Q== X-UI-Out-Filterresults: notjunk:1; V01:K0:l4OLrDD0gn4=:AS0YMODd/Fo9bAJzWx9jEt 4E8Z3EjVIL+QD3EUlsWfwCRJ7r8O4NDjayEyaRBkavCEq8QQIJmPk5/fHzNm8ZRxc0ubb59kT HCYBIgW2FcqMP0sQDjbbGiLV7pEDmWDGpXngVOYPWnIVph8H9cnb81GVZxX4SgkSFLUp5RhJB OxkC8Ve4F6Vuras/gTIbbU+F9WVW2wV9Zy/AxmL+LXkjIUVKAIxg2FIKK+66CoR5UedrgJyfe udMqLnLNmmLEplv+Jh23iUHguCmMeD0DCtibJ6cLObwoDsNB3GZWS06mumOIUfVAli46xCyb/ v32cILJbQjRhYkXXBq0CRwVKCuleP2dx5fllAPyW2jTmfLE2PhufRasNOZ3pzK3gCK+9GJett 7dv+yiOtB2WgmAcYQlVrpCGLAeTJwil0yJ9nTKFjU9gg1zv7ag4FUuXchs+ePKwvYOzm1hqFO Njj0z8mik+3whzjU1mfYP0NXhBz+oFA+Fcso14J7EytGYk9+4rmaWliy21T3Mtfegwu26wsCt M2f7KnxHfcUV8rkflZ3R3duvlJTvYMziejuIHSNqIeu9b8KCJm1e+q1n1U02M3dPow9XnOqmG 9T4dO1S2l4zaam6+SvESm+Jg6AeNHFtwbOxhIqXUMfYXTL2BGjsjWJPrbS5RUeFmUymIwbw2J HEgZHtHzLbTy5bU7NwTZH8xAo5kl6fnSF2QMOe9flpOnmGDb0J9PzPsRWnnLDU/BSAVVMbj8A q7V199F8OQsoW49HUKtx+SA9l6jp1shTdsxNp5hxoG9bN67/X9qbq2znUpqjVDKUIzJX6DWd0 oJPmyQ1 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: Mon, 6 Feb 2017 22:00:07 +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. Signed-off-by: Markus Elfring --- drivers/hid/hid-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 404eccd0d670..16c73bf49d55 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -975,7 +975,7 @@ int hid_open_report(struct hid_device *device) device->rdesc = start; device->rsize = size; - parser = vzalloc(sizeof(struct hid_parser)); + parser = vzalloc(sizeof(*parser)); if (!parser) { ret = -ENOMEM; goto err; @@ -986,7 +986,7 @@ int hid_open_report(struct hid_device *device) end = start + size; device->collection = kcalloc(HID_DEFAULT_NUM_COLLECTIONS, - sizeof(struct hid_collection), GFP_KERNEL); + sizeof(*device->collection), GFP_KERNEL); if (!device->collection) { ret = -ENOMEM; goto err;