[05/12] net/enetfec: fix build with GCC 12

Message ID 20220518101657.1230416-6-david.marchand@redhat.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series Fix compilation with gcc 12 |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

David Marchand May 18, 2022, 10:16 a.m. UTC
  GCC 12 raises the following warning:

../drivers/net/enetfec/enet_ethdev.c: In function
        ‘enetfec_rx_queue_setup’:
../drivers/net/enetfec/enet_ethdev.c:473:9: error: array
        subscript 1 is
    above array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’}
        [-Werror=array-bounds]
  473 | rte_write32(rte_cpu_to_le_32(fep->bd_addr_p_r[queue_idx]),
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  474 |     (uint8_t *)fep->hw_baseaddr_v + ENETFEC_RD_START(queue_idx));
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../drivers/net/enetfec/enet_ethdev.c:9:
../drivers/net/enetfec/enet_ethdev.h:113:33: note: while referencing
        ‘bd_addr_p_r’
  113 | uint32_t                bd_addr_p_r[ENETFEC_MAX_Q];
      |                                 ^~~~~~~~~~~

This driver properly announces that it only supports 1 rxq.
Silence this warning by adding an explicit check on the queue id.

Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/net/enetfec/enet_ethdev.c | 9 +++++++++
 1 file changed, 9 insertions(+)
  

Comments

David Marchand June 10, 2022, 1:08 p.m. UTC | #1
On Wed, May 18, 2022 at 12:17 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> GCC 12 raises the following warning:
>
> ../drivers/net/enetfec/enet_ethdev.c: In function
>         ‘enetfec_rx_queue_setup’:
> ../drivers/net/enetfec/enet_ethdev.c:473:9: error: array
>         subscript 1 is
>     above array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’}
>         [-Werror=array-bounds]
>   473 | rte_write32(rte_cpu_to_le_32(fep->bd_addr_p_r[queue_idx]),
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   474 |     (uint8_t *)fep->hw_baseaddr_v + ENETFEC_RD_START(queue_idx));
>       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from ../drivers/net/enetfec/enet_ethdev.c:9:
> ../drivers/net/enetfec/enet_ethdev.h:113:33: note: while referencing
>         ‘bd_addr_p_r’
>   113 | uint32_t                bd_addr_p_r[ENETFEC_MAX_Q];
>       |                                 ^~~~~~~~~~~
>
> This driver properly announces that it only supports 1 rxq.
> Silence this warning by adding an explicit check on the queue id.
>
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Any comment from driver maintainers?
Thanks.
  
Stephen Hemminger June 11, 2022, 3:35 p.m. UTC | #2
On Wed, 18 May 2022 12:16:50 +0200
David Marchand <david.marchand@redhat.com> wrote:

> GCC 12 raises the following warning:
> 
> ../drivers/net/enetfec/enet_ethdev.c: In function
>         ‘enetfec_rx_queue_setup’:
> ../drivers/net/enetfec/enet_ethdev.c:473:9: error: array
>         subscript 1 is
>     above array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’}
>         [-Werror=array-bounds]
>   473 | rte_write32(rte_cpu_to_le_32(fep->bd_addr_p_r[queue_idx]),
>       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>   474 |     (uint8_t *)fep->hw_baseaddr_v + ENETFEC_RD_START(queue_idx));
>       |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In file included from ../drivers/net/enetfec/enet_ethdev.c:9:
> ../drivers/net/enetfec/enet_ethdev.h:113:33: note: while referencing
>         ‘bd_addr_p_r’
>   113 | uint32_t                bd_addr_p_r[ENETFEC_MAX_Q];
>       |                                 ^~~~~~~~~~~
> 
> This driver properly announces that it only supports 1 rxq.
> Silence this warning by adding an explicit check on the queue id.
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>


Acked-by: Stephen Hemminger <stephen@networkplumber.org>
  
Sachin Saxena (OSS) June 13, 2022, 5:22 a.m. UTC | #3
Hello David,

I understood and agree with your suggestion. We are using GCC 11.3 where 
we were not seeing this warning.
We will fix this on priority and submit the patch asap.

regards,
Sachin Saxena

On 6/10/2022 6:38 PM, David Marchand wrote:
> On Wed, May 18, 2022 at 12:17 PM David Marchand
> <david.marchand@redhat.com> wrote:
>> GCC 12 raises the following warning:
>>
>> ../drivers/net/enetfec/enet_ethdev.c: In function
>>          ‘enetfec_rx_queue_setup’:
>> ../drivers/net/enetfec/enet_ethdev.c:473:9: error: array
>>          subscript 1 is
>>      above array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’}
>>          [-Werror=array-bounds]
>>    473 | rte_write32(rte_cpu_to_le_32(fep->bd_addr_p_r[queue_idx]),
>>        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>    474 |     (uint8_t *)fep->hw_baseaddr_v + ENETFEC_RD_START(queue_idx));
>>        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> In file included from ../drivers/net/enetfec/enet_ethdev.c:9:
>> ../drivers/net/enetfec/enet_ethdev.h:113:33: note: while referencing
>>          ‘bd_addr_p_r’
>>    113 | uint32_t                bd_addr_p_r[ENETFEC_MAX_Q];
>>        |                                 ^~~~~~~~~~~
>>
>> This driver properly announces that it only supports 1 rxq.
>> Silence this warning by adding an explicit check on the queue id.
>>
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: David Marchand <david.marchand@redhat.com>
> Any comment from driver maintainers?
> Thanks.
>
>
  
Sachin Saxena (OSS) June 14, 2022, 8:16 a.m. UTC | #4
Acked-by: Sachin Saxena <sachin.saxena@nxp.com>

On 6/10/2022 6:38 PM, David Marchand wrote:
> On Wed, May 18, 2022 at 12:17 PM David Marchand
> <david.marchand@redhat.com> wrote:
>> GCC 12 raises the following warning:
>>
>> ../drivers/net/enetfec/enet_ethdev.c: In function
>>          ‘enetfec_rx_queue_setup’:
>> ../drivers/net/enetfec/enet_ethdev.c:473:9: error: array
>>          subscript 1 is
>>      above array bounds of ‘uint32_t[1]’ {aka ‘unsigned int[1]’}
>>          [-Werror=array-bounds]
>>    473 | rte_write32(rte_cpu_to_le_32(fep->bd_addr_p_r[queue_idx]),
>>        | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>    474 |     (uint8_t *)fep->hw_baseaddr_v + ENETFEC_RD_START(queue_idx));
>>        |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> In file included from ../drivers/net/enetfec/enet_ethdev.c:9:
>> ../drivers/net/enetfec/enet_ethdev.h:113:33: note: while referencing
>>          ‘bd_addr_p_r’
>>    113 | uint32_t                bd_addr_p_r[ENETFEC_MAX_Q];
>>        |                                 ^~~~~~~~~~~
>>
>> This driver properly announces that it only supports 1 rxq.
>> Silence this warning by adding an explicit check on the queue id.
>>
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: David Marchand <david.marchand@redhat.com>
> Any comment from driver maintainers?
> Thanks.
>
>
  

Patch

diff --git a/drivers/net/enetfec/enet_ethdev.c b/drivers/net/enetfec/enet_ethdev.c
index 714f8ac7ec..c938e58204 100644
--- a/drivers/net/enetfec/enet_ethdev.c
+++ b/drivers/net/enetfec/enet_ethdev.c
@@ -2,9 +2,12 @@ 
  * Copyright 2020-2021 NXP
  */
 
+#include <inttypes.h>
+
 #include <ethdev_vdev.h>
 #include <ethdev_driver.h>
 #include <rte_io.h>
+
 #include "enet_pmd_logs.h"
 #include "enet_ethdev.h"
 #include "enet_regs.h"
@@ -454,6 +457,12 @@  enetfec_rx_queue_setup(struct rte_eth_dev *dev,
 		return -EINVAL;
 	}
 
+	if (queue_idx >= ENETFEC_MAX_Q) {
+		ENETFEC_PMD_ERR("Invalid queue id %" PRIu16 ", max %d\n",
+			queue_idx, ENETFEC_MAX_Q);
+		return -EINVAL;
+	}
+
 	/* allocate receive queue */
 	rxq = rte_zmalloc(NULL, sizeof(*rxq), RTE_CACHE_LINE_SIZE);
 	if (rxq == NULL) {