diff mbox series

[v5] crypto/qat: fix uninitialized gcc compiler warning

Message ID 20210521020004.100034-1-feifei.wang2@arm.com (mailing list archive)
State Accepted
Delegated to: akhil goyal
Headers show
Series [v5] crypto/qat: fix uninitialized gcc compiler warning | expand

Checks

Context Check Description
ci/iol-mellanox-Performance fail Performance Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/github-robot success github build: passed
ci/iol-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation fail Compilation issues
ci/iol-abi-testing success Testing PASS
ci/checkpatch success coding style OK

Commit Message

Feifei Wang May 21, 2021, 2 a.m. UTC
In Arm platform, when "RTE_ARCH_ARM64_MEMCPY" is set as true, gcc will
report variable uninitialized warning:

../drivers/crypto/qat/qat_sym_session.c: In function ‘partial_hash_compute’:
../lib/eal/include/generic/rte_byteorder.h:241:24: warning:
‘<U35a0>’ may be used uninitialized in this function
	[-Wmaybe-uninitialized]
	241 | #define rte_bswap32(x) __builtin_bswap32(x)
	...

This is because "digest" will be initialized by "rte_memcpy" function
rather than "memcpy" if "RTE_ARCH_ARM64_MEMCPY" is set as true.
Furthermore, 'rte_memcpy' will initialize 'digest' with two steps
by invoking rte_mov_x functions. For example:

partial_hash_sha1 -> rte_memcpy -> rte_memcpy_ge16_lt_128 ->
step 1: rte_mov16(dst,src )
step 2: rte_mov16(dst - 16 + n, src - 16 + n)

However, gcc compiler cannot identify this multi-step initialization,
then it will report warning.

To fix this, use "memset" to initialize "digest".

Fixes: cd7fc8a84b48 ("eal/arm64: optimize memcpy")
Cc: stable@dpdk.org

Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
Reviewed-by: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
---
v2: add check and free for memory dynamic allocation (David Marchand)
v3: fix compiler error
v4: use 'memset' to initialize digest (Ferruh, Adam)
v5: fixed spelling errors in commit message (Honnappa)


 drivers/crypto/qat/qat_sym_session.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Akhil Goyal June 29, 2021, 8:04 p.m. UTC | #1
> In Arm platform, when "RTE_ARCH_ARM64_MEMCPY" is set as true, gcc will
> report variable uninitialized warning:
> 
> ../drivers/crypto/qat/qat_sym_session.c: In function
> ‘partial_hash_compute’:
> ../lib/eal/include/generic/rte_byteorder.h:241:24: warning:
> ‘<U35a0>’ may be used uninitialized in this function
> 	[-Wmaybe-uninitialized]
> 	241 | #define rte_bswap32(x) __builtin_bswap32(x)
> 	...
> 
> This is because "digest" will be initialized by "rte_memcpy" function
> rather than "memcpy" if "RTE_ARCH_ARM64_MEMCPY" is set as true.
> Furthermore, 'rte_memcpy' will initialize 'digest' with two steps
> by invoking rte_mov_x functions. For example:
> 
> partial_hash_sha1 -> rte_memcpy -> rte_memcpy_ge16_lt_128 ->
> step 1: rte_mov16(dst,src )
> step 2: rte_mov16(dst - 16 + n, src - 16 + n)
> 
> However, gcc compiler cannot identify this multi-step initialization,
> then it will report warning.
> 
> To fix this, use "memset" to initialize "digest".
> 
> Fixes: cd7fc8a84b48 ("eal/arm64: optimize memcpy")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Feifei Wang <feifei.wang2@arm.com>
> Reviewed-by: Ruifeng Wang <ruifeng.wang@arm.com>
> Reviewed-by: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> Acked-by: Adam Dybkowski <adamx.dybkowski@intel.com>
> ---
> v2: add check and free for memory dynamic allocation (David Marchand)
> v3: fix compiler error
> v4: use 'memset' to initialize digest (Ferruh, Adam)
> v5: fixed spelling errors in commit message (Honnappa)
> 
Applied to dpdk-next-crypto

Thanks.
diff mbox series

Patch

diff --git a/drivers/crypto/qat/qat_sym_session.c b/drivers/crypto/qat/qat_sym_session.c
index 231b1640da..e22dd3600c 100644
--- a/drivers/crypto/qat/qat_sym_session.c
+++ b/drivers/crypto/qat/qat_sym_session.c
@@ -1196,6 +1196,9 @@  static int partial_hash_compute(enum icp_qat_hw_auth_algo hash_alg,
 	uint64_t *hash_state_out_be64;
 	int i;
 
+	/* Initialize to avoid gcc warning */
+	memset(digest, 0, sizeof(digest));
+
 	digest_size = qat_hash_get_digest_size(hash_alg);
 	if (digest_size <= 0)
 		return -EFAULT;