Skip to content

Commit c1c52db

Browse files
bjorn-helgaasdavem330
authored andcommitted
net/mlx4: Avoid 'may be used uninitialized' warnings
With a cross-compiler based on gcc-4.9, I see warnings like the following: drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_CQ_wrapper': drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:3048:10: error: 'cq' may be used uninitialized in this function [-Werror=maybe-uninitialized] cq->mtt = mtt; I think the warning is spurious because we only use cq when cq_res_start_move_to() returns zero, and it always initializes *cq in that case. The srq case is similar. But maybe gcc isn't smart enough to figure that out. Initialize cq and srq explicitly to avoid the warnings. Signed-off-by: Bjorn Helgaas <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e87a468 commit c1c52db

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/net/ethernet/mellanox/mlx4/resource_tracker.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3187,7 +3187,7 @@ int mlx4_SW2HW_CQ_wrapper(struct mlx4_dev *dev, int slave,
31873187
int cqn = vhcr->in_modifier;
31883188
struct mlx4_cq_context *cqc = inbox->buf;
31893189
int mtt_base = cq_get_mtt_addr(cqc) / dev->caps.mtt_entry_sz;
3190-
struct res_cq *cq;
3190+
struct res_cq *cq = NULL;
31913191
struct res_mtt *mtt;
31923192

31933193
err = cq_res_start_move_to(dev, slave, cqn, RES_CQ_HW, &cq);
@@ -3223,7 +3223,7 @@ int mlx4_HW2SW_CQ_wrapper(struct mlx4_dev *dev, int slave,
32233223
{
32243224
int err;
32253225
int cqn = vhcr->in_modifier;
3226-
struct res_cq *cq;
3226+
struct res_cq *cq = NULL;
32273227

32283228
err = cq_res_start_move_to(dev, slave, cqn, RES_CQ_ALLOCATED, &cq);
32293229
if (err)
@@ -3362,7 +3362,7 @@ int mlx4_SW2HW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
33623362
int err;
33633363
int srqn = vhcr->in_modifier;
33643364
struct res_mtt *mtt;
3365-
struct res_srq *srq;
3365+
struct res_srq *srq = NULL;
33663366
struct mlx4_srq_context *srqc = inbox->buf;
33673367
int mtt_base = srq_get_mtt_addr(srqc) / dev->caps.mtt_entry_sz;
33683368

@@ -3406,7 +3406,7 @@ int mlx4_HW2SW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
34063406
{
34073407
int err;
34083408
int srqn = vhcr->in_modifier;
3409-
struct res_srq *srq;
3409+
struct res_srq *srq = NULL;
34103410

34113411
err = srq_res_start_move_to(dev, slave, srqn, RES_SRQ_ALLOCATED, &srq);
34123412
if (err)

0 commit comments

Comments
 (0)