Skip to contentSkip to conversation

net/mlx4: suppress 'may be used uninitialized' warning

PATCH In review Greg Thelen 3 participants 4 messages Apr 18, 2017 – Apr 20, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx4: suppress 'may be used uninitialized' warning

gcc 4.8.4 complains that mlx4_SW2HW_MPT_wrapper() uses an uninitialized
'mpt' variable:
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_MPT_wrapper':
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2802:12: warning: 'mpt' may be used uninitialized in this function [-Wmaybe-uninitialized]

     mpt->mtt = mtt;

I think this warning is a false complaint. mpt is only used when mr_res_start_move_to() return zero, and in all such cases it initializes mpt. But apparently gcc cannot see that.

Initialize mpt to avoid the warning.

---
 drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +1 -1
index d8d5d161b8c7..4aa29ee93013 100644
@@ -2749,7 +2749,7 @@ int mlx4_SW2HW_MPT_wrapper(struct mlx4_dev *dev, int slave,
 	int err;
 	int index = vhcr->in_modifier;
 	struct res_mtt *mtt;
-	struct res_mpt *mpt;
+	struct res_mpt *mpt = NULL;
 	int mtt_base = mr_get_mtt_addr(inbox->buf) / dev->caps.mtt_entry_sz;
 	int phys;
 	int id;
Signature · 6 lines
2.12.2.762.g0e3151a226-goog

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 11 lines · Greg Thelen

gcc 4.8.4 complains that mlx4_SW2HW_MPT_wrapper() uses an uninitialized
'mpt' variable:
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_MPT_wrapper':
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2802:12: warning: 'mpt' may be used uninitialized in this function [-Wmaybe-uninitialized]

     mpt->mtt = mtt;

I think this warning is a false complaint. mpt is only used when mr_res_start_move_to() return zero, and in all such cases it initializes mpt.
But apparently gcc cannot see that.

Quoted 4 lines

Initialize mpt to avoid the warning.

---

It looks like other callers of mr_res_start_move_to() have the same "uninitialized" variable.

Thanks

#2 lore raw
Quoted 15 lines · Leon Romanovsky

[ Unknown signature status ]

Quoted 13 lines · Greg Thelen

gcc 4.8.4 complains that mlx4_SW2HW_MPT_wrapper() uses an uninitialized
'mpt' variable:
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_MPT_wrapper':
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2802:12: warning: 'mpt' may be used uninitialized in this function [-Wmaybe-uninitialized]

     mpt->mtt = mtt;

I think this warning is a false complaint. mpt is only used when mr_res_start_move_to() return zero, and in all such cases it initializes mpt.
But apparently gcc cannot see that.

Initialize mpt to avoid the warning.

Quoted 7 lines
Quoted 2 lines

---

It looks like other callers of mr_res_start_move_to() have the same "uninitialized" variable.

Thanks

The above is the only mellanox warning I see. So gcc is able to better analyze the other callsites.

maintainer
#3 lore raw
In reply to Greg Thelen

From: Greg Thelen <[email protected]>
Date: Mon, 17 Apr 2017 23:21:35 -0700

Quoted 6 lines

gcc 4.8.4 complains that mlx4_SW2HW_MPT_wrapper() uses an uninitialized
'mpt' variable:
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c: In function 'mlx4_SW2HW_MPT_wrapper':
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c:2802:12: warning: 'mpt' may be used uninitialized in this function [-Wmaybe-uninitialized]

     mpt->mtt = mtt;
Quoted 7 lines

I think this warning is a false complaint. mpt is only used when mr_res_start_move_to() return zero, and in all such cases it initializes mpt. But apparently gcc cannot see that.

Initialize mpt to avoid the warning.

Appied to net-next.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html