From 06d6ef335457490c0bcb552ee306577e141bafaf Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Sat, 27 Mar 2021 08:36:01 +0100 Subject: [PATCH] nettle-benchmark: avoid -Wmaybe-uninitialized warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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. --- examples/nettle-benchmark.c | 12 +++++++++--- 1 file 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; -- 2.47.2