From patchwork Sun Aug 21 07:27:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9292061 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 1DDDB607FF for ; Sun, 21 Aug 2016 07:27:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 15E00284F8 for ; Sun, 21 Aug 2016 07:27:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A9512893B; Sun, 21 Aug 2016 07:27:50 +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 B4F0F284F8 for ; Sun, 21 Aug 2016 07:27:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752514AbcHUH1e (ORCPT ); Sun, 21 Aug 2016 03:27:34 -0400 Received: from mout.web.de ([217.72.192.78]:51440 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbcHUH1d (ORCPT ); Sun, 21 Aug 2016 03:27:33 -0400 Received: from [192.168.1.3] ([77.181.85.179]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MBCBN-1bTQYH2j25-00ABHh; Sun, 21 Aug 2016 09:27:20 +0200 Subject: [PATCH 6/7] aacraid: Improve determination of a few sizes To: linux-scsi@vger.kernel.org, aacraid@microsemi.com, "James E. J. Bottomley" , "Martin K. Petersen" References: <566ABCD9.1060404@users.sourceforge.net> <40d8607f-3934-c31f-3791-ef6a67d65d45@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <5fa01979-9ca2-32d0-bece-c33902a5259b@users.sourceforge.net> Date: Sun, 21 Aug 2016 09:27:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <40d8607f-3934-c31f-3791-ef6a67d65d45@users.sourceforge.net> X-Provags-ID: V03:K0:6OyacQEl9rISSiuSskq7v/vUpOPcJ50xlcHZDpZC6e9meroKXBf iB+2XTjBa4ekhbpt0gQrGdIK2eMG1yv+flVxVqV+JNK28KC6Um80zQPczYkdYFhQGCL33jj koXesqcbsKxfFu/lEm8/6Epj2f632Ie2HfvAPSfpYRyUY/ZQG9ZBnySo1TV81WvWtbS54Ls HERpho2/49i5B1qFxm/PQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:nW7jFXWJbDw=:b+rEmer4LJYdXzLWWkAM6j ajCTQuSCqgI/t2vFMEfSQFGeCMXch0uwlVDRFxle3Jog/mw5FgjNa6kNAwjTdmWFs82HisSv8 CiutL0hk11ny963SZ3LQgkzLqTcIQg1TIyeUHPPsoyDKSaNkUh/XfN9S1lN5CjiT0HMT7t8sv k4C65BdZ+vGiyAYrP5eABu9gG4eotvtvCMeme4dQESD4jDs91q8v50y4GAT4wplFDtjUdLJ9u KDgrmJaceDyNCqhuYJbL72tsTQMJkK18ZpAnGuFJVMRKXftDvNBdFgXlQB2uJKPM23pON+y8H ZbKxGM3Do0q+9SsdibPVowzBSpLdiTbxOdMhBO+tT1IY16dzgtQ5m5MCqwuzNLUk4E67XCGsb RjqC+Vz7TK7ho9B6da1utMmmi7LFfISdBSE4A09sJDicWOxkG4yQAIILuoUVjsylSeDljsSEX LCa/Tpf1N5yHNcNIcwCnuS/0cpj/555T3Z7Gr8xiPvHnHJ/2sRDONZnwnjiU9zWQ0WekF2Yb8 PIY/F3zPL/eQPoHQtdXO1z8Au6CyiGNsZsAYpWdOvX6IkQHieFmyyZuCTtg7pNS3gX91y462Y AHE45mte2m9+CujALFFN4PudB/mMhX8gNc1wssSGS958al+eksRs9vs7wI6KTpIOZRc0vzihJ SjWZr1wKVkFb6NZ8/ILIJC5UyNa+8OlmjsF6TC7xdWcNg8X+OTpUdvJ01ha+f21tr2h3PSI1Q k7goEBplXxrMUvKdtdZX9QokJjntV7ExpX9RtzArBYUxdEE23kZd0rXWByYwXLOLZjX6lTr+p lS+mOrG Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 21 Aug 2016 08:04:48 +0200 Replace the specification of data structures by references for variables 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/scsi/aacraid/commctrl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index cda03f0..d2029db 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -177,7 +177,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) struct aac_fib_context * fibctx; int status; - fibctx = kmalloc(sizeof(struct aac_fib_context), GFP_KERNEL); + fibctx = kmalloc(sizeof(*fibctx), GFP_KERNEL); if (fibctx == NULL) { status = -ENOMEM; } else { @@ -186,7 +186,7 @@ static int open_getadapter_fib(struct aac_dev * dev, void __user *arg) struct aac_fib_context * context; fibctx->type = FSAFS_NTC_GET_ADAPTER_FIB_CONTEXT; - fibctx->size = sizeof(struct aac_fib_context); + fibctx->size = sizeof(*fibctx); /* * Yes yes, I know this could be an index, but we have a * better guarantee of uniqueness for the locked loop below. @@ -251,7 +251,7 @@ static int next_getadapter_fib(struct aac_dev * dev, void __user *arg) struct list_head * entry; unsigned long flags; - if (copy_from_user((void *)&f, arg, sizeof(struct fib_ioctl))) + if (copy_from_user(&f, arg, sizeof(f))) return -EFAULT; /* * Verify that the HANDLE passed in was a valid AdapterFibContext @@ -509,7 +509,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) srbcmd = (struct aac_srb*) fib_data(srbfib); memset(sg_list, 0, sizeof(sg_list)); /* cleanup may take issue */ - if (copy_from_user(&fibsize, &user_srb->count, sizeof(u32))) { + if (copy_from_user(&fibsize, &user_srb->count, sizeof(fibsize))) { dprintk((KERN_DEBUG"aacraid: Could not copy data size from user\n")); rcode = -EFAULT; goto free_sg_list;