* [PATCH rdma-next] RDMA/mlx5: Avoid flexible array warning
@ 2025-05-21 11:34 Leon Romanovsky
2025-05-21 18:27 ` Zhu Yanjun
2025-05-25 7:52 ` Leon Romanovsky
0 siblings, 2 replies; 3+ messages in thread
From: Leon Romanovsky @ 2025-05-21 11:34 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Leon Romanovsky, linux-rdma
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>
---
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--;
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH rdma-next] RDMA/mlx5: Avoid flexible array warning
2025-05-21 11:34 [PATCH rdma-next] RDMA/mlx5: Avoid flexible array warning Leon Romanovsky
@ 2025-05-21 18:27 ` Zhu Yanjun
2025-05-25 7:52 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Zhu Yanjun @ 2025-05-21 18:27 UTC (permalink / raw)
To: Leon Romanovsky, Jason Gunthorpe; +Cc: Leon Romanovsky, linux-rdma
在 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--;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH rdma-next] RDMA/mlx5: Avoid flexible array warning
2025-05-21 11:34 [PATCH rdma-next] RDMA/mlx5: Avoid flexible array warning Leon Romanovsky
2025-05-21 18:27 ` Zhu Yanjun
@ 2025-05-25 7:52 ` Leon Romanovsky
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2025-05-25 7:52 UTC (permalink / raw)
To: Jason Gunthorpe, Leon Romanovsky; +Cc: linux-rdma, Leon Romanovsky
On Wed, 21 May 2025 14:34:58 +0300, Leon Romanovsky wrote:
> 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.
>
>
> [...]
Applied, thanks!
[1/1] RDMA/mlx5: Avoid flexible array warning
https://git.kernel.org/rdma/rdma/c/de748d531c52a5
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-25 7:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 11:34 [PATCH rdma-next] RDMA/mlx5: Avoid flexible array warning Leon Romanovsky
2025-05-21 18:27 ` Zhu Yanjun
2025-05-25 7:52 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox