Building with clang and -Wunreachable-code produces warnings:

- In flow_verbs_discover_priorities()
    - With recent rdma-core versions, a condition is skipped
      because of goto statement under ifdefs for new version.
- In flow_hw_validate_rule_pattern() and
  flow_hw_validate_rule_actions()
    - On variable declarations inside switch at the beginning of
      switch blocks.

This patch silences these warnings.
First issue is resolved by reorganizing ifdef guards
to remove the need for goto.
Second issue is resolved by moving variable declarations
out of the switch block.

Bugzilla ID: 2140
Fixes: 1d47e9335e2f ("net/mlx5: improve Verbs flow priority discovery")
Fixes: 57c7b94301ee ("net/mlx5: add async flow operation validation")
Fixes: 179e70fd7ad2 ("net/mlx5: fix connection tracking state item validation")
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Reported-by: Stephen Hemminger <[email protected]>
Signed-off-by: Dariusz Sosnowski <[email protected]>
---
 drivers/net/mlx5/mlx5_flow_hw.c    | 17 ++++++++---------
 drivers/net/mlx5/mlx5_flow_verbs.c | 11 +++++++----
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 6e6bf07799..62482c911d 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -17351,6 +17351,11 @@ flow_hw_validate_rule_pattern(struct rte_eth_dev *dev,
                pt_item++;
 
        for (; pt_item->type != RTE_FLOW_ITEM_TYPE_END; pt_item++, items++) {
+               const struct rte_flow_item_ethdev *ethdev;
+               const struct rte_flow_item_tx_queue *tx_queue;
+               const struct rte_flow_item_conntrack *spec;
+               struct mlx5_txq_ctrl *txq;
+
                if (pt_item->type != items->type)
                        return rte_flow_error_set(error, EINVAL, 
RTE_FLOW_ERROR_TYPE_ITEM,
                                                  items, "Item type does not 
match the template");
@@ -17375,11 +17380,6 @@ flow_hw_validate_rule_pattern(struct rte_eth_dev *dev,
                                                  items, "Item spec is 
required");
 
                switch (items->type) {
-               const struct rte_flow_item_ethdev *ethdev;
-               const struct rte_flow_item_tx_queue *tx_queue;
-               const struct rte_flow_item_conntrack *spec;
-               struct mlx5_txq_ctrl *txq;
-
                case RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT:
                        ethdev = items->spec;
                        if (flow_hw_validate_target_port_id(dev, 
ethdev->port_id)) {
@@ -17486,7 +17486,10 @@ flow_hw_validate_rule_actions(struct rte_eth_dev *dev,
         * Configuration of masked actions is ignored.
         */
        LIST_FOREACH(act_data, &hw_acts->act_list, next) {
+               const struct rte_flow_action_modify_field *mf;
+               const struct rte_flow_action_ethdev *ethdev;
                const struct rte_flow_action *user_action;
+               enum rte_flow_action_type expected_type;
 
                user_action = &actions[act_data->action_src];
 
@@ -17507,10 +17510,6 @@ flow_hw_validate_rule_actions(struct rte_eth_dev *dev,
                                                  "Action requires 
configuration");
 
                switch ((int)user_action->type) {
-               enum rte_flow_action_type expected_type;
-               const struct rte_flow_action_ethdev *ethdev;
-               const struct rte_flow_action_modify_field *mf;
-
                case RTE_FLOW_ACTION_TYPE_INDIRECT:
                        expected_type = act_data->indirect.expected_type;
                        if (!flow_hw_valid_indirect_action_type(user_action, 
expected_type))
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c 
b/drivers/net/mlx5/mlx5_flow_verbs.c
index eb576f73d4..c0c0da5833 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -85,10 +85,15 @@ flow_verbs_discover_priorities(struct rte_eth_dev *dev,
        int priority = 0;
 
 #if defined(HAVE_MLX5DV_DR_DEVX_PORT) || defined(HAVE_MLX5DV_DR_DEVX_PORT_V35)
+       RTE_SET_USED(flow_attr);
+       RTE_SET_USED(flow);
+       RTE_SET_USED(drop);
+       RTE_SET_USED(i);
+       RTE_SET_USED(vprio);
+       RTE_SET_USED(vprio_n);
        /* If DevX supported, driver must support 16 verbs flow priorities. */
        priority = 16;
-       goto out;
-#endif
+#else
        if (!drop->qp) {
                rte_errno = ENOTSUP;
                return -rte_errno;
@@ -101,8 +106,6 @@ flow_verbs_discover_priorities(struct rte_eth_dev *dev,
                claim_zero(mlx5_glue->destroy_flow(flow));
                priority = vprio[i];
        }
-#if defined(HAVE_MLX5DV_DR_DEVX_PORT) || defined(HAVE_MLX5DV_DR_DEVX_PORT_V35)
-out:
 #endif
        DRV_LOG(INFO, "port %u supported flow priorities:"
                " 0-%d for ingress or egress root table,"
-- 
2.43.0

Reply via email to