DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] crypto/zuc: fix gcc11 maybe-uninitialized warnings
@ 2021-05-14 15:08 Kevin Traynor
  2021-05-17 19:23 ` [dpdk-dev] [EXT] " Akhil Goyal
  0 siblings, 1 reply; 2+ messages in thread
From: Kevin Traynor @ 2021-05-14 15:08 UTC (permalink / raw)
  To: dev; +Cc: gakhil, ferruh.yigit, Kevin Traynor, Pablo de Lara

gcc11 complains that some arrays may be uninitialized in
process_zuc_hash_op(). This is because their initialization
depends on num_ops being > 0.

For example:
$ gcc --version
gcc (GCC) 11.1.1 20210428 (Red Hat 11.1.1-1)

In file included from ../drivers/crypto/zuc/zuc_pmd_private.h:8,
                 from ../drivers/crypto/zuc/rte_zuc_pmd.c:13:
../drivers/crypto/zuc/rte_zuc_pmd.c: In function ‘process_zuc_hash_op’:
../drivers/crypto/zuc/rte_zuc_pmd.c:279:33: error: ‘hash_keys’ may be used uninitialized [-Werror=maybe-uninitialized]
  279 |         IMB_ZUC_EIA3_N_BUFFER(qp->mb_mgr, (const void **)hash_keys,
      |                                 ^
../drivers/crypto/zuc/rte_zuc_pmd.c:279:33: note: by argument 1 of type ‘const void * const*’ to ‘void(const void * const*, const void * const*, const void * const*, const uint32_t *, uint32_t **, const uint32_t)’ {aka ‘void(const void * const*, const void * const*, const void * const*, const unsigned int *, unsigned int **, const unsigned int)’}
../drivers/crypto/zuc/rte_zuc_pmd.c:245:21: note: ‘hash_keys’ declared here
  245 |         const void *hash_keys[ZUC_MAX_BURST];
      |                     ^~~~~~~~~

This function is only called with num_ops > 0 because of
checks in process_zuc_hash_op().

To remove the warning initialize the arrays.

Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
---
 drivers/crypto/zuc/rte_zuc_pmd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/crypto/zuc/rte_zuc_pmd.c b/drivers/crypto/zuc/rte_zuc_pmd.c
index aa50c12da6..42b669f188 100644
--- a/drivers/crypto/zuc/rte_zuc_pmd.c
+++ b/drivers/crypto/zuc/rte_zuc_pmd.c
@@ -239,9 +239,9 @@ process_zuc_hash_op(struct zuc_qp *qp, struct rte_crypto_op **ops,
 	unsigned int i;
 	uint8_t processed_ops = 0;
-	uint8_t *src[ZUC_MAX_BURST];
+	uint8_t *src[ZUC_MAX_BURST] = { 0 };
 	uint32_t *dst[ZUC_MAX_BURST];
-	uint32_t length_in_bits[ZUC_MAX_BURST];
-	uint8_t *iv[ZUC_MAX_BURST];
-	const void *hash_keys[ZUC_MAX_BURST];
+	uint32_t length_in_bits[ZUC_MAX_BURST] = { 0 };
+	uint8_t *iv[ZUC_MAX_BURST] = { 0 };
+	const void *hash_keys[ZUC_MAX_BURST] = { 0 };
 	struct zuc_session *sess;
 
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [EXT] [PATCH] crypto/zuc: fix gcc11 maybe-uninitialized warnings
  2021-05-14 15:08 [dpdk-dev] [PATCH] crypto/zuc: fix gcc11 maybe-uninitialized warnings Kevin Traynor
@ 2021-05-17 19:23 ` Akhil Goyal
  0 siblings, 0 replies; 2+ messages in thread
From: Akhil Goyal @ 2021-05-17 19:23 UTC (permalink / raw)
  To: Kevin Traynor, dev; +Cc: ferruh.yigit, Pablo de Lara

> gcc11 complains that some arrays may be uninitialized in
> process_zuc_hash_op(). This is because their initialization
> depends on num_ops being > 0.
> 
> For example:
> $ gcc --version
> gcc (GCC) 11.1.1 20210428 (Red Hat 11.1.1-1)
> 
> In file included from ../drivers/crypto/zuc/zuc_pmd_private.h:8,
>                  from ../drivers/crypto/zuc/rte_zuc_pmd.c:13:
> ../drivers/crypto/zuc/rte_zuc_pmd.c: In function ‘process_zuc_hash_op’:
> ../drivers/crypto/zuc/rte_zuc_pmd.c:279:33: error: ‘hash_keys’ may be used
> uninitialized [-Werror=maybe-uninitialized]
>   279 |         IMB_ZUC_EIA3_N_BUFFER(qp->mb_mgr, (const void
> **)hash_keys,
>       |                                 ^
> ../drivers/crypto/zuc/rte_zuc_pmd.c:279:33: note: by argument 1 of type
> ‘const void * const*’ to ‘void(const void * const*, const void * const*, const
> void * const*, const uint32_t *, uint32_t **, const uint32_t)’ {aka ‘void(const
> void * const*, const void * const*, const void * const*, const unsigned int *,
> unsigned int **, const unsigned int)’}
> ../drivers/crypto/zuc/rte_zuc_pmd.c:245:21: note: ‘hash_keys’ declared here
>   245 |         const void *hash_keys[ZUC_MAX_BURST];
>       |                     ^~~~~~~~~
> 
> This function is only called with num_ops > 0 because of
> checks in process_zuc_hash_op().
> 
> To remove the warning initialize the arrays.
> 
> Signed-off-by: Kevin Traynor <ktraynor@redhat.com>
> ---
Removed error log from commit message.

Applied to dpdk-next-crypto

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-17 19:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 15:08 [dpdk-dev] [PATCH] crypto/zuc: fix gcc11 maybe-uninitialized warnings Kevin Traynor
2021-05-17 19:23 ` [dpdk-dev] [EXT] " Akhil Goyal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).