Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756111AbdLOKdZ (ORCPT ); Fri, 15 Dec 2017 05:33:25 -0500 Received: from mout.web.de ([212.227.15.3]:63582 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755136AbdLOKdS (ORCPT ); Fri, 15 Dec 2017 05:33:18 -0500 Subject: [PATCH 4/7] rapidio: Improve a size determination in five functions From: SF Markus Elfring To: kernel-janitors@vger.kernel.org, Alexandre Bounine , Matt Porter Cc: LKML References: Message-ID: <495f571c-fb4d-b1d5-a6e5-494f2c537a8d@users.sourceforge.net> Date: Fri, 15 Dec 2017 11:32:46 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:fSadu5z2cQNupHjae0E6D54wXoZUmWldpNNiU8gz5MtP0G3WZEC U6gL/ZKTSXWAjvZuJ082YFbzpoD4JZSty2ZNe/6JM1+EwduAOc2J+q1wKmgsN6/xIC3IMyS dIQ4avVW9BbIvAwaCwMAsTu2wEnvTCjIzS87nd4xPCeMJee21El9o1C/WGb8HFgRLgBN6W2 ol8mM8YdyHHRaXxtvyrdQ== X-UI-Out-Filterresults: notjunk:1;V01:K0:UV3Lb/mtNOE=:P7PxVXncrSig0zhYVH+36A DZ9iF251oYjOZYlfh0HywSbh8HCaNNWNPn23QvDKgY3jSn/pgM5FupeEVxOgXz4KLeLmgYVK+ FRLVxLy/XXd9jnjW+WGGI1eZ50LWMl6+m21AtP7oXnj5RqSXdUOl4G/UIwk24NByCqf4C9FMb e9NkcJ1udIGNeD4ktTzj2U1DqfsvIEyhQkBy5oEXw1rNykFg6tmHAxYaU7LR3vSJ5DxacM4U1 yTnHwDxIGa3HuG9FJ+30J96EhqiQ+FJG4Mfb3qtMrdlO2QmPIovbW6TMG533ApdbmHRxlHMPR +zJc858XQDXLFxpFqAECtPGHifQvGP1+aBBgN4NnGZAeaXUqg3zLMLcZKvkL7RwrKAPrqA9jI Ei1R8AFv4XS3ywhiiQi39nKV9Vy0dOx0e8yww3zzJ7JXf/tArJAykBjrOpXJ3/iPyVn5AdmRN gSWWWy5okJFvaZXKOjBnEBPSd1OJO6sXkubyV6I5y9+V40yIrTfzlci6rdyh67XsoSA0qQvpu KdAmE11HAnIApIE+7JYsbqGS2jGABXb285EIYEzT4HpzgVQy+wEy1KFCRNEexAFSCQvx833Ob 7tezSrHPsznEeDl2O0WO4rb3X+yHzxOwKPqkYKCeW0QhnGNkO/owX324V/gwnfOYbM8MvTcjk mHz4ShmZpWITS1JhdmTR/blbNRbJtu9nqVj/3a2BNg0RYMaG+3jqbxxa8PK7MTMtf8jevCQk/ AD11y3KG3VH2oXhpBx1lON2RnvcRvnj0uVaNX5IqTWf4c9grgD15VobYw8/aiNtq8bDvsDBFB IY4+ZufRH1bh1p6Ny61G/os6kq65kDKf8m2UgNpcU0QmfjKFGxpssNRasrzVfZa6Y4hCZ+S Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2244 Lines: 72 From: Markus Elfring Date: Thu, 14 Dec 2017 16:24:51 +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/rapidio/rio.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index b9dc932ce19e..90534365e46c 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c @@ -110,9 +110,8 @@ EXPORT_SYMBOL(rio_query_mport); */ struct rio_net *rio_alloc_net(struct rio_mport *mport) { - struct rio_net *net; + struct rio_net *net = kzalloc(sizeof(*net), GFP_KERNEL); - net = kzalloc(sizeof(struct rio_net), GFP_KERNEL); if (net) { INIT_LIST_HEAD(&net->node); INIT_LIST_HEAD(&net->devices); @@ -246,8 +245,7 @@ int rio_request_inb_mbox(struct rio_mport *mport, if (!mport->ops->open_inb_mbox) goto out; - res = kzalloc(sizeof(struct resource), GFP_KERNEL); - + res = kzalloc(sizeof(*res), GFP_KERNEL); if (res) { rio_init_mbox_res(res, mbox, mbox); @@ -329,8 +327,7 @@ int rio_request_outb_mbox(struct rio_mport *mport, if (!mport->ops->open_outb_mbox) goto out; - res = kzalloc(sizeof(struct resource), GFP_KERNEL); - + res = kzalloc(sizeof(*res), GFP_KERNEL); if (res) { rio_init_mbox_res(res, mbox, mbox); @@ -445,8 +442,7 @@ int rio_request_inb_dbell(struct rio_mport *mport, u16 dst, u16 info)) { int rc = 0; - - struct resource *res = kzalloc(sizeof(struct resource), GFP_KERNEL); + struct resource *res = kzalloc(sizeof(*res), GFP_KERNEL); if (res) { rio_init_dbell_res(res, start, end); @@ -568,9 +564,8 @@ int rio_add_mport_pw_handler(struct rio_mport *mport, void *context, void *context, union rio_pw_msg *msg, int step)) { int rc = 0; - struct rio_pwrite *pwrite; + struct rio_pwrite *pwrite = kzalloc(sizeof(*pwrite), GFP_KERNEL); - pwrite = kzalloc(sizeof(struct rio_pwrite), GFP_KERNEL); if (!pwrite) { rc = -ENOMEM; goto out; -- 2.15.1