From patchwork Wed Mar 8 12:58:49 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: 9611027 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 66B666016C for ; Wed, 8 Mar 2017 13:10:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A444028582 for ; Wed, 8 Mar 2017 13:10:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9852A28586; Wed, 8 Mar 2017 13:10:27 +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 3F28928582 for ; Wed, 8 Mar 2017 13:10:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752713AbdCHNKZ (ORCPT ); Wed, 8 Mar 2017 08:10:25 -0500 Received: from mout.web.de ([212.227.15.4]:57242 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751603AbdCHNKX (ORCPT ); Wed, 8 Mar 2017 08:10:23 -0500 Received: from [192.168.1.2] ([92.228.144.238]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MEZPl-1d1Klu0v5V-00FjwX; Wed, 08 Mar 2017 13:58:51 +0100 Subject: [PATCH 08/26] IB/ocrdma: Improve size determinations in ocrdma_mbx_rdma_stats() To: linux-rdma@vger.kernel.org, Devesh Sharma , Doug Ledford , Hal Rosenstock , Sean Hefty , Selvin Xavier References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Wed, 8 Mar 2017 13:58:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:l3N2YWMPpUujLrmXLrF7Gi1zgq8GpcHePFN6BhwzXW8lrOZXHPb +KtytQm/OUwgok/2N0T4sGmN8obhllto8syj/hrXpqY+bWWf2XGK1IpGa1zCAaYtvJXP+yZ S///5iB7LKK9Gbzjty1SOPzOTwPyk+UlKC+X7YSjW/ORTpNX2QqDnKp8AUrkm8djXr0kkLX SPrO2SvcnPuqWit5qaViw== X-UI-Out-Filterresults: notjunk:1; V01:K0:l5gfDVbrJZs=:726p0eXui8YvKI2kWwtGDI M9R9fuFvzzHRBlfPVpyLsVRXqJTZpnKVWdQc+8g04GUndCV/F0r+DxxHHJaCFgwZyAoVKeNiz zbzxFwWBs0bYYKtbxpawn4Q0orkMJafz0Tx9jb73PIYo2KF5Z5dSFW6qlTRglDfTffCoXVNoq knWZH4oNIVa3KQ6g7iHz1L9ntlZqtRTYe84US5k8wRepwMnVxTooYyG9IA4/nYIeFA410NWlV tILNzjuFx+w/Wo4W6U5a7oUwDQMAQVa4hdkei4uojnmAHbMPy9NrLOMhaD05Uj+D+4PIgpqV1 6E66n6ZD4ncbqlcABFFn2SybdB1czJZr27W2bBR5BzjFwNdbKfPGldoesV0sKb4P3kkGKlYhe U0BRE0pXZ730T0OkaO2m0dKSiJe6yDlRqGidHRqrgENN6czPPlfggTjFK+0BUcM7onjpmSXTe rsadIE55axBOSLO5QLjV7+0B/s4kBaNcJt8s5XYWTqMpVV5cnCTTdHoGFj4/IxsGG+iH6etCe M48XlVKxfv+SU+rB8+XFYvibFOMy8qgyt85eQhe9dS8hwctCcR0KjvZU0pKL2SZ+gkNVXHssl 5qOf+GNV3p70as3eGpPBD6YUUaqxfhiVSLtVkbal6bD7fQEb7UStf/xAk1vvwORfK25mxe2rY IF8Qf7SxLqzQFjVsr1w2JtXvuvaAu14EdGQ3bO0lomBAkcrBYAjHJSD9kAIkmiFsuPNIc6Kit r7/7lZyXHFzFzmx/+8J4TW3yq8HaRCtJI3bJPg9Oaoy0qqtZh3cx+BGuXeXhd4tGebhUUCpXv 9lssU3F 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: Tue, 7 Mar 2017 20:16:16 +0100 Replace the specification of two data structures 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 --- drivers/infiniband/hw/ocrdma/ocrdma_hw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 1f7d88d7569e..0628600bee56 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c @@ -1302,7 +1302,7 @@ int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset) mqe->u.nonemb_req.sge[0].len = dev->stats_mem.size; /* Cache the old stats */ - memcpy(old_stats, req, sizeof(struct ocrdma_rdma_stats_resp)); + memcpy(old_stats, req, sizeof(*old_stats)); memset(req, 0, dev->stats_mem.size); ocrdma_init_mch((struct ocrdma_mbx_hdr *)req, @@ -1315,7 +1315,7 @@ int ocrdma_mbx_rdma_stats(struct ocrdma_dev *dev, bool reset) status = ocrdma_nonemb_mbx_cmd(dev, mqe, dev->stats_mem.va); if (status) /* Copy from cache, if mbox fails */ - memcpy(req, old_stats, sizeof(struct ocrdma_rdma_stats_resp)); + memcpy(req, old_stats, sizeof(*old_stats)); else ocrdma_le32_to_cpu(req, dev->stats_mem.size);