From patchwork Fri Apr 21 18:28:37 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: 9693395 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 4672C6038D for ; Fri, 21 Apr 2017 18:29:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B81F28636 for ; Fri, 21 Apr 2017 18:29:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3037E28654; Fri, 21 Apr 2017 18:29:36 +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 B9F5C28636 for ; Fri, 21 Apr 2017 18:29:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1041917AbdDUS3d (ORCPT ); Fri, 21 Apr 2017 14:29:33 -0400 Received: from mout.web.de ([212.227.15.3]:60810 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161841AbdDUS3P (ORCPT ); Fri, 21 Apr 2017 14:29:15 -0400 Received: from [192.168.1.2] ([77.182.39.184]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M9GcY-1crCdw1rck-00ClnU; Fri, 21 Apr 2017 20:28:42 +0200 Subject: [PATCH v2 03/17] IB/mlx4: Improve size determinations in six functions From: SF Markus Elfring To: Doug Ledford , Hal Rosenstock , Leon Romanovsky , Majd Dibbiny , Matan Barak , Sean Hefty , Yishai Hadas , linux-rdma@vger.kernel.org Cc: LKML , kernel-janitors@vger.kernel.org References: <1935365a-bd7c-461e-6a84-0c5d3a501fff@users.sourceforge.net> <1492720654.3041.16.camel@redhat.com> Message-ID: Date: Fri, 21 Apr 2017 20:28:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:jXGpziSDKshcPcCjR+oA4OvjgdsD9zlA1fqkX8ShwnsC9cySurK SLUSPd/IJG/KgVopPhnpKju+cx7/V6BC7N7tvaCbJu5z0ibm+cbHz0fdAB6NKRrBGz+L6wU 4kZQr+nbGAj77EUhS7K4GRYvIxAjlTuj4J6d4xK9S29Oi6nt3zzUu3mrXQdKiM9K9wRe0Jh TkHTg+tv+unioxKtTVBYg== X-UI-Out-Filterresults: notjunk:1; V01:K0:2N78RhxjPCY=:7svmLskf6mWmehNkOOnB+l P39++LUDbyZTD7X6PWfspWNb5Un6Z+GkisSf98C9ZLRiq1U0/c26nvO73w28ntf2hFD7LHLva LZdmfNXCbxqeidmo8rYHakEz4nj7Y/aqRfwgZB6R7L2CXupgDwCacD4sDmrkiqDpr3UL9zcwN L200FmpH59ksMEwqKdXbZDhGfFzLBKx83mLeK3+JFkB3HWZWU0z3/6Ucsv2z1kLlh7xFK0Pk1 I83VcS6Uz+/2GJjrgIN2+uUUSTkMCYttdT16gi2tsAiio6vobPclQrc/uG25sQ1PSAftT3w8b VWm2XFXSOs4cI8zN/HzWGOATz6oMSrd2BDIMDCtFD/TdZRewLgF3KqqXuIBCfcjiILuDgEL4y 3xDTUkFf4dpBRP0zTTRrpDN/pe9/axRfs+tOPV2Xzm0R7PCBGZBWgkRl+pb69Fmm9SmI0Op5y FZexoDkI36Z6BgjpQbexG4dq9G0R4BxXAaTjgWW0AlLq3KOKDRPuYMr+unjOV4s0sPGyGCIP2 kgXE7uQgd+uUaur69S4qzOwrhIKc1svqYvrsfxAs7O6UV6vGKJCmfNF8cs6U+MP6eeBsvC2pj euIavWQB3BBBnlEgVnTQSKkSOGCMaUGdlKNBUzFhKZD/yj//ml0O9bF/27dtCRelq7nY07IrV dji2d1oSqaeQQJdtELoHzGwOzBpe4uWGlScknA20CDjtjT9NvaZtwj4gJN6y9wVo9j9bUCUT2 R54jJnJMPkm8TFujF9crL15azH7SPHrF97O45ZUY+m9dd+QwX0Y6OA5UkcyageOQdq9xHpVve ITItMr7 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Fri, 21 Apr 2017 11:33:43 +0200 Replace the specification of data types by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determinations a bit safer according to the Linux coding style convention. Signed-off-by: Markus Elfring --- v2: Changes were rebased on source files from Linux next-20170421. These were recombined as requested by Doug Ledford. drivers/infiniband/hw/mlx4/mad.c | 6 +++--- drivers/infiniband/hw/mlx4/main.c | 7 +++---- drivers/infiniband/hw/mlx4/qp.c | 4 ++-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c index 61bd81baeb29..ea4892b0f39e 100644 --- a/drivers/infiniband/hw/mlx4/mad.c +++ b/drivers/infiniband/hw/mlx4/mad.c @@ -1607,7 +1607,7 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx, return -ENOMEM; tun_qp->tx_ring = kcalloc(MLX4_NUM_TUNNEL_BUFS, - sizeof (struct mlx4_ib_tun_tx_buf), + sizeof(*tun_qp->tx_ring), GFP_KERNEL); if (!tun_qp->tx_ring) { kfree(tun_qp->ring); @@ -1948,7 +1948,7 @@ static int alloc_pv_object(struct mlx4_ib_dev *dev, int slave, int port, struct mlx4_ib_demux_pv_ctx *ctx; *ret_ctx = NULL; - ctx = kzalloc(sizeof (struct mlx4_ib_demux_pv_ctx), GFP_KERNEL); + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (!ctx) return -ENOMEM; @@ -2150,7 +2150,7 @@ static int mlx4_ib_alloc_demux_ctx(struct mlx4_ib_dev *dev, int i; ctx->tun = kcalloc(dev->dev->caps.sqp_demux, - sizeof (struct mlx4_ib_demux_pv_ctx *), GFP_KERNEL); + sizeof(*ctx->tun), GFP_KERNEL); if (!ctx->tun) return -ENOMEM; diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 30a70fa95fec..0ac670765466 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -2804,9 +2804,8 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) } if (mlx4_is_bonded(dev)) for (i = 1; i < ibdev->num_ports ; ++i) { - new_counter_index = - kmalloc(sizeof(struct counter_index), - GFP_KERNEL); + new_counter_index = kmalloc(sizeof(*new_counter_index), + GFP_KERNEL); if (!new_counter_index) goto err_counter; new_counter_index->index = counter_index; @@ -3085,7 +3084,7 @@ static void do_slave_init(struct mlx4_ib_dev *ibdev, int slave, int do_init) return; for (i = 0; i < ports; i++) { - dm[i] = kmalloc(sizeof (struct mlx4_ib_demux_work), GFP_ATOMIC); + dm[i] = kmalloc(sizeof(*dm[i]), GFP_ATOMIC); if (!dm[i]) { while (--i >= 0) kfree(dm[i]); diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index 1d9d949c66d0..9269cd503443 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c @@ -691,14 +691,14 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd, if (qp_type == MLX4_IB_QPT_SMI || qp_type == MLX4_IB_QPT_GSI || (qp_type & (MLX4_IB_QPT_PROXY_SMI | MLX4_IB_QPT_PROXY_SMI_OWNER | MLX4_IB_QPT_PROXY_GSI | MLX4_IB_QPT_TUN_SMI_OWNER))) { - sqp = kzalloc(sizeof (struct mlx4_ib_sqp), gfp); + sqp = kzalloc(sizeof(*sqp), gfp); if (!sqp) return -ENOMEM; qp = &sqp->qp; qp->pri.vid = 0xFFFF; qp->alt.vid = 0xFFFF; } else { - qp = kzalloc(sizeof (struct mlx4_ib_qp), gfp); + qp = kzalloc(sizeof(*qp), gfp); if (!qp) return -ENOMEM; qp->pri.vid = 0xFFFF;