Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1038978/?format=api
{ "id": 1038978, "url": "http://patchwork.ozlabs.org/api/patches/1038978/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190208205043.11975-5-anirudh.venkataramanan@intel.com/", "project": { "id": 46, "url": "http://patchwork.ozlabs.org/api/projects/46/?format=api", "name": "Intel Wired Ethernet development", "link_name": "intel-wired-lan", "list_id": "intel-wired-lan.osuosl.org", "list_email": "intel-wired-lan@osuosl.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20190208205043.11975-5-anirudh.venkataramanan@intel.com>", "list_archive_url": null, "date": "2019-02-08T20:50:31", "name": "[S11,04/16] ice: sizeof(<type>) should be avoided", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "306b8ef049872090b5a6d5a901808430ed030a66", "submitter": { "id": 73601, "url": "http://patchwork.ozlabs.org/api/people/73601/?format=api", "name": "Anirudh Venkataramanan", "email": "anirudh.venkataramanan@intel.com" }, "delegate": { "id": 68, "url": "http://patchwork.ozlabs.org/api/users/68/?format=api", "username": "jtkirshe", "first_name": "Jeff", "last_name": "Kirsher", "email": "jeffrey.t.kirsher@intel.com" }, "mbox": "http://patchwork.ozlabs.org/project/intel-wired-lan/patch/20190208205043.11975-5-anirudh.venkataramanan@intel.com/mbox/", "series": [ { "id": 90915, "url": "http://patchwork.ozlabs.org/api/series/90915/?format=api", "web_url": "http://patchwork.ozlabs.org/project/intel-wired-lan/list/?series=90915", "date": "2019-02-08T20:50:37", "name": "Bug fixes for ice", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/90915/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1038978/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/1038978/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<intel-wired-lan-bounces@osuosl.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "intel-wired-lan@lists.osuosl.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=osuosl.org\n\t(client-ip=140.211.166.136; helo=silver.osuosl.org;\n\tenvelope-from=intel-wired-lan-bounces@osuosl.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org;\n\tdmarc=fail (p=none dis=none) header.from=intel.com" ], "Received": [ "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 43x6qY0qsNz9sMp\n\tfor <incoming@patchwork.ozlabs.org>;\n\tSat, 9 Feb 2019 07:54:17 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id B73D3236B5;\n\tFri, 8 Feb 2019 20:54:15 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id qwUYcgTZJ+uT; Fri, 8 Feb 2019 20:54:13 +0000 (UTC)", "from ash.osuosl.org (ash.osuosl.org [140.211.166.34])\n\tby silver.osuosl.org (Postfix) with ESMTP id 3122830E61;\n\tFri, 8 Feb 2019 20:54:13 +0000 (UTC)", "from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])\n\tby ash.osuosl.org (Postfix) with ESMTP id 427B91BF981\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 8 Feb 2019 20:52:32 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n\tby silver.osuosl.org (Postfix) with ESMTP id 374E831364\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 8 Feb 2019 20:52:31 +0000 (UTC)", "from silver.osuosl.org ([127.0.0.1])\n\tby localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id BtCe59sCgmke for <intel-wired-lan@lists.osuosl.org>;\n\tFri, 8 Feb 2019 20:52:29 +0000 (UTC)", "from mga02.intel.com (mga02.intel.com [134.134.136.20])\n\tby silver.osuosl.org (Postfix) with ESMTPS id EF1E52343B\n\tfor <intel-wired-lan@lists.osuosl.org>;\n\tFri, 8 Feb 2019 20:52:28 +0000 (UTC)", "from orsmga008.jf.intel.com ([10.7.209.65])\n\tby orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t08 Feb 2019 12:50:43 -0800", "from shasta.jf.intel.com ([10.166.241.11])\n\tby orsmga008.jf.intel.com with ESMTP; 08 Feb 2019 12:50:43 -0800" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.7.6", "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.58,348,1544515200\"; d=\"scan'208\";a=\"116332333\"", "From": "Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>", "To": "intel-wired-lan@lists.osuosl.org", "Date": "Fri, 8 Feb 2019 12:50:31 -0800", "Message-Id": "<20190208205043.11975-5-anirudh.venkataramanan@intel.com>", "X-Mailer": "git-send-email 2.14.5", "In-Reply-To": "<20190208205043.11975-1-anirudh.venkataramanan@intel.com>", "References": "<20190208205043.11975-1-anirudh.venkataramanan@intel.com>", "Subject": "[Intel-wired-lan] [PATCH S11 04/16] ice: sizeof(<type>) should be\n\tavoided", "X-BeenThere": "intel-wired-lan@osuosl.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Intel Wired Ethernet Linux Kernel Driver Development\n\t<intel-wired-lan.osuosl.org>", "List-Unsubscribe": "<https://lists.osuosl.org/mailman/options/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=unsubscribe>", "List-Archive": "<http://lists.osuosl.org/pipermail/intel-wired-lan/>", "List-Post": "<mailto:intel-wired-lan@osuosl.org>", "List-Help": "<mailto:intel-wired-lan-request@osuosl.org?subject=help>", "List-Subscribe": "<https://lists.osuosl.org/mailman/listinfo/intel-wired-lan>, \n\t<mailto:intel-wired-lan-request@osuosl.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "intel-wired-lan-bounces@osuosl.org", "Sender": "\"Intel-wired-lan\" <intel-wired-lan-bounces@osuosl.org>" }, "content": "From: Bruce Allan <bruce.w.allan@intel.com>\n\nWith sizeof(), it is preferable to use the variable of type <type> instead\nof sizeof(<type>).\n\nThere are multiple places where a temporary variable is used to hold a\n'size' value which is then used for a subsequent alloc/memset. Get rid\nof the temporary variable by calculating size as part of the alloc/memset\nstatement.\n\nAlso remove unnecessary type-cast.\n\nSigned-off-by: Bruce Allan <bruce.w.allan@intel.com>\nSigned-off-by: Anirudh Venkataramanan <anirudh.venkataramanan@intel.com>\n---\n[Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> fixed checkpatch errors]\n[Anirudh Venkataramanan <anirudh.venkataramanan@intel.com> edited commit message]\n---\n drivers/net/ethernet/intel/ice/ice_ethtool.c | 15 +++++++--------\n drivers/net/ethernet/intel/ice/ice_lib.c | 10 +++++-----\n drivers/net/ethernet/intel/ice/ice_main.c | 23 +++++++++++------------\n drivers/net/ethernet/intel/ice/ice_sched.c | 9 ++++-----\n drivers/net/ethernet/intel/ice/ice_switch.c | 2 +-\n drivers/net/ethernet/intel/ice/ice_txrx.c | 24 ++++++++++--------------\n 6 files changed, 38 insertions(+), 45 deletions(-)", "diff": "diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool.c b/drivers/net/ethernet/intel/ice/ice_ethtool.c\nindex a82f0202652d..a93daf660171 100644\n--- a/drivers/net/ethernet/intel/ice/ice_ethtool.c\n+++ b/drivers/net/ethernet/intel/ice/ice_ethtool.c\n@@ -1084,7 +1084,7 @@ ice_get_settings_link_up(struct ethtool_link_ksettings *ks,\n \t * current PHY type, get what is supported by the NVM and intersect\n \t * them to get what is truly supported\n \t */\n-\tmemset(&cap_ksettings, 0, sizeof(struct ethtool_link_ksettings));\n+\tmemset(&cap_ksettings, 0, sizeof(cap_ksettings));\n \tice_phy_type_to_ethtool(netdev, &cap_ksettings);\n \tethtool_intersect_link_masks(ks, &cap_ksettings);\n \n@@ -1416,7 +1416,7 @@ ice_set_link_ksettings(struct net_device *netdev,\n \t\treturn -EOPNOTSUPP;\n \n \t/* copy the ksettings to copy_ks to avoid modifying the original */\n-\tmemcpy(©_ks, ks, sizeof(struct ethtool_link_ksettings));\n+\tmemcpy(©_ks, ks, sizeof(copy_ks));\n \n \t/* save autoneg out of ksettings */\n \tautoneg = copy_ks.base.autoneg;\n@@ -1435,7 +1435,7 @@ ice_set_link_ksettings(struct net_device *netdev,\n \t\treturn -EINVAL;\n \n \t/* get our own copy of the bits to check against */\n-\tmemset(&safe_ks, 0, sizeof(struct ethtool_link_ksettings));\n+\tmemset(&safe_ks, 0, sizeof(safe_ks));\n \tsafe_ks.base.cmd = copy_ks.base.cmd;\n \tsafe_ks.base.link_mode_masks_nwords =\n \t\tcopy_ks.base.link_mode_masks_nwords;\n@@ -1449,8 +1449,7 @@ ice_set_link_ksettings(struct net_device *netdev,\n \t/* If copy_ks.base and safe_ks.base are not the same now, then they are\n \t * trying to set something that we do not support.\n \t */\n-\tif (memcmp(©_ks.base, &safe_ks.base,\n-\t\t sizeof(struct ethtool_link_settings)))\n+\tif (memcmp(©_ks.base, &safe_ks.base, sizeof(copy_ks.base)))\n \t\treturn -EOPNOTSUPP;\n \n \twhile (test_and_set_bit(__ICE_CFG_BUSY, pf->state)) {\n@@ -1474,7 +1473,7 @@ ice_set_link_ksettings(struct net_device *netdev,\n \t}\n \n \t/* Copy abilities to config in case autoneg is not set below */\n-\tmemset(&config, 0, sizeof(struct ice_aqc_set_phy_cfg_data));\n+\tmemset(&config, 0, sizeof(config));\n \tconfig.caps = abilities->caps & ~ICE_AQC_PHY_AN_MODE;\n \tif (abilities->caps & ICE_AQC_PHY_AN_MODE)\n \t\tconfig.caps |= ICE_AQ_PHY_ENA_AUTO_LINK_UPDT;\n@@ -1668,7 +1667,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)\n \t\t vsi->tx_rings[0]->count, new_tx_cnt);\n \n \ttx_rings = devm_kcalloc(&pf->pdev->dev, vsi->alloc_txq,\n-\t\t\t\tsizeof(struct ice_ring), GFP_KERNEL);\n+\t\t\t\tsizeof(*tx_rings), GFP_KERNEL);\n \tif (!tx_rings) {\n \t\terr = -ENOMEM;\n \t\tgoto done;\n@@ -1700,7 +1699,7 @@ ice_set_ringparam(struct net_device *netdev, struct ethtool_ringparam *ring)\n \t\t vsi->rx_rings[0]->count, new_rx_cnt);\n \n \trx_rings = devm_kcalloc(&pf->pdev->dev, vsi->alloc_rxq,\n-\t\t\t\tsizeof(struct ice_ring), GFP_KERNEL);\n+\t\t\t\tsizeof(*rx_rings), GFP_KERNEL);\n \tif (!rx_rings) {\n \t\terr = -ENOMEM;\n \t\tgoto done;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c\nindex 27c3760ae5cb..82aae530d6c5 100644\n--- a/drivers/net/ethernet/intel/ice/ice_lib.c\n+++ b/drivers/net/ethernet/intel/ice/ice_lib.c\n@@ -249,12 +249,12 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors)\n \n \t/* allocate memory for both Tx and Rx ring pointers */\n \tvsi->tx_rings = devm_kcalloc(&pf->pdev->dev, vsi->alloc_txq,\n-\t\t\t\t sizeof(struct ice_ring *), GFP_KERNEL);\n+\t\t\t\t sizeof(*vsi->tx_rings), GFP_KERNEL);\n \tif (!vsi->tx_rings)\n \t\tgoto err_txrings;\n \n \tvsi->rx_rings = devm_kcalloc(&pf->pdev->dev, vsi->alloc_rxq,\n-\t\t\t\t sizeof(struct ice_ring *), GFP_KERNEL);\n+\t\t\t\t sizeof(*vsi->rx_rings), GFP_KERNEL);\n \tif (!vsi->rx_rings)\n \t\tgoto err_rxrings;\n \n@@ -262,7 +262,7 @@ static int ice_vsi_alloc_arrays(struct ice_vsi *vsi, bool alloc_qvectors)\n \t\t/* allocate memory for q_vector pointers */\n \t\tvsi->q_vectors = devm_kcalloc(&pf->pdev->dev,\n \t\t\t\t\t vsi->num_q_vectors,\n-\t\t\t\t\t sizeof(struct ice_q_vector *),\n+\t\t\t\t\t sizeof(*vsi->q_vectors),\n \t\t\t\t\t GFP_KERNEL);\n \t\tif (!vsi->q_vectors)\n \t\t\tgoto err_vectors;\n@@ -355,7 +355,7 @@ void ice_vsi_delete(struct ice_vsi *vsi)\n \t\tctxt.vf_num = vsi->vf_id;\n \tctxt.vsi_num = vsi->vsi_num;\n \n-\tmemcpy(&ctxt.info, &vsi->info, sizeof(struct ice_aqc_vsi_props));\n+\tmemcpy(&ctxt.info, &vsi->info, sizeof(ctxt.info));\n \n \tstatus = ice_free_vsi(&pf->hw, vsi->idx, &ctxt, false, NULL);\n \tif (status)\n@@ -1620,7 +1620,7 @@ ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings, int offset)\n \tu16 buf_len, i, pf_q;\n \tint err = 0, tc;\n \n-\tbuf_len = sizeof(struct ice_aqc_add_tx_qgrp);\n+\tbuf_len = sizeof(*qg_buf);\n \tqg_buf = devm_kzalloc(&pf->pdev->dev, buf_len, GFP_KERNEL);\n \tif (!qg_buf)\n \t\treturn -ENOMEM;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c\nindex 9d266d754445..0731b8994958 100644\n--- a/drivers/net/ethernet/intel/ice/ice_main.c\n+++ b/drivers/net/ethernet/intel/ice/ice_main.c\n@@ -1513,8 +1513,8 @@ static int ice_cfg_netdev(struct ice_vsi *vsi)\n \tu8 mac_addr[ETH_ALEN];\n \tint err;\n \n-\tnetdev = alloc_etherdev_mqs(sizeof(struct ice_netdev_priv),\n-\t\t\t\t vsi->alloc_txq, vsi->alloc_rxq);\n+\tnetdev = alloc_etherdev_mqs(sizeof(*np), vsi->alloc_txq,\n+\t\t\t\t vsi->alloc_rxq);\n \tif (!netdev)\n \t\treturn -ENOMEM;\n \n@@ -1867,7 +1867,7 @@ static int ice_ena_msix_range(struct ice_pf *pf)\n \tv_left -= pf->num_lan_msix;\n \n \tpf->msix_entries = devm_kcalloc(&pf->pdev->dev, v_budget,\n-\t\t\t\t\tsizeof(struct msix_entry), GFP_KERNEL);\n+\t\t\t\t\tsizeof(*pf->msix_entries), GFP_KERNEL);\n \n \tif (!pf->msix_entries) {\n \t\terr = -ENOMEM;\n@@ -1955,7 +1955,6 @@ static void ice_clear_interrupt_scheme(struct ice_pf *pf)\n static int ice_init_interrupt_scheme(struct ice_pf *pf)\n {\n \tint vectors = 0, hw_vectors = 0;\n-\tssize_t size;\n \n \tif (test_bit(ICE_FLAG_MSIX_ENA, pf->flags))\n \t\tvectors = ice_ena_msix_range(pf);\n@@ -1966,9 +1965,9 @@ static int ice_init_interrupt_scheme(struct ice_pf *pf)\n \t\treturn vectors;\n \n \t/* set up vector assignment tracking */\n-\tsize = sizeof(struct ice_res_tracker) + (sizeof(u16) * vectors);\n-\n-\tpf->sw_irq_tracker = devm_kzalloc(&pf->pdev->dev, size, GFP_KERNEL);\n+\tpf->sw_irq_tracker =\n+\t\tdevm_kzalloc(&pf->pdev->dev, sizeof(*pf->sw_irq_tracker) +\n+\t\t\t (sizeof(u16) * vectors), GFP_KERNEL);\n \tif (!pf->sw_irq_tracker) {\n \t\tice_dis_msix(pf);\n \t\treturn -ENOMEM;\n@@ -1980,9 +1979,9 @@ static int ice_init_interrupt_scheme(struct ice_pf *pf)\n \n \t/* set up HW vector assignment tracking */\n \thw_vectors = pf->hw.func_caps.common_cap.num_msix_vectors;\n-\tsize = sizeof(struct ice_res_tracker) + (sizeof(u16) * hw_vectors);\n-\n-\tpf->hw_irq_tracker = devm_kzalloc(&pf->pdev->dev, size, GFP_KERNEL);\n+\tpf->hw_irq_tracker =\n+\t\tdevm_kzalloc(&pf->pdev->dev, sizeof(*pf->hw_irq_tracker) +\n+\t\t\t (sizeof(u16) * hw_vectors), GFP_KERNEL);\n \tif (!pf->hw_irq_tracker) {\n \t\tice_clear_interrupt_scheme(pf);\n \t\treturn -ENOMEM;\n@@ -2116,7 +2115,7 @@ static int ice_probe(struct pci_dev *pdev,\n \t}\n \n \tpf->vsi = devm_kcalloc(&pdev->dev, pf->num_alloc_vsi,\n-\t\t\t sizeof(struct ice_vsi *), GFP_KERNEL);\n+\t\t\t sizeof(*pf->vsi), GFP_KERNEL);\n \tif (!pf->vsi) {\n \t\terr = -ENOMEM;\n \t\tgoto err_init_pf_unroll;\n@@ -2148,7 +2147,7 @@ static int ice_probe(struct pci_dev *pdev,\n \t}\n \n \t/* create switch struct for the switch element created by FW on boot */\n-\tpf->first_sw = devm_kzalloc(&pdev->dev, sizeof(struct ice_sw),\n+\tpf->first_sw = devm_kzalloc(&pdev->dev, sizeof(*pf->first_sw),\n \t\t\t\t GFP_KERNEL);\n \tif (!pf->first_sw) {\n \t\terr = -ENOMEM;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_sched.c b/drivers/net/ethernet/intel/ice/ice_sched.c\nindex 81fb7d19c0fd..f355f59d8b64 100644\n--- a/drivers/net/ethernet/intel/ice/ice_sched.c\n+++ b/drivers/net/ethernet/intel/ice/ice_sched.c\n@@ -1066,11 +1066,10 @@ enum ice_status ice_sched_query_res_alloc(struct ice_hw *hw)\n \t\thw->max_children[i] = le16_to_cpu(max_sibl);\n \t}\n \n-\thw->layer_info = (struct ice_aqc_layer_props *)\n-\t\t\t devm_kmemdup(ice_hw_to_dev(hw), buf->layer_props,\n-\t\t\t\t (hw->num_tx_sched_layers *\n-\t\t\t\t\tsizeof(*hw->layer_info)),\n-\t\t\t\t GFP_KERNEL);\n+\thw->layer_info = devm_kmemdup(ice_hw_to_dev(hw), buf->layer_props,\n+\t\t\t\t (hw->num_tx_sched_layers *\n+\t\t\t\t sizeof(*hw->layer_info)),\n+\t\t\t\t GFP_KERNEL);\n \tif (!hw->layer_info) {\n \t\tstatus = ICE_ERR_NO_MEMORY;\n \t\tgoto sched_query_out;\ndiff --git a/drivers/net/ethernet/intel/ice/ice_switch.c b/drivers/net/ethernet/intel/ice/ice_switch.c\nindex 3c5a66edaf7f..528b90cdd9da 100644\n--- a/drivers/net/ethernet/intel/ice/ice_switch.c\n+++ b/drivers/net/ethernet/intel/ice/ice_switch.c\n@@ -98,7 +98,7 @@ enum ice_status ice_init_def_sw_recp(struct ice_hw *hw)\n \tu8 i;\n \n \trecps = devm_kcalloc(ice_hw_to_dev(hw), ICE_MAX_NUM_RECIPES,\n-\t\t\t sizeof(struct ice_sw_recipe), GFP_KERNEL);\n+\t\t\t sizeof(*recps), GFP_KERNEL);\n \tif (!recps)\n \t\treturn ICE_ERR_NO_MEMORY;\n \ndiff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c\nindex 2357fcac996b..67d129bfe489 100644\n--- a/drivers/net/ethernet/intel/ice/ice_txrx.c\n+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c\n@@ -48,7 +48,6 @@ static struct netdev_queue *txring_txq(const struct ice_ring *ring)\n */\n void ice_clean_tx_ring(struct ice_ring *tx_ring)\n {\n-\tunsigned long size;\n \tu16 i;\n \n \t/* ring already cleared, nothing to do */\n@@ -59,8 +58,7 @@ void ice_clean_tx_ring(struct ice_ring *tx_ring)\n \tfor (i = 0; i < tx_ring->count; i++)\n \t\tice_unmap_and_free_tx_buf(tx_ring, &tx_ring->tx_buf[i]);\n \n-\tsize = sizeof(struct ice_tx_buf) * tx_ring->count;\n-\tmemset(tx_ring->tx_buf, 0, size);\n+\tmemset(tx_ring->tx_buf, 0, sizeof(*tx_ring->tx_buf) * tx_ring->count);\n \n \t/* Zero out the descriptor ring */\n \tmemset(tx_ring->desc, 0, tx_ring->size);\n@@ -226,21 +224,21 @@ static bool ice_clean_tx_irq(struct ice_vsi *vsi, struct ice_ring *tx_ring,\n int ice_setup_tx_ring(struct ice_ring *tx_ring)\n {\n \tstruct device *dev = tx_ring->dev;\n-\tint bi_size;\n \n \tif (!dev)\n \t\treturn -ENOMEM;\n \n \t/* warn if we are about to overwrite the pointer */\n \tWARN_ON(tx_ring->tx_buf);\n-\tbi_size = sizeof(struct ice_tx_buf) * tx_ring->count;\n-\ttx_ring->tx_buf = devm_kzalloc(dev, bi_size, GFP_KERNEL);\n+\ttx_ring->tx_buf =\n+\t\tdevm_kzalloc(dev, sizeof(*tx_ring->tx_buf) * tx_ring->count,\n+\t\t\t GFP_KERNEL);\n \tif (!tx_ring->tx_buf)\n \t\treturn -ENOMEM;\n \n \t/* round up to nearest 4K */\n-\ttx_ring->size = tx_ring->count * sizeof(struct ice_tx_desc);\n-\ttx_ring->size = ALIGN(tx_ring->size, 4096);\n+\ttx_ring->size = ALIGN(tx_ring->count * sizeof(struct ice_tx_desc),\n+\t\t\t 4096);\n \ttx_ring->desc = dmam_alloc_coherent(dev, tx_ring->size, &tx_ring->dma,\n \t\t\t\t\t GFP_KERNEL);\n \tif (!tx_ring->desc) {\n@@ -267,7 +265,6 @@ int ice_setup_tx_ring(struct ice_ring *tx_ring)\n void ice_clean_rx_ring(struct ice_ring *rx_ring)\n {\n \tstruct device *dev = rx_ring->dev;\n-\tunsigned long size;\n \tu16 i;\n \n \t/* ring already cleared, nothing to do */\n@@ -292,8 +289,7 @@ void ice_clean_rx_ring(struct ice_ring *rx_ring)\n \t\trx_buf->page_offset = 0;\n \t}\n \n-\tsize = sizeof(struct ice_rx_buf) * rx_ring->count;\n-\tmemset(rx_ring->rx_buf, 0, size);\n+\tmemset(rx_ring->rx_buf, 0, sizeof(*rx_ring->rx_buf) * rx_ring->count);\n \n \t/* Zero out the descriptor ring */\n \tmemset(rx_ring->desc, 0, rx_ring->size);\n@@ -331,15 +327,15 @@ void ice_free_rx_ring(struct ice_ring *rx_ring)\n int ice_setup_rx_ring(struct ice_ring *rx_ring)\n {\n \tstruct device *dev = rx_ring->dev;\n-\tint bi_size;\n \n \tif (!dev)\n \t\treturn -ENOMEM;\n \n \t/* warn if we are about to overwrite the pointer */\n \tWARN_ON(rx_ring->rx_buf);\n-\tbi_size = sizeof(struct ice_rx_buf) * rx_ring->count;\n-\trx_ring->rx_buf = devm_kzalloc(dev, bi_size, GFP_KERNEL);\n+\trx_ring->rx_buf =\n+\t\tdevm_kzalloc(dev, sizeof(*rx_ring->rx_buf) * rx_ring->count,\n+\t\t\t GFP_KERNEL);\n \tif (!rx_ring->rx_buf)\n \t\treturn -ENOMEM;\n \n", "prefixes": [ "S11", "04/16" ] }