diff mbox series

[v2] net/bnxt: fix build failure

Message ID 20210709153725.87348-1-ajit.khaparde@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ajit Khaparde
Headers show
Series [v2] net/bnxt: fix build failure | expand

Checks

Context Check Description
ci/Intel-compilation warning apply issues
ci/iol-testing warning apply patch failure
ci/github-robot success github build: passed
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde July 9, 2021, 3:37 p.m. UTC
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")

Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
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(-)

Comments

Ajit Khaparde July 9, 2021, 6:38 p.m. UTC | #1
On Fri, Jul 9, 2021 at 8:37 AM Ajit Khaparde <ajit.khaparde@broadcom.com>
wrote:

> 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")
>
> Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
> Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> ---
> v1->v2: update commit log to show the build error encountered.
> ---
>
Patch applied to dpdk-next-net-brcm for-next-net branch. Thanks



>  drivers/net/bnxt/tf_core/dpool.c     | 1 +
>  drivers/net/bnxt/tf_ulp/ulp_mapper.c | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/bnxt/tf_core/dpool.c
> b/drivers/net/bnxt/tf_core/dpool.c
> index 0dae42b1bb..145efa486f 100644
> --- a/drivers/net/bnxt/tf_core/dpool.c
> +++ b/drivers/net/bnxt/tf_core/dpool.c
> @@ -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)) {
> diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
> b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
> index acd9f996e8..871dbad0fe 100644
> --- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
> +++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
> @@ -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)
>
>
Thomas Monjalon July 9, 2021, 8:39 p.m. UTC | #2
09/07/2021 20:38, Ajit Khaparde:
> On Fri, Jul 9, 2021 at 8:37 AM Ajit Khaparde <ajit.khaparde@broadcom.com>
> wrote:
> 
> > 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")
> >
> > Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
> > Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
> 
> 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)
diff mbox series

Patch

diff --git a/drivers/net/bnxt/tf_core/dpool.c b/drivers/net/bnxt/tf_core/dpool.c
index 0dae42b1bb..145efa486f 100644
--- a/drivers/net/bnxt/tf_core/dpool.c
+++ b/drivers/net/bnxt/tf_core/dpool.c
@@ -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)) {
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index acd9f996e8..871dbad0fe 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -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;