Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/66424/?format=api
http://patches.dpdk.org/api/patches/66424/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/patch/20200309114357.31800-8-qi.z.zhang@intel.com/", "project": { "id": 1, "url": "http://patches.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<20200309114357.31800-8-qi.z.zhang@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200309114357.31800-8-qi.z.zhang@intel.com", "date": "2020-03-09T11:43:36", "name": "[07/28] net/ice/base: use struct size helper", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "87138d2c9f63ad688cd59450ba0bb9e27f1aae2f", "submitter": { "id": 504, "url": "http://patches.dpdk.org/api/people/504/?format=api", "name": "Qi Zhang", "email": "qi.z.zhang@intel.com" }, "delegate": { "id": 31221, "url": "http://patches.dpdk.org/api/users/31221/?format=api", "username": "yexl", "first_name": "xiaolong", "last_name": "ye", "email": "xiaolong.ye@intel.com" }, "mbox": "http://patches.dpdk.org/project/dpdk/patch/20200309114357.31800-8-qi.z.zhang@intel.com/mbox/", "series": [ { "id": 8843, "url": "http://patches.dpdk.org/api/series/8843/?format=api", "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=8843", "date": "2020-03-09T11:43:29", "name": "update ice base code", "version": 1, "mbox": "http://patches.dpdk.org/series/8843/mbox/" } ], "comments": "http://patches.dpdk.org/api/patches/66424/comments/", "check": "warning", "checks": "http://patches.dpdk.org/api/patches/66424/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id C9B10A052E;\n\tMon, 9 Mar 2020 12:41:44 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 52E6C1C0C7;\n\tMon, 9 Mar 2020 12:40:47 +0100 (CET)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n by dpdk.org (Postfix) with ESMTP id 3D6391C0B8\n for <dev@dpdk.org>; Mon, 9 Mar 2020 12:40:45 +0100 (CET)", "from fmsmga002.fm.intel.com ([10.253.24.26])\n by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 09 Mar 2020 04:40:44 -0700", "from dpdk51.sh.intel.com ([10.67.110.245])\n by fmsmga002.fm.intel.com with ESMTP; 09 Mar 2020 04:40:43 -0700" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.70,533,1574150400\"; d=\"scan'208\";a=\"276483536\"", "From": "Qi Zhang <qi.z.zhang@intel.com>", "To": "qiming.yang@intel.com,\n\tbeilei.xing@intel.com", "Cc": "xiaolong.ye@intel.com, dev@dpdk.org, Qi Zhang <qi.z.zhang@intel.com>,\n Bruce Allan <bruce.w.allan@intel.com>,\n Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>", "Date": "Mon, 9 Mar 2020 19:43:36 +0800", "Message-Id": "<20200309114357.31800-8-qi.z.zhang@intel.com>", "X-Mailer": "git-send-email 2.13.6", "In-Reply-To": "<20200309114357.31800-1-qi.z.zhang@intel.com>", "References": "<20200309114357.31800-1-qi.z.zhang@intel.com>", "Subject": "[dpdk-dev] [PATCH 07/28] net/ice/base: use struct size helper", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "DPDK patches and discussions <dev.dpdk.org>", "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n <mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://mails.dpdk.org/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "For structures using the common C \"struct hack\" technique to create a\nflexible length structure member at the end of the structure, use the\nice_struct_size macro to determine the length of the structure instead of\nopen coding the calculation.\n\nSigned-off-by: Bruce Allan <bruce.w.allan@intel.com>\nSigned-off-by: Paul M Stillwell Jr <paul.m.stillwell.jr@intel.com>\nSigned-off-by: Qi Zhang <qi.z.zhang@intel.com>\n---\n drivers/net/ice/base/ice_common.c | 4 ++--\n drivers/net/ice/base/ice_flex_pipe.c | 5 ++---\n drivers/net/ice/base/ice_sched.c | 2 +-\n drivers/net/ice/base/ice_type.h | 3 +++\n 4 files changed, 8 insertions(+), 6 deletions(-)", "diff": "diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c\nindex 9ef1aeef2..4b1b31066 100644\n--- a/drivers/net/ice/base/ice_common.c\n+++ b/drivers/net/ice/base/ice_common.c\n@@ -1680,7 +1680,7 @@ ice_alloc_hw_res(struct ice_hw *hw, u16 type, u16 num, bool btm, u16 *res)\n \tenum ice_status status;\n \tu16 buf_len;\n \n-\tbuf_len = sizeof(*buf) + sizeof(buf->elem) * (num - 1);\n+\tbuf_len = ice_struct_size(buf, elem, num - 1);\n \tbuf = (struct ice_aqc_alloc_free_res_elem *)\n \t\tice_malloc(hw, buf_len);\n \tif (!buf)\n@@ -1720,7 +1720,7 @@ ice_free_hw_res(struct ice_hw *hw, u16 type, u16 num, u16 *res)\n \tenum ice_status status;\n \tu16 buf_len;\n \n-\tbuf_len = sizeof(*buf) + sizeof(buf->elem) * (num - 1);\n+\tbuf_len = ice_struct_size(buf, elem, num - 1);\n \tbuf = (struct ice_aqc_alloc_free_res_elem *)ice_malloc(hw, buf_len);\n \tif (!buf)\n \t\treturn ICE_ERR_NO_MEMORY;\ndiff --git a/drivers/net/ice/base/ice_flex_pipe.c b/drivers/net/ice/base/ice_flex_pipe.c\nindex 1598efd67..82b27de0e 100644\n--- a/drivers/net/ice/base/ice_flex_pipe.c\n+++ b/drivers/net/ice/base/ice_flex_pipe.c\n@@ -1136,8 +1136,7 @@ static enum ice_status ice_get_pkg_info(struct ice_hw *hw)\n \n \tice_debug(hw, ICE_DBG_TRACE, \"%s\\n\", __func__);\n \n-\tsize = sizeof(*pkg_info) + (sizeof(pkg_info->pkg_info[0]) *\n-\t\t\t\t (ICE_PKG_CNT - 1));\n+\tsize = ice_struct_size(pkg_info, pkg_info, ICE_PKG_CNT - 1);\n \tpkg_info = (struct ice_aqc_get_pkg_info_resp *)ice_malloc(hw, size);\n \tif (!pkg_info)\n \t\treturn ICE_ERR_NO_MEMORY;\n@@ -1209,7 +1208,7 @@ static enum ice_status ice_verify_pkg(struct ice_pkg_hdr *pkg, u32 len)\n \t\treturn ICE_ERR_CFG;\n \n \t/* make sure segment array fits in package length */\n-\tif (len < sizeof(*pkg) + ((seg_count - 1) * sizeof(pkg->seg_offset)))\n+\tif (len < ice_struct_size(pkg, seg_offset, seg_count - 1))\n \t\treturn ICE_ERR_BUF_TOO_SHORT;\n \n \t/* all segments must fit within length */\ndiff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c\nindex 26c4ba36f..575c2ab58 100644\n--- a/drivers/net/ice/base/ice_sched.c\n+++ b/drivers/net/ice/base/ice_sched.c\n@@ -899,7 +899,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,\n \tu16 buf_size;\n \tu32 teid;\n \n-\tbuf_size = sizeof(*buf) + sizeof(*buf->generic) * (num_nodes - 1);\n+\tbuf_size = ice_struct_size(buf, generic, num_nodes - 1);\n \tbuf = (struct ice_aqc_add_elem *)ice_malloc(hw, buf_size);\n \tif (!buf)\n \t\treturn ICE_ERR_NO_MEMORY;\ndiff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h\nindex 237220ee8..59dce32fa 100644\n--- a/drivers/net/ice/base/ice_type.h\n+++ b/drivers/net/ice/base/ice_type.h\n@@ -34,6 +34,9 @@\n \n #define IS_ASCII(_ch)\t((_ch) < 0x80)\n \n+#define ice_struct_size(ptr, field, num) \\\n+\t(sizeof(*(ptr)) + sizeof(*(ptr)->field) * (num))\n+\n #include \"ice_status.h\"\n #include \"ice_hw_autogen.h\"\n #include \"ice_devids.h\"\n", "prefixes": [ "07/28" ] }{ "id": 66424, "url": "