From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934130AbdHYQDp (ORCPT ); Fri, 25 Aug 2017 12:03:45 -0400 Received: from mout.web.de ([212.227.15.14]:59783 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933744AbdHYQDn (ORCPT ); Fri, 25 Aug 2017 12:03:43 -0400 Subject: [PATCH 07/14] vme: fake: Improve five size determinations in fake_init() From: SF Markus Elfring To: devel@driverdev.osuosl.org, Aaron Sierra , Alessio Igor Bogani , Arnd Bergmann , Augusto Mecking Caringi , Baoyou Xie , Greg Kroah-Hartman , Manohar Vanga , Martyn Welch Cc: LKML , kernel-janitors@vger.kernel.org References: <7ab4be89-4aa6-5537-9839-da090635f249@users.sourceforge.net> Message-ID: <833ed88a-d969-3745-b61a-7274c87394b9@users.sourceforge.net> Date: Fri, 25 Aug 2017 18:03:37 +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: <7ab4be89-4aa6-5537-9839-da090635f249@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:ziTnHBIsN2xwaXMkahwWivhPYwurOQeIXJjx4Ho4zNU7TGzlcQj +BogaMsCUcBDVy0dNlmAp2OrphVsMzgwnk4b7LfbMN3wubWcMrRHjQiY1lCOLcvg9I+aaYB splzZeuLeHWEzC1EPq0YeiIhv4owAuEMMvotBPA8X9MB4e+4tU2eCMxYfN73QkUG19/whTq /Nfi2xGu+GCYNmXaR3vFg== X-UI-Out-Filterresults: notjunk:1;V01:K0:fKYSjD4DMuM=:sP/idD1u+TVh2Odgp5mu6O aRT36eic3y/Jp9wExcJraH2n+MdfYrVz1cw77PytkdtpqBwA1crph6Bb7Cj/S6v9B/ZaoX8/v eMK3+DsfbpDvFx8XMsEPc7FDnIaJSrRQB3nlbXX0undkwFS97sFSDnD3czlmUdIirVbsQtkXW mte2ZWJko/nqZheYdj8asrmUoE1LttYIrXUoO90g+ydXzu9Iquxqkptr7L/wX2482nfr5u8v+ XYpRPJg6/IVZGP8jeN5VKtfov2u6ERfVkS5squf8SGF0w4m5OVpauLWZro2x12fuknBH1O44O xmDOc+r78qMKki20j1ptoRyn2TpBQC+p5w0mS3e8FODgwDBnHb6SXB70SWHeP7u9mjDfEmold up6uW5KYDYti+NlCqbMCt/SEn9W9voY3iB/z+bLyeOnxh6RBU/jcYBC7o9L3Rffml8DqKpOeT Bk0puKKgyfTojSndX4myeg43s5yqKwlJh/DbWsp7uQBVRxSL+4JefStOy3VnucWOo1wHmL6w6 lHUvjOS+I53ydANGHh65/Rl+Nbm8RKp5c69qUitsYf38UHakiulkZgFMouXftjhFNZV99i5lo jRvcSpA4VVTk5h7h+r6+55HpMBJNinKFBf2VuniDSauCd3bss6pv1qoSbYq9j+qtqq5eGdWA+ lCpNIFU9q+RwXXvzcAQNliZC2AoWur66Q5TO07POSdi0oB9rYrhpeclAqNlRWKVi4MeuVtA6f CWr9wp7TDaxU1dzgYWXie58eVOFLuZWH/m5ee3OhigvWbRNU0Awakb2D089ZbdC0wjHwiv29r N9yQHYMcbavu7JWnOTkQhUVuMUn+rCAeTuXezHW4ptpRs3ceYA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Fri, 25 Aug 2017 09:46:13 +0200 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/vme/bridges/vme_fake.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c index 6ceea5e9fd8b..39f84df44557 100644 --- a/drivers/vme/bridges/vme_fake.c +++ b/drivers/vme/bridges/vme_fake.c @@ -1075,11 +1075,11 @@ static int __init fake_init(void) /* If we want to support more than one bridge at some point, we need to * dynamically allocate this so we get one per device. */ - fake_bridge = kzalloc(sizeof(struct vme_bridge), GFP_KERNEL); + fake_bridge = kzalloc(sizeof(*fake_bridge), GFP_KERNEL); if (fake_bridge == NULL) { retval = -ENOMEM; goto err_struct; } - fake_device = kzalloc(sizeof(struct fake_driver), GFP_KERNEL); + fake_device = kzalloc(sizeof(*fake_device), GFP_KERNEL); if (fake_device == NULL) { @@ -1104,6 +1104,5 @@ static int __init fake_init(void) /* Add master windows to list */ INIT_LIST_HEAD(&fake_bridge->master_resources); for (i = 0; i < FAKE_MAX_MASTER; i++) { - master_image = kmalloc(sizeof(struct vme_master_resource), - GFP_KERNEL); + master_image = kmalloc(sizeof(*master_image), GFP_KERNEL); if (master_image == NULL) { @@ -1131,6 +1130,5 @@ static int __init fake_init(void) /* Add slave windows to list */ INIT_LIST_HEAD(&fake_bridge->slave_resources); for (i = 0; i < FAKE_MAX_SLAVE; i++) { - slave_image = kmalloc(sizeof(struct vme_slave_resource), - GFP_KERNEL); + slave_image = kmalloc(sizeof(*slave_image), GFP_KERNEL); if (slave_image == NULL) { @@ -1154,5 +1152,5 @@ static int __init fake_init(void) /* Add location monitor to list */ INIT_LIST_HEAD(&fake_bridge->lm_resources); - lm = kmalloc(sizeof(struct vme_lm_resource), GFP_KERNEL); + lm = kmalloc(sizeof(*lm), GFP_KERNEL); if (lm == NULL) { -- 2.14.0