test/crypto: fix warnings for optimization=1 build

Message ID 872fbb13ed0df67f7dedbf3db340464bb7391af1.1654898453.git.rahul.lakkireddy@chelsio.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series test/crypto: fix warnings for optimization=1 build |

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/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Rahul Lakkireddy June 10, 2022, 10:09 p.m. UTC
  Skip IPSec ESN and antireplay cases, if there are no packets. Fixes
following warning when using optimization=1 build flag with GCC 11.

../app/test/test_cryptodev.c: In function ‘test_ipsec_pkt_replay’:
../app/test/test_cryptodev.c:10074:15: warning: ‘td_outb’ may be used uninitialized [-Wmaybe-uninitialized]
         ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                        &flags);
                                        ~~~~~~~
../app/test/test_cryptodev.c:9150:1: note: by argument 1 of type ‘const struct ipsec_test_data[]’ to ‘test_ipsec_proto_process’ declared here
 test_ipsec_proto_process(const struct ipsec_test_data td[],
 ^~~~~~~~~~~~~~~~~~~~~~~~
../app/test/test_cryptodev.c:10056:32: note: ‘td_outb’ declared here
         struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
                                ^~~~~~~

Fixes: d02c6bfcb99a ("test/crypto: add ESN and antireplay cases")
Cc: stable@dpdk.org

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
---
 app/test/test_cryptodev.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Anoob Joseph June 13, 2022, 5:02 a.m. UTC | #1
Hi Rahul,

Please see inline.

Thanks,
Anoob

> -----Original Message-----
> From: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> Sent: Saturday, June 11, 2022 3:40 AM
> To: dev@dpdk.org
> Cc: Akhil Goyal <gakhil@marvell.com>; roy.fan.zhang@intel.com;
> stable@dpdk.org
> Subject: [EXT] [PATCH] test/crypto: fix warnings for optimization=1 build
> 
> External Email
> 
> ----------------------------------------------------------------------
> Skip IPSec ESN and antireplay cases, if there are no packets. Fixes following
> warning when using optimization=1 build flag with GCC 11.
> 
> ../app/test/test_cryptodev.c: In function ‘test_ipsec_pkt_replay’:
> ../app/test/test_cryptodev.c:10074:15: warning: ‘td_outb’ may be used
> uninitialized [-Wmaybe-uninitialized]
>          ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
> 
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>                                         &flags);
>                                         ~~~~~~~
> ../app/test/test_cryptodev.c:9150:1: note: by argument 1 of type ‘const
> struct ipsec_test_data[]’ to ‘test_ipsec_proto_process’ declared here
> test_ipsec_proto_process(const struct ipsec_test_data td[],
> ^~~~~~~~~~~~~~~~~~~~~~~~
> ../app/test/test_cryptodev.c:10056:32: note: ‘td_outb’ declared here
>          struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
>                                 ^~~~~~~
> 
> Fixes: d02c6bfcb99a ("test/crypto: add ESN and antireplay cases")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
> ---
>  app/test/test_cryptodev.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c index
> 524019ce0e..47ce3d8420 100644
> --- a/app/test/test_cryptodev.c
> +++ b/app/test/test_cryptodev.c
> @@ -10058,6 +10058,9 @@ test_ipsec_pkt_replay(const void *test_data,
> const uint64_t esn[],
>  	struct ipsec_test_flags flags;
>  	uint32_t i = 0, ret = 0;
> 
> +	if (nb_pkts == 0)
> +		return TEST_SKIPPED;
> +

[Anoob] nb_pkts == 0 would indicate a badly written test case. Might be better to return TEST_FAILED in that case.
 
>  	memset(&flags, 0, sizeof(flags));
>  	flags.antireplay = true;
> 
> --
> 2.27.0
  

Patch

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 524019ce0e..47ce3d8420 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -10058,6 +10058,9 @@  test_ipsec_pkt_replay(const void *test_data, const uint64_t esn[],
 	struct ipsec_test_flags flags;
 	uint32_t i = 0, ret = 0;
 
+	if (nb_pkts == 0)
+		return TEST_SKIPPED;
+
 	memset(&flags, 0, sizeof(flags));
 	flags.antireplay = true;