From: Zhu Yanjun <yanjun.zhu@linux.dev>
To: Leon Romanovsky <leon@kernel.org>, Jason Gunthorpe <jgg@nvidia.com>
Cc: Leon Romanovsky <leonro@nvidia.com>, linux-rdma@vger.kernel.org
Subject: Re: [PATCH rdma-next] RDMA/mlx5: Avoid flexible array warning
Date: Wed, 21 May 2025 20:27:42 +0200 [thread overview]
Message-ID: <ac9cb366-ec1b-4331-8d2b-8f6bf7cc556e@linux.dev> (raw)
In-Reply-To: <7b891b96a9fc053d01284c184d25ae98d35db2d4.1747827041.git.leon@kernel.org>
在 2025/5/21 13:34, Leon Romanovsky 写道:
> From: Leon Romanovsky <leonro@nvidia.com>
>
> The following warning is reported by sparse tool:
> drivers/infiniband/hw/mlx5/fs.c:1664:26: warning: array of flexible
> structures
>
> Avoid it by simply splitting array into two separate structs.
>
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
In my local host, I can reproduce this problem. And I think that this
commit can fix this problem.
Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev>
Zhu Yanjun
> ---
> drivers/infiniband/hw/mlx5/fs.c | 58 ++++++++++++---------------------
> 1 file changed, 21 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/infiniband/hw/mlx5/fs.c b/drivers/infiniband/hw/mlx5/fs.c
> index 251246c73b339..1d67f0ce6b59a 100644
> --- a/drivers/infiniband/hw/mlx5/fs.c
> +++ b/drivers/infiniband/hw/mlx5/fs.c
> @@ -1645,11 +1645,6 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev,
> return _create_flow_rule(dev, ft_prio, flow_attr, dst, 0, NULL);
> }
>
> -enum {
> - LEFTOVERS_MC,
> - LEFTOVERS_UC,
> -};
> -
> static struct mlx5_ib_flow_handler *create_leftovers_rule(struct mlx5_ib_dev *dev,
> struct mlx5_ib_flow_prio *ft_prio,
> struct ib_flow_attr *flow_attr,
> @@ -1659,43 +1654,32 @@ static struct mlx5_ib_flow_handler *create_leftovers_rule(struct mlx5_ib_dev *de
> struct mlx5_ib_flow_handler *handler = NULL;
>
> static struct {
> - struct ib_flow_attr flow_attr;
> struct ib_flow_spec_eth eth_flow;
> - } leftovers_specs[] = {
> - [LEFTOVERS_MC] = {
> - .flow_attr = {
> - .num_of_specs = 1,
> - .size = sizeof(leftovers_specs[0])
> - },
> - .eth_flow = {
> - .type = IB_FLOW_SPEC_ETH,
> - .size = sizeof(struct ib_flow_spec_eth),
> - .mask = {.dst_mac = {0x1} },
> - .val = {.dst_mac = {0x1} }
> - }
> - },
> - [LEFTOVERS_UC] = {
> - .flow_attr = {
> - .num_of_specs = 1,
> - .size = sizeof(leftovers_specs[0])
> - },
> - .eth_flow = {
> - .type = IB_FLOW_SPEC_ETH,
> - .size = sizeof(struct ib_flow_spec_eth),
> - .mask = {.dst_mac = {0x1} },
> - .val = {.dst_mac = {} }
> - }
> - }
> - };
> + struct ib_flow_attr flow_attr;
> + } leftovers_wc = { .flow_attr = { .num_of_specs = 1,
> + .size = sizeof(leftovers_wc) },
> + .eth_flow = {
> + .type = IB_FLOW_SPEC_ETH,
> + .size = sizeof(struct ib_flow_spec_eth),
> + .mask = { .dst_mac = { 0x1 } },
> + .val = { .dst_mac = { 0x1 } } } };
>
> - handler = create_flow_rule(dev, ft_prio,
> - &leftovers_specs[LEFTOVERS_MC].flow_attr,
> - dst);
> + static struct {
> + struct ib_flow_spec_eth eth_flow;
> + struct ib_flow_attr flow_attr;
> + } leftovers_uc = { .flow_attr = { .num_of_specs = 1,
> + .size = sizeof(leftovers_uc) },
> + .eth_flow = {
> + .type = IB_FLOW_SPEC_ETH,
> + .size = sizeof(struct ib_flow_spec_eth),
> + .mask = { .dst_mac = { 0x1 } },
> + .val = { .dst_mac = {} } } };
> +
> + handler = create_flow_rule(dev, ft_prio, &leftovers_wc.flow_attr, dst);
> if (!IS_ERR(handler) &&
> flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT) {
> handler_ucast = create_flow_rule(dev, ft_prio,
> - &leftovers_specs[LEFTOVERS_UC].flow_attr,
> - dst);
> + &leftovers_uc.flow_attr, dst);
> if (IS_ERR(handler_ucast)) {
> mlx5_del_flow_rules(handler->rule);
> ft_prio->refcount--;
next prev parent reply other threads:[~2025-05-21 18:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-21 11:34 [PATCH rdma-next] RDMA/mlx5: Avoid flexible array warning Leon Romanovsky
2025-05-21 18:27 ` Zhu Yanjun [this message]
2025-05-25 7:52 ` Leon Romanovsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ac9cb366-ec1b-4331-8d2b-8f6bf7cc556e@linux.dev \
--to=yanjun.zhu@linux.dev \
--cc=jgg@nvidia.com \
--cc=leon@kernel.org \
--cc=leonro@nvidia.com \
--cc=linux-rdma@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox