IB/mlx4: avoid a -Wmaybe-uninitialize warning
Subsystems (4)
PATCH 1/1 IB/mlx4: avoid a -Wmaybe-uninitialize warning
There is an old warning about mlx4_SW2HW_EQ_wrapper on x86:
ethernet/mellanox/mlx4/resource_tracker.c: In function ‘mlx4_SW2HW_EQ_wrapper’:ethernet/mellanox/mlx4/resource_tracker.c:3071:10: error: ‘eq’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
The problem here is that gcc won't track the state of the variable across a spin_unlock. Moving the assignment out of the lock is safe here and avoids the warning.
--- drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +3 -2
@@ -1605,13 +1605,14 @@ static int eq_res_start_move_to(struct mlx4_dev *dev, int slave, int index, r->com.from_state = r->com.state; r->com.to_state = state; r->com.state =RES_EQ_BUSY ; -if (eq) - *eq = r; } }spin_unlock_irq (mlx4_tlock (dev)); +if (!err && eq) + *eq = r; +return err; }
Signature · 1 line
2.9.0
Quoted 10 lines · Arnd Bergmann
There is an old warning about
mlx4_SW2HW_EQ_wrapperon x86:
ethernet/mellanox/mlx4/resource_tracker.c: In function ‘mlx4_SW2HW_EQ_wrapper’:ethernet/mellanox/mlx4/resource_tracker.c:3071:10: error: ‘eq’ may be used uninitialized in this function [-Werror=maybe-uninitialized]The problem here is that gcc won't track the state of the variable across a
spin_unlock. Moving the assignment out of the lock is safe here and avoids the warning.Signed-off-by Arnd Bergmann <[email protected]>
Quoted 26 lines
--- drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +3
-2@@ -1605,13 +1605,14 @@ static int eq_res_start_move_to(struct mlx4_dev *dev, int slave, int index, r->com.from_state = r->com.state; r->com.to_state = state; r->com.state =RES_EQ_BUSY ; -if (eq) - *eq = r; } }spin_unlock_irq (mlx4_tlock (dev)); +if (!err && eq) + *eq = r; +return err; }
Doug Ledford
AppliedQuoted 10 lines · Arnd Bergmann
There is an old warning about
mlx4_SW2HW_EQ_wrapperon x86:
ethernet/mellanox/mlx4/resource_tracker.c: In function ‘mlx4_SW2HW_EQ_wrapper’:ethernet/mellanox/mlx4/resource_tracker.c:3071:10: error: ‘eq’ may be used uninitialized in this function [-Werror=maybe-uninitialized]The problem here is that gcc won't track the state of the variable across a
spin_unlock. Moving the assignment out of the lock is safe here and avoids the warning.Signed-off-by Arnd Bergmann <[email protected]>
Thanks, applied.
Signature · 2 lines
Doug Ledford <[email protected]> GPG Key ID: 0E572FDD