net/mlx5: fix GCC uninitialized variable warning
authorDmitry Kozlyuk <dkozlyuk@nvidia.com>
Tue, 28 Dec 2021 09:17:03 +0000 (11:17 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Thu, 6 Jan 2022 09:09:00 +0000 (10:09 +0100)
commitbe8cda4932eb256caaca90090fe0c6d9c756f852
tree6da7d38512ae4e16c6275af727611fbf79236715
parente50fe91ae329aa1b3ce499897378286353aaf262
net/mlx5: fix GCC uninitialized variable warning

When building with -Db_sanitize=thread, GCC gives a warning:

drivers/net/mlx5/mlx5_flow_meter.c: In function ‘mlx5_flow_meter_create’:
drivers/net/mlx5/mlx5_flow_meter.c:1170:33: warning: ‘legacy_fm’ may be
    used uninitialized in this function [-Wmaybe-uninitialized]

This is a false-positive: legacy_fm is initialized and used
if and only if priv->sh->meter_aso_en is false.
Work around this by initializing legacy_fm to NULL.
Add an assertion before legacy_fm use in case the logic changes.

Fixes: 444320186393 ("net/mlx5: support meter creation with policy")
Cc: stable@dpdk.org
Reported-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Dmitry Kozlyuk <dkozlyuk@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/mlx5_flow_meter.c