[01/12] common/cpt: fix build with GCC 12

Message ID 20220518101657.1230416-2-david.marchand@redhat.com (mailing list archive)
State Changes Requested, 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:

In function ‘fill_sg_comp_from_iov’,
    inlined from ‘cpt_kasumi_enc_prep’ at
        ../drivers/common/cpt/cpt_ucode.h:2176:8,
    inlined from ‘cpt_fc_enc_hmac_prep’ at
        ../drivers/common/cpt/cpt_ucode.h:2475:3,
    inlined from ‘fill_digest_params’ at
        ../drivers/common/cpt/cpt_ucode.h:3548:14,
    inlined from ‘otx_cpt_enq_single_sym’ at
        ../drivers/crypto/octeontx/otx_cryptodev_ops.c:541:9,
    inlined from ‘otx_cpt_enq_single_sym_sessless’ at
        ../drivers/crypto/octeontx/otx_cryptodev_ops.c:584:8,
    inlined from ‘otx_cpt_enq_single’ at
        ../drivers/crypto/octeontx/otx_cryptodev_ops.c:611:11,
    inlined from ‘otx_cpt_pkt_enqueue’ at
        ../drivers/crypto/octeontx/otx_cryptodev_ops.c:643:9,
    inlined from ‘otx_cpt_enqueue_sym’ at
        ../drivers/crypto/octeontx/otx_cryptodev_ops.c:668:9:
../drivers/common/cpt/cpt_ucode.h:415:36: error: array subscript 0 is
        outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’}
        [-Werror=array-bounds]
  415 |                         e_dma_addr = bufs[j].dma_addr;
      |                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
../drivers/common/cpt/cpt_ucode.h:416:48: error: array subscript 0 is
        outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’}
        [-Werror=array-bounds]
  416 |                         e_len = (size > bufs[j].size) ?
      |                                         ~~~~~~~^~~~~

For now, waive this warning until we have a proper fix.

Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
 drivers/common/cpt/cpt_ucode.h | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Comments

Stephen Hemminger May 20, 2022, 8:23 p.m. UTC | #1
On Wed, 18 May 2022 12:16:46 +0200
David Marchand <david.marchand@redhat.com> wrote:

> GCC 12 raises the following warning:
> 
> In function ‘fill_sg_comp_from_iov’,
>     inlined from ‘cpt_kasumi_enc_prep’ at
>         ../drivers/common/cpt/cpt_ucode.h:2176:8,
>     inlined from ‘cpt_fc_enc_hmac_prep’ at
>         ../drivers/common/cpt/cpt_ucode.h:2475:3,
>     inlined from ‘fill_digest_params’ at
>         ../drivers/common/cpt/cpt_ucode.h:3548:14,
>     inlined from ‘otx_cpt_enq_single_sym’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:541:9,
>     inlined from ‘otx_cpt_enq_single_sym_sessless’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:584:8,
>     inlined from ‘otx_cpt_enq_single’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:611:11,
>     inlined from ‘otx_cpt_pkt_enqueue’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:643:9,
>     inlined from ‘otx_cpt_enqueue_sym’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:668:9:
> ../drivers/common/cpt/cpt_ucode.h:415:36: error: array subscript 0 is
>         outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’}
>         [-Werror=array-bounds]
>   415 |                         e_dma_addr = bufs[j].dma_addr;
>       |                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
> ../drivers/common/cpt/cpt_ucode.h:416:48: error: array subscript 0 is
>         outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’}
>         [-Werror=array-bounds]
>   416 |                         e_len = (size > bufs[j].size) ?
>       |                                         ~~~~~~~^~~~~
> 
> For now, waive this warning until we have a proper fix.
> 
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
 
NAK
Please fix properly, with something like:

