Skip to content

Commit 842c3b3

Browse files
committed
mellanox: mlx5: avoid uninitialized variable warning with gcc-12
gcc-12 started warning about 'tracker' being used uninitialized: drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c: In function ‘mlx5_do_bond’: drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c:786:28: warning: ‘tracker’ is used uninitialized [-Wuninitialized] 786 | struct lag_tracker tracker; | ^~~~~~~ which seems to be because it doesn't track how the use (and initialization) is bound by the 'do_bond' flag. But admittedly that 'do_bond' usage is fairly complicated, and involves passing it around as an argument to helper functions, so it's somewhat understandable that gcc doesn't see how that all works. This function could be rewritten to make the use of that tracker variable more obviously safe, but for now I'm just adding the forced initialization of it. Signed-off-by: Linus Torvalds <[email protected]>
1 parent 49beadb commit 842c3b3

File tree

1 file changed

+1
-1
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/lag

1 file changed

+1
-1
lines changed

drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ static void mlx5_do_bond(struct mlx5_lag *ldev)
783783
{
784784
struct mlx5_core_dev *dev0 = ldev->pf[MLX5_LAG_P1].dev;
785785
struct mlx5_core_dev *dev1 = ldev->pf[MLX5_LAG_P2].dev;
786-
struct lag_tracker tracker;
786+
struct lag_tracker tracker = { };
787787
bool do_bond, roce_lag;
788788
int err;
789789
int i;

0 commit comments

Comments
 (0)