Skip to content

Commit e91fb8b

Browse files
committed
RDMA/mlx5: Avoid flexible array warning
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. Link: https://patch.msgid.link/7b891b96a9fc053d01284c184d25ae98d35db2d4.1747827041.git.leon@kernel.org Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
1 parent 45611fe commit e91fb8b

File tree

1 file changed

+21
-37
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+21
-37
lines changed

drivers/infiniband/hw/mlx5/fs.c

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,11 +1645,6 @@ static struct mlx5_ib_flow_handler *create_flow_rule(struct mlx5_ib_dev *dev,
16451645
return _create_flow_rule(dev, ft_prio, flow_attr, dst, 0, NULL);
16461646
}
16471647

1648-
enum {
1649-
LEFTOVERS_MC,
1650-
LEFTOVERS_UC,
1651-
};
1652-
16531648
static struct mlx5_ib_flow_handler *create_leftovers_rule(struct mlx5_ib_dev *dev,
16541649
struct mlx5_ib_flow_prio *ft_prio,
16551650
struct ib_flow_attr *flow_attr,
@@ -1659,43 +1654,32 @@ static struct mlx5_ib_flow_handler *create_leftovers_rule(struct mlx5_ib_dev *de
16591654
struct mlx5_ib_flow_handler *handler = NULL;
16601655

16611656
static struct {
1662-
struct ib_flow_attr flow_attr;
16631657
struct ib_flow_spec_eth eth_flow;
1664-
} leftovers_specs[] = {
1665-
[LEFTOVERS_MC] = {
1666-
.flow_attr = {
1667-
.num_of_specs = 1,
1668-
.size = sizeof(leftovers_specs[0])
1669-
},
1670-
.eth_flow = {
1671-
.type = IB_FLOW_SPEC_ETH,
1672-
.size = sizeof(struct ib_flow_spec_eth),
1673-
.mask = {.dst_mac = {0x1} },
1674-
.val = {.dst_mac = {0x1} }
1675-
}
1676-
},
1677-
[LEFTOVERS_UC] = {
1678-
.flow_attr = {
1679-
.num_of_specs = 1,
1680-
.size = sizeof(leftovers_specs[0])
1681-
},
1682-
.eth_flow = {
1683-
.type = IB_FLOW_SPEC_ETH,
1684-
.size = sizeof(struct ib_flow_spec_eth),
1685-
.mask = {.dst_mac = {0x1} },
1686-
.val = {.dst_mac = {} }
1687-
}
1688-
}
1689-
};
1658+
struct ib_flow_attr flow_attr;
1659+
} leftovers_wc = { .flow_attr = { .num_of_specs = 1,
1660+
.size = sizeof(leftovers_wc) },
1661+
.eth_flow = {
1662+
.type = IB_FLOW_SPEC_ETH,
1663+
.size = sizeof(struct ib_flow_spec_eth),
1664+
.mask = { .dst_mac = { 0x1 } },
1665+
.val = { .dst_mac = { 0x1 } } } };
16901666

1691-
handler = create_flow_rule(dev, ft_prio,
1692-
&leftovers_specs[LEFTOVERS_MC].flow_attr,
1693-
dst);
1667+
static struct {
1668+
struct ib_flow_spec_eth eth_flow;
1669+
struct ib_flow_attr flow_attr;
1670+
} leftovers_uc = { .flow_attr = { .num_of_specs = 1,
1671+
.size = sizeof(leftovers_uc) },
1672+
.eth_flow = {
1673+
.type = IB_FLOW_SPEC_ETH,
1674+
.size = sizeof(struct ib_flow_spec_eth),
1675+
.mask = { .dst_mac = { 0x1 } },
1676+
.val = { .dst_mac = {} } } };
1677+
1678+
handler = create_flow_rule(dev, ft_prio, &leftovers_wc.flow_attr, dst);
16941679
if (!IS_ERR(handler) &&
16951680
flow_attr->type == IB_FLOW_ATTR_ALL_DEFAULT) {
16961681
handler_ucast = create_flow_rule(dev, ft_prio,
1697-
&leftovers_specs[LEFTOVERS_UC].flow_attr,
1698-
dst);
1682+
&leftovers_uc.flow_attr, dst);
16991683
if (IS_ERR(handler_ucast)) {
17001684
mlx5_del_flow_rules(handler->rule);
17011685
ft_prio->refcount--;

0 commit comments

Comments
 (0)