Skip to contentSkip to conversation

net/bnxt: fix build failure

PATCH Superseded Ajit Khaparde 3 participants 7 messages Jul 8, 2021 – Jul 9, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bnxt: fix build failure

Fix build failures because of uninitialized variable usage.

Fixes 05b405d58148 ("net/bnxt: add dpool allocator for EM allocation")
---
 drivers/net/bnxt/tf_core/dpool.c     | 1 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_core/dpool.c +1 -0
index 0dae42b1bb..145efa486f 100644
@@ -125,6 +125,7 @@ int dpool_defrag(struct dpool *dpool,
 		largest_free_size = 0;
 		largest_free_index = 0;
 		count = 0;
+		index = 0;
 
 		for (i = 0; i < dpool->size; i++) {
 			if (DP_IS_FREE(dpool->entry[i].flags)) {
drivers/net/bnxt/tf_ulp/ulp_mapper.c +1 -1
index acd9f996e8..871dbad0fe 100644
@@ -2249,7 +2249,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	struct tf_free_tbl_entry_parms free_parms = { 0 };
 	uint32_t tbl_scope_id;
 	struct tf *tfp;
-	struct bnxt_ulp_glb_resource_info glb_res;
+	struct bnxt_ulp_glb_resource_info glb_res = { 0 };
 	uint16_t bit_size;
 	bool alloc = false;
 	bool write = false;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#2 lore raw
Quoted 7 lines · Thomas Monjalon

09/07/2021 00:49, Ajit Khaparde:

Quoted 1 line

Fix build failures because of uninitialized variable usage.

You should add the error log here.
You don't mention the condition of failure.
Nobody reproduced a failure so far.

Sure. I did not notice it on my Fedora34 either. The build error was reported in the dpdk-test-report [1]. Let me resend a v2 with the information.

[1] http://mails.dpdk.org/archives/test-report/2021-July/203186.html

Quoted 8 lines
Quoted 4 lines
Fixes 05b405d58148 ("net/bnxt: add dpool allocator for EM allocation")
#3 lore raw

PATCH v2 1/1 net/bnxt: fix build failure

Fix build failures because of uninitialized variables.

../drivers/net/bnxt/tf_ulp/ulp_mapper.c: In function ‘ulp_mapper_index_tbl_process’:
../drivers/net/bnxt/tf_ulp/ulp_mapper.c:2252:43: error: ‘*(unsigned int *)((char *)&glb_res + offsetof(struct bnxt_ulp_glb_resource_info, resource_func))’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2252 | struct bnxt_ulp_glb_resource_info glb_res;
| ^~~~~~~
../drivers/net/bnxt/tf_ulp/ulp_mapper.c:2252:43: error: ‘glb_res.resource_type’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

../drivers/net/bnxt/tf_core/dpool.c: In function ‘dpool_defrag’:
../drivers/net/bnxt/tf_core/dpool.c:95:18: error: ‘index’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
95 | uint32_t index;
| ^~~~~

Fixes 05b405d58148 ("net/bnxt: add dpool allocator for EM allocation")

---
v1->v2: update commit log to show the build error encountered.

---
 drivers/net/bnxt/tf_core/dpool.c     | 1 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_core/dpool.c +1 -0
index 0dae42b1bb..145efa486f 100644
@@ -125,6 +125,7 @@ int dpool_defrag(struct dpool *dpool,
 		largest_free_size = 0;
 		largest_free_index = 0;
 		count = 0;
+		index = 0;
 
 		for (i = 0; i < dpool->size; i++) {
 			if (DP_IS_FREE(dpool->entry[i].flags)) {
drivers/net/bnxt/tf_ulp/ulp_mapper.c +1 -1
index acd9f996e8..871dbad0fe 100644
@@ -2249,7 +2249,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
 	struct tf_free_tbl_entry_parms free_parms = { 0 };
 	uint32_t tbl_scope_id;
 	struct tf *tfp;
-	struct bnxt_ulp_glb_resource_info glb_res;
+	struct bnxt_ulp_glb_resource_info glb_res = { 0 };
 	uint16_t bit_size;
 	bool alloc = false;
 	bool write = false;
Signature · 1 line
2.21.1 (Apple Git-122.3)
#4 lore raw
Quoted 20 lines · Ajit Khaparde

Fix build failures because of uninitialized variables.

../drivers/net/bnxt/tf_ulp/ulp_mapper.c: In function ‘ulp_mapper_index_tbl_process’:
../drivers/net/bnxt/tf_ulp/ulp_mapper.c:2252:43: error: ‘*(unsigned int *)((char *)&glb_res + offsetof(struct bnxt_ulp_glb_resource_info, resource_func))’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2252 | struct bnxt_ulp_glb_resource_info glb_res;
| ^~~~~~~
../drivers/net/bnxt/tf_ulp/ulp_mapper.c:2252:43: error:
‘glb_res.resource_type’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

../drivers/net/bnxt/tf_core/dpool.c: In function ‘dpool_defrag’:
../drivers/net/bnxt/tf_core/dpool.c:95:18: error: ‘index’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
95 | uint32_t index;
| ^~~~~

Quoted 8 lines
Fixes 05b405d58148 ("net/bnxt: add dpool allocator for EM allocation")

---
v1->v2: update commit log to show the build error encountered.
---

Patch applied to dpdk-next-net-brcm for-next-net branch. Thanks

Quoted 36 lines
 drivers/net/bnxt/tf_core/dpool.c     | 1 +
 drivers/net/bnxt/tf_ulp/ulp_mapper.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
drivers/net/bnxt/tf_core/dpool.c +1 -0
index 0dae42b1bb..145efa486f 100644
@@ -125,6 +125,7 @@ int dpool_defrag(struct dpool *dpool,
                largest_free_size = 0;
                largest_free_index = 0;
                count = 0;
+               index = 0;
 
                for (i = 0; i < dpool->size; i++) {
                        if (DP_IS_FREE(dpool->entry[i].flags)) {
drivers/net/bnxt/tf_ulp/ulp_mapper.c +1 -1
index acd9f996e8..871dbad0fe 100644
@@ -2249,7 +2249,7 @@ ulp_mapper_index_tbl_process(struct
 bnxt_ulp_mapper_parms *parms,
        struct tf_free_tbl_entry_parms free_parms = { 0 };
        uint32_t tbl_scope_id;
        struct tf *tfp;
-       struct bnxt_ulp_glb_resource_info glb_res;
+       struct bnxt_ulp_glb_resource_info glb_res = { 0 };
        uint16_t bit_size;
        bool alloc = false;
        bool write = false;

--
2.21.1 (Apple Git-122.3)

#5 lore raw

09/07/2021 20:38, Ajit Khaparde:

Quoted 23 lines
Quoted 20 lines · Ajit Khaparde

Fix build failures because of uninitialized variables.

../drivers/net/bnxt/tf_ulp/ulp_mapper.c: In function ‘ulp_mapper_index_tbl_process’:
../drivers/net/bnxt/tf_ulp/ulp_mapper.c:2252:43: error: ‘*(unsigned int *)((char *)&glb_res + offsetof(struct bnxt_ulp_glb_resource_info, resource_func))’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
2252 | struct bnxt_ulp_glb_resource_info glb_res;
| ^~~~~~~
../drivers/net/bnxt/tf_ulp/ulp_mapper.c:2252:43: error:
‘glb_res.resource_type’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

../drivers/net/bnxt/tf_core/dpool.c: In function ‘dpool_defrag’:
../drivers/net/bnxt/tf_core/dpool.c:95:18: error: ‘index’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
95 | uint32_t index;
| ^~~~~

Quoted 6 lines
Quoted 4 lines
Fixes 05b405d58148 ("net/bnxt: add dpool allocator for EM allocation")

Patch applied to dpdk-next-net-brcm for-next-net branch. Thanks

Pulled in main with additional info:
seen on Fedora Core 34 (GCC 11)

#6 lore raw
In reply to Thomas Monjalon
Quoted 7 lines · Thomas Monjalon

09/07/2021 00:49, Ajit Khaparde:

Quoted 1 line

Fix build failures because of uninitialized variable usage.

You should add the error log here.
You don't mention the condition of failure.
Nobody reproduced a failure so far.

Hi Thomas,

This addresses FC34 (which I think is using gcc11) build failures, there is an example here:

     http://mails.dpdk.org/archives/test-report/2021-July/203186.html

Regards,
Lance