On 11/4/2021 12:23 PM, Gregory Etelson wrote:
Use `__rte_unused` macro to mask a debug variable instead of `#ifdef`.
This way, if the variable is used in a macro, it does not depend on
how the macro is expanded.

Fixes: 91f0e029ce5f ("net/mlx5: translate flex item pattern into matcher")
Signed-off-by: Gregory Etelson <getel...@nvidia.com>
---
  drivers/net/mlx5/mlx5_flow_flex.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow_flex.c 
b/drivers/net/mlx5/mlx5_flow_flex.c
index bdfa383c45..be0f9821ce 100644
--- a/drivers/net/mlx5/mlx5_flow_flex.c
+++ b/drivers/net/mlx5/mlx5_flow_flex.c
@@ -222,9 +222,7 @@ mlx5_flex_flow_translate_item(struct rte_eth_dev *dev,
                              const struct rte_flow_item *item,
                              bool is_inner)
  {
-#ifdef RTE_LIBRTE_MLX5_DEBUG
-       struct mlx5_priv *priv = dev->data->dev_private;
-#endif
+       __rte_unused struct mlx5_priv *priv = dev->data->dev_private;

Marking the variable as unused to silence compiler for some cases,
but it is indeed used, what about something like this (inspired by
sfc code):

 #if defined(RTE_LIBRTE_MLX5_DEBUG) || defined(RTE_ENABLE_ASSERT)
   struct mlx5_priv *priv = dev->data->dev_private;
 #endif

        const struct rte_flow_item_flex *spec, *mask;
        void *misc4_m = MLX5_ADDR_OF(fte_match_param, matcher,
                                     misc_parameters_4);


Reply via email to