--- a/drivers/common/cpt/cpt_mcode_defines.h
+++ b/drivers/common/cpt/cpt_mcode_defines.h
@@ -387,7 +387,7 @@ typedef struct buf_ptr {
 /* IOV Pointer */
 typedef struct{
        int buf_cnt;
-       buf_ptr_t bufs[0];
+       buf_ptr_t bufs[];
 } iov_ptr_t;
 
 typedef struct fc_params {
  
David Marchand June 10, 2022, 1:11 p.m. UTC | #2
Hello maintainers,

On Wed, May 18, 2022 at 12:17 PM David Marchand
<david.marchand@redhat.com> wrote:
>
> GCC 12 raises the following warning:
>
> In function ‘fill_sg_comp_from_iov’,
>     inlined from ‘cpt_kasumi_enc_prep’ at
>         ../drivers/common/cpt/cpt_ucode.h:2176:8,
>     inlined from ‘cpt_fc_enc_hmac_prep’ at
>         ../drivers/common/cpt/cpt_ucode.h:2475:3,
>     inlined from ‘fill_digest_params’ at
>         ../drivers/common/cpt/cpt_ucode.h:3548:14,
>     inlined from ‘otx_cpt_enq_single_sym’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:541:9,
>     inlined from ‘otx_cpt_enq_single_sym_sessless’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:584:8,
>     inlined from ‘otx_cpt_enq_single’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:611:11,
>     inlined from ‘otx_cpt_pkt_enqueue’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:643:9,
>     inlined from ‘otx_cpt_enqueue_sym’ at
>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:668:9:
> ../drivers/common/cpt/cpt_ucode.h:415:36: error: array subscript 0 is
>         outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’}
>         [-Werror=array-bounds]
>   415 |                         e_dma_addr = bufs[j].dma_addr;
>       |                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
> ../drivers/common/cpt/cpt_ucode.h:416:48: error: array subscript 0 is
>         outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’}
>         [-Werror=array-bounds]
>   416 |                         e_len = (size > bufs[j].size) ?
>       |                                         ~~~~~~~^~~~~
>
> For now, waive this warning until we have a proper fix.

Both common/cpt and crypto/cnxk have the same code that triggers this warning.
Can you look into this please?

Thanks.
  
Ankur Dwivedi June 13, 2022, 11:40 a.m. UTC | #3
Hi David,

>-----Original Message-----
>From: David Marchand <david.marchand@redhat.com>
>Sent: Friday, June 10, 2022 6:42 PM
>To: Anoob Joseph <anoobj@marvell.com>; Ankur Dwivedi
><adwivedi@marvell.com>
>Cc: Thomas Monjalon <thomas@monjalon.net>; Ferruh Yigit
><ferruh.yigit@xilinx.com>; dpdk stable <stable@dpdk.org>; dev
><dev@dpdk.org>; Akhil Goyal <gakhil@marvell.com>; Jerin Jacob
>Kollanukkaran <jerinj@marvell.com>
>Subject: [EXT] Re: [PATCH 01/12] common/cpt: fix build with GCC 12
>
>External Email
>
>----------------------------------------------------------------------
>Hello maintainers,
>
>On Wed, May 18, 2022 at 12:17 PM David Marchand
><david.marchand@redhat.com> wrote:
>>
>> GCC 12 raises the following warning:
>>
>> In function ‘fill_sg_comp_from_iov’,
>>     inlined from ‘cpt_kasumi_enc_prep’ at
>>         ../drivers/common/cpt/cpt_ucode.h:2176:8,
>>     inlined from ‘cpt_fc_enc_hmac_prep’ at
>>         ../drivers/common/cpt/cpt_ucode.h:2475:3,
>>     inlined from ‘fill_digest_params’ at
>>         ../drivers/common/cpt/cpt_ucode.h:3548:14,
>>     inlined from ‘otx_cpt_enq_single_sym’ at
>>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:541:9,
>>     inlined from ‘otx_cpt_enq_single_sym_sessless’ at
>>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:584:8,
>>     inlined from ‘otx_cpt_enq_single’ at
>>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:611:11,
>>     inlined from ‘otx_cpt_pkt_enqueue’ at
>>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:643:9,
>>     inlined from ‘otx_cpt_enqueue_sym’ at
>>         ../drivers/crypto/octeontx/otx_cryptodev_ops.c:668:9:
>> ../drivers/common/cpt/cpt_ucode.h:415:36: error: array subscript 0 is
>>         outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’}
>>         [-Werror=array-bounds]
>>   415 |                         e_dma_addr = bufs[j].dma_addr;
>>       |                         ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
>> ../drivers/common/cpt/cpt_ucode.h:416:48: error: array subscript 0 is
>>         outside array bounds of ‘buf_ptr_t[0]’ {aka ‘struct buf_ptr[]’}
>>         [-Werror=array-bounds]
>>   416 |                         e_len = (size > bufs[j].size) ?
>>       |                                         ~~~~~~~^~~~~
>>
>> For now, waive this warning until we have a proper fix.
>
>Both common/cpt and crypto/cnxk have the same code that triggers this
>warning.
>Can you look into this please?

