[2/2] net/qede/base: compilation fix for GCC-12

Message ID 20220824140339.2581716-2-amitprakashs@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [1/2] net/i40e: compilation fix for GCC-12 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS

Commit Message

Amit Prakash Shukla Aug. 24, 2022, 2:03 p.m. UTC
  GCC 12 raises the following warning:

../drivers/net/qede/base/ecore_init_fw_funcs.c: In function
'ecore_dmae_to_grc.constprop.isra':
../drivers/net/qede/base/ecore_init_fw_funcs.c:1418:25:
	error: array subscript 1 is outside array bounds of 'u32[1]'
	{aka 'unsigned int[1]'} [-Werror=array-bounds]
 1418 |                         ecore_wr(dev, ptt, ((addr) + (4 * i)),  \
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1419 |                                  ((u32 *)&(arr))[i]);           \
      |                                  ~~~~~~~~~~~~~~~~~~~
../drivers/net/qede/base/ecore_init_fw_funcs.c:1465:17: note:
	in expansion of macro 'ARR_REG_WR'
 1465 |            ARR_REG_WR(p_hwfn, p_ptt, addr, pData, len_in_dwords);
      |            ^~~~~~~~~~
../drivers/net/qede/base/ecore_init_fw_funcs.c:1439:35:
	note: at offset 4 into object 'pData' of size 4
 1439 |                              u32 *pData,
      |                              ~~~~~^~~~~
cc1: all warnings being treated as errors

Fixes: 3b307c55f2ac (net/qede/base: update FW to 8.40.25.0)
Cc: stable@dpdk.org

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
 drivers/net/qede/base/ecore_init_fw_funcs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon Oct. 6, 2022, 9:52 a.m. UTC | #1
24/08/2022 16:03, Amit Prakash Shukla:
> GCC 12 raises the following warning:
> 
> ../drivers/net/qede/base/ecore_init_fw_funcs.c: In function
> 'ecore_dmae_to_grc.constprop.isra':
> ../drivers/net/qede/base/ecore_init_fw_funcs.c:1418:25:
> 	error: array subscript 1 is outside array bounds of 'u32[1]'
> 	{aka 'unsigned int[1]'} [-Werror=array-bounds]
>  1418 |                         ecore_wr(dev, ptt, ((addr) + (4 * i)),  \
>       |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>  1419 |                                  ((u32 *)&(arr))[i]);           \
>       |                                  ~~~~~~~~~~~~~~~~~~~
> ../drivers/net/qede/base/ecore_init_fw_funcs.c:1465:17: note:
> 	in expansion of macro 'ARR_REG_WR'
>  1465 |            ARR_REG_WR(p_hwfn, p_ptt, addr, pData, len_in_dwords);
>       |            ^~~~~~~~~~
> ../drivers/net/qede/base/ecore_init_fw_funcs.c:1439:35:
> 	note: at offset 4 into object 'pData' of size 4
>  1439 |                              u32 *pData,
>       |                              ~~~~~^~~~~
> cc1: all warnings being treated as errors
> 
> Fixes: 3b307c55f2ac (net/qede/base: update FW to 8.40.25.0)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>

Sorry I did not notice this patch and I recently submitted one
which I will abandon.
It seems there was no reply from qede maintainers after 6 weeks,
but I will apply anyway.

I will use my commit message:

    net/qede/base: fix 32-bit build with GCC 12
    
    A pointer is passed to a macro and it seems mistakenly referenced.
    This issue is seen only when compiling with GCC 12 for 32-bit:
    
    drivers/net/qede/base/ecore_init_fw_funcs.c:1418:25:
            error: array subscript 1 is outside array bounds of ‘u32[1]’
            {aka ‘unsigned int[1]’} [-Werror=array-bounds]
     1418 |                 ecore_wr(dev, ptt, ((addr) + (4 * i)),  \
          |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     1419 |                          ((u32 *)&(arr))[i]);           \
          |                          ~~~~~~~~~~~~~~~~~~~
    drivers/net/qede/base/ecore_init_fw_funcs.c:1465:17:
            note: in expansion of macro ‘ARR_REG_WR’
     1465 |         ARR_REG_WR(p_hwfn, p_ptt, addr, pData, len_in_dwords);
          |         ^~~~~~~~~~
    drivers/net/qede/base/ecore_init_fw_funcs.c:1439:35:
            note: at offset 4 into object ‘pData’ of size 4
     1439 |                              u32 *pData,
          |                              ~~~~~^~~~~
    
    Fixes: 3b307c55f2ac ("net/qede/base: update FW to 8.40.25.0")
    Cc: stable@dpdk.org
  

Patch

diff --git a/drivers/net/qede/base/ecore_init_fw_funcs.c b/drivers/net/qede/base/ecore_init_fw_funcs.c
index 6a52f32cc9..4e4d1dc374 100644
--- a/drivers/net/qede/base/ecore_init_fw_funcs.c
+++ b/drivers/net/qede/base/ecore_init_fw_funcs.c
@@ -1416,7 +1416,7 @@  void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn,
 		u32 i;						\
 		for (i = 0; i < (arr_size); i++)		\
 			ecore_wr(dev, ptt, ((addr) + (4 * i)),	\
-				 ((u32 *)&(arr))[i]);		\
+				 ((u32 *)(arr))[i]);		\
 	} while (0)
 
 #ifndef DWORDS_TO_BYTES