These gcc warnings are justified: test-gc-rijndael.c:70:16: warning: declaration of 'i' shadows a previous local [-Wshadow=compatible-local] test-gc-rijndael.c:93:16: warning: declaration of 'i' shadows a previous local [-Wshadow=compatible-local] test-gc-rijndael.c:147:16: warning: declaration of 'i' shadows a previous local [-Wshadow=compatible-local] test-rijndael.c:61:14: warning: declaration of 'i' shadows a previous local [-Wshadow=compatible-local] test-rijndael.c:92:14: warning: declaration of 'i' shadows a previous local [-Wshadow=compatible-local]
It makes the code clearer when different variable names are used for different purposes. 2023-09-04 Bruno Haible <br...@clisp.org> crypto/{gc-rijndael,rijndael} tests: Fix some gcc -Wshadow warnings. * tests/test-gc-rijndael.c (main): Rename local variable 'i' to 'round'. * tests/test-rijndael.c (main): Likewise. diff --git a/tests/test-gc-rijndael.c b/tests/test-gc-rijndael.c index 2439d89201..ba014d7bf3 100644 --- a/tests/test-gc-rijndael.c +++ b/tests/test-gc-rijndael.c @@ -43,7 +43,7 @@ main (int argc, char *argv[]) char ct[] = "\xC3\x4C\x05\x2C\xC0\xDA\x8D\x73" "\x45\x1A\xFE\x5F\x03\xBE\x29\x7F"; gc_cipher_handle ctx; - size_t i; + size_t round; rc = gc_cipher_open (GC_AES128, GC_ECB, &ctx); if (rc != GC_OK) @@ -55,7 +55,7 @@ main (int argc, char *argv[]) memcpy (buf, pt, 16); - for (i = 0; i < 10000; i++) + for (round = 0; round < 10000; round++) { rc = gc_cipher_encrypt_inline (ctx, 16, buf); if (rc != GC_OK) @@ -78,7 +78,7 @@ main (int argc, char *argv[]) return 1; } - for (i = 0; i < 10000; i++) + for (round = 0; round < 10000; round++) { rc = gc_cipher_decrypt_inline (ctx, 16, buf); if (rc != GC_OK) @@ -116,7 +116,7 @@ main (int argc, char *argv[]) char ct[] = "\x66\xe9\x4b\xd4\xef\x8a\x2c\x3b" "\x88\x4c\xfa\x59\xca\x34\x2b\x2e"; gc_cipher_handle ctx; - size_t i; + size_t round; rc = gc_cipher_open (GC_AES128, GC_CBC, &ctx); if (rc != GC_OK) @@ -132,7 +132,7 @@ main (int argc, char *argv[]) memcpy (buf, pt, 16); - for (i = 0; i < 10000; i++) + for (round = 0; round < 10000; round++) { rc = gc_cipher_encrypt_inline (ctx, 16, buf); if (rc != GC_OK) diff --git a/tests/test-rijndael.c b/tests/test-rijndael.c index b77ba66425..30b3d5ce50 100644 --- a/tests/test-rijndael.c +++ b/tests/test-rijndael.c @@ -34,7 +34,7 @@ main (int argc, char *argv[]) "\x00\x00\x00\x00\x00\x00\x00\x00"; char ct[] = "\xC3\x4C\x05\x2C\xC0\xDA\x8D\x73" "\x45\x1A\xFE\x5F\x03\xBE\x29\x7F"; - size_t i; + size_t round; rc = rijndaelMakeKey (&key, RIJNDAEL_DIR_ENCRYPT, 128, "00000000000000000000000000000000"); @@ -47,7 +47,7 @@ main (int argc, char *argv[]) memset (in, 0, RIJNDAEL_BITSPERBLOCK / 8); - for (i = 0; i < 10000; i++) + for (round = 0; round < 10000; round++) { rc = rijndaelBlockEncrypt (&cipher, &key, in, 128, out); if (rc < 0) @@ -78,7 +78,7 @@ main (int argc, char *argv[]) if (rc != 0) printf ("cipherInit failed %d\n", rc); - for (i = 0; i < 10000; i++) + for (round = 0; round < 10000; round++) { memcpy (in, out, RIJNDAEL_BITSPERBLOCK / 8);