diff options
author | Daiki Ueno <dueno@redhat.com> | 2021-03-27 08:36:01 +0100 |
---|---|---|
committer | Daiki Ueno <dueno@redhat.com> | 2021-03-27 08:39:59 +0100 |
commit | 06d6ef335457490c0bcb552ee306577e141bafaf (patch) | |
tree | d3cac6290a9cb65652965c028b30b3e26b84f132 | |
parent | d5972ced439c414982bbbf821239b65097b04699 (diff) | |
download | nettle-06d6ef335457490c0bcb552ee306577e141bafaf.tar.gz |
nettle-benchmark: avoid -Wmaybe-uninitialized warnings
Otherwise GCC 11 prints the following warning:
nettle-benchmark.c: In function ‘time_umac’:
../umac.h:42:25: warning: ‘key’ may be used uninitialized [-Wmaybe-uninitialized]
42 | #define umac32_set_key nettle_umac32_set_key
nettle-benchmark.c:395:3: note: in expansion of macro ‘umac32_set_key’
395 | umac32_set_key (&ctx32, key);
| ^~~~~~~~~~~~~~
Although this should be harmless as it's in the benchmarking code and
the content of the key doesn't matter, it wouldn't hurt to explicitly
initialize it. This patch also uses predefined constants for key
sizes.
-rw-r--r-- | examples/nettle-benchmark.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/examples/nettle-benchmark.c b/examples/nettle-benchmark.c index ca6346e0..9ce3a733 100644 --- a/examples/nettle-benchmark.c +++ b/examples/nettle-benchmark.c @@ -390,7 +390,9 @@ time_umac(void) struct umac96_ctx ctx96; struct umac128_ctx ctx128; - uint8_t key[16]; + uint8_t key[UMAC_KEY_SIZE]; + + init_key (sizeof(key), key); umac32_set_key (&ctx32, key); info.ctx = &ctx32; @@ -432,7 +434,9 @@ time_cmac(void) struct bench_hash_info info; struct cmac_aes128_ctx ctx; - uint8_t key[16]; + uint8_t key[AES128_KEY_SIZE]; + + init_key (sizeof(key), key); cmac_aes128_set_key (&ctx, key); info.ctx = &ctx; @@ -449,7 +453,9 @@ time_poly1305_aes(void) static uint8_t data[BENCH_BLOCK]; struct bench_hash_info info; struct poly1305_aes_ctx ctx; - uint8_t key[32]; + uint8_t key[POLY1305_AES_KEY_SIZE]; + + init_key (sizeof(key), key); poly1305_aes_set_key (&ctx, key); info.ctx = &ctx; |