Skip to contentSkip to conversation

net/bnxt: avoid maybe-uninitialized warning in flow counters

PATCH In review Manish Kurup 1 participant 2 messages Oct 5 – Oct 20 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bnxt: avoid maybe-uninitialized warning in flow counters

From: Shuanglin Wang <[email protected]>

In ulp_fc_mgr_cntr_set, ulp_fc_mgr_cntr_reset, and ulp_fc_mgr_cntr_parent_flow_set, sw_cntr_idx was declared without an initializer. The variable is always written through a pointer by ulp_fc_mgr_sw_cntr_idx_get before it is read, but GCC -Wmaybe-uninitialized cannot prove this from the function signature alone. Initialize sw_cntr_idx to 0 at each declaration to silence the three build warnings.

---
 drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/bnxt/tf_ulp/ulp_fc_mgr.c +3 -3
index c765e123fe..4f02dd2c20 100644
@@ -437,7 +437,7 @@ int32_t ulp_fc_mgr_cntr_set(struct bnxt_ulp_context *ctxt, enum tf_dir dir,
 			    enum bnxt_ulp_session_type session_type)
 {
 	struct bnxt_ulp_fc_info *ulp_fc_info;
-	uint32_t sw_cntr_idx;
+	uint32_t sw_cntr_idx = 0;
 
 	ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt);
 	if (!ulp_fc_info)
@@ -473,7 +473,7 @@ int32_t ulp_fc_mgr_cntr_reset(struct bnxt_ulp_context *ctxt, uint8_t dir,
 			      uint32_t hw_cntr_id)
 {
 	struct bnxt_ulp_fc_info *ulp_fc_info;
-	uint32_t sw_cntr_idx;
+	uint32_t sw_cntr_idx = 0;
 
 	ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt);
 	if (!ulp_fc_info)
@@ -691,7 +691,7 @@ int32_t ulp_fc_mgr_cntr_parent_flow_set(struct bnxt_ulp_context *ctxt,
 					uint32_t pc_idx)
 {
 	struct bnxt_ulp_fc_info *ulp_fc_info;
-	uint32_t sw_cntr_idx;
+	uint32_t sw_cntr_idx = 0;
 	int32_t rc = 0;
 
 	ulp_fc_info = bnxt_ulp_cntxt_ptr2_fc_info_get(ctxt);
Signature · 1 line
2.31.1
#1 lore raw

Please ignore this patch, it is withdrawn.

The commit message refers to ulp_fc_mgr_sw_cntr_idx_get(), which is not in this tree, and in the three functions it touches sw_cntr_idx is already assigned before it is used, so there is no maybe-uninitialized warning to silence here and the initializer has no effect.

Thanks,
Manish