We will look into the issues in common/cpt and crypto/cnxk.
>
>Thanks.
>
>--
>David Marchand

Regards,
Ankur
  
David Marchand June 16, 2022, 9:30 a.m. UTC | #4
On Mon, Jun 13, 2022 at 1:40 PM Ankur Dwivedi <adwivedi@marvell.com> wrote:
> >> For now, waive this warning until we have a proper fix.
> >
> >Both common/cpt and crypto/cnxk have the same code that triggers this
> >warning.
> >Can you look into this please?
>
> We will look into the issues in common/cpt and crypto/cnxk.

Any update?
Thanks.
  
Ankur Dwivedi June 16, 2022, 11:59 a.m. UTC | #5
Hi David,

>-----Original Message-----
>From: David Marchand <david.marchand@redhat.com>
>Sent: Thursday, June 16, 2022 3:00 PM
>To: Ankur Dwivedi <adwivedi@marvell.com>; Jerin Jacob Kollanukkaran
><jerinj@marvell.com>
>Cc: Anoob Joseph <anoobj@marvell.com>; Thomas Monjalon
><thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@xilinx.com>; dpdk stable
><stable@dpdk.org>; dev <dev@dpdk.org>; Akhil Goyal <gakhil@marvell.com>
>Subject: Re: [EXT] Re: [PATCH 01/12] common/cpt: fix build with GCC 12
>
>On Mon, Jun 13, 2022 at 1:40 PM Ankur Dwivedi <adwivedi@marvell.com>
>wrote:
>> >> For now, waive this warning until we have a proper fix.
>> >
>> >Both common/cpt and crypto/cnxk have the same code that triggers this
>> >warning.
>> >Can you look into this please?
>>
>> We will look into the issues in common/cpt and crypto/cnxk.
>
>Any update?

We are working on the changes. Will send the patch once it is complete.

>Thanks.
>
>
>--
>David Marchand

Regards,
Ankur
  

Patch

diff --git a/drivers/common/cpt/cpt_ucode.h b/drivers/common/cpt/cpt_ucode.h
index e1f2f6005d..bdf72b400c 100644
--- a/drivers/common/cpt/cpt_ucode.h
+++ b/drivers/common/cpt/cpt_ucode.h
@@ -412,9 +412,17 @@  fill_sg_comp_from_iov(sg_comp_t *list,
 				(bufs[j].size - from_offset) : size;
 			from_offset = 0;
 		} else {
+/* FIXME */
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Warray-bounds"
+#endif
 			e_dma_addr = bufs[j].dma_addr;
 			e_len = (size > bufs[j].size) ?
 				bufs[j].size : size;
+#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 120000)
+#pragma GCC diagnostic pop
+#endif
 		}
 
 		to->u.s.len[i % 4] = rte_cpu_to_be_16(e_len);