[dpdk-dev,10/10] app/test-crypto-perf: fix compilation with -Og

Message ID 20170911151333.5727-11-olivier.matz@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Olivier Matz Sept. 11, 2017, 3:13 p.m. UTC
  The compilation with gcc-6.3.0 and EXTRA_CFLAGS=-Og gives the following
error:

  CC cperf_test_verify.o
cperf_test_verify.c: In function ‘cperf_verify_op’:
cperf_test_verify.c:382:5: error: ‘auth’ may be used uninitialized
                           in this function
                           [-Werror=maybe-uninitialized]
  if (auth == 1) {
     ^
cperf_test_verify.c:371:5: error: ‘cipher’ may be used uninitialized
                           in this function
			   [-Werror=maybe-uninitialized]
  if (cipher == 1) {
     ^
cperf_test_verify.c:384:11: error: ‘auth_offset’ may be used
			    uninitialized in this function
			    [-Werror=maybe-uninitialized]
    res += memcmp(data + auth_offset,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
      vector->digest.data,
      ~~~~~~~~~~~~~~~~~~~~
      options->digest_sz);
      ~~~~~~~~~~~~~~~~~~~
cperf_test_verify.c:377:11: error: ‘cipher_offset’ may be used
                            uninitialized in this function
                            [-Werror=maybe-uninitialized]
    res += memcmp(data + cipher_offset,
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
      vector->plaintext.data,
      ~~~~~~~~~~~~~~~~~~~~~~~
      options->test_buffer_size);
      ~~~~~~~~~~~~~~~~~~~~~~~~~~

There is no default case in the switch statement, so if options->op_type
is an unknown value, the function will use uninitialized values. Fix it
by adding a default.

Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test application")

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
---
 app/test-crypto-perf/cperf_test_verify.c | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

De Lara Guarch, Pablo Oct. 5, 2017, 9:36 a.m. UTC | #1
> -----Original Message-----

> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Olivier Matz

> Sent: Monday, September 11, 2017 4:14 PM

> To: dev@dpdk.org

> Subject: [dpdk-dev] [PATCH 10/10] app/test-crypto-perf: fix compilation

> with -Og

> 

> The compilation with gcc-6.3.0 and EXTRA_CFLAGS=-Og gives the following

> error:

> 

>   CC cperf_test_verify.o

> cperf_test_verify.c: In function ‘cperf_verify_op’:

> cperf_test_verify.c:382:5: error: ‘auth’ may be used uninitialized

>                            in this function

>                            [-Werror=maybe-uninitialized]

>   if (auth == 1) {

>      ^

> cperf_test_verify.c:371:5: error: ‘cipher’ may be used uninitialized

>                            in this function

> 			   [-Werror=maybe-uninitialized]

>   if (cipher == 1) {

>      ^

> cperf_test_verify.c:384:11: error: ‘auth_offset’ may be used

> 			    uninitialized in this function

> 			    [-Werror=maybe-uninitialized]

>     res += memcmp(data + auth_offset,

>            ^~~~~~~~~~~~~~~~~~~~~~~~~~

>       vector->digest.data,

>       ~~~~~~~~~~~~~~~~~~~~

>       options->digest_sz);

>       ~~~~~~~~~~~~~~~~~~~

> cperf_test_verify.c:377:11: error: ‘cipher_offset’ may be used

>                             uninitialized in this function

>                             [-Werror=maybe-uninitialized]

>     res += memcmp(data + cipher_offset,

>            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

>       vector->plaintext.data,

>       ~~~~~~~~~~~~~~~~~~~~~~~

>       options->test_buffer_size);

>       ~~~~~~~~~~~~~~~~~~~~~~~~~~

> 

> There is no default case in the switch statement, so if options->op_type is

> an unknown value, the function will use uninitialized values. Fix it by adding

> a default.

> 

> Fixes: f8be1786b1b8 ("app/crypto-perf: introduce performance test

> application")

> 

> Signed-off-by: Olivier Matz <olivier.matz@6wind.com>


Acked-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>


Before applying this patch and patch 9, title should be renamed to
"app/crypto-perf", since that's the convention that we are using.

Thanks,
Pablo
  

Patch

diff --git a/app/test-crypto-perf/cperf_test_verify.c b/app/test-crypto-perf/cperf_test_verify.c
index 5221f2251..36be7b864 100644
--- a/app/test-crypto-perf/cperf_test_verify.c
+++ b/app/test-crypto-perf/cperf_test_verify.c
@@ -366,6 +366,9 @@  cperf_verify_op(struct rte_crypto_op *op,
 		auth = 1;
 		auth_offset = vector->aad.length + options->test_buffer_size;
 		break;
+	default:
+		res = 1;
+		goto out;
 	}
 
 	if (cipher == 1) {
@@ -386,6 +389,7 @@  cperf_verify_op(struct rte_crypto_op *op,
 					options->digest_sz);
 	}
 
+out:
 	rte_free(data);
 	return !!res;
 }