Skip to contentSkip to conversation

Fix non-C99-compliant builds: don't use const size_t as array length

PATCH In review Steffan Karger 2 participants 2 messages Mar 16, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix non-C99-compliant builds: don't use const size_t as array length

---
 src/openvpn/crypto_openssl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
src/openvpn/crypto_openssl.c +2 -3
index 5f28391..9139480 100644
@@ -292,8 +292,7 @@ show_available_ciphers()
     size_t i;
 
     /* If we ever exceed this, we must be more selective */
-    const size_t cipher_list_len = 1000;
-    const EVP_CIPHER *cipher_list[cipher_list_len];
+    const EVP_CIPHER *cipher_list[1000];
     size_t num_ciphers = 0;
 #ifndef ENABLE_SMALL
     printf("The following ciphers and cipher modes are available for use\n"
@@ -318,7 +317,7 @@ show_available_ciphers()
         {
             cipher_list[num_ciphers++] = cipher;
         }
-        if (num_ciphers == cipher_list_len)
+        if (num_ciphers == (sizeof(cipher_list)/sizeof(*cipher_list)))
         {
             msg(M_WARN, "WARNING: Too many ciphers, not showing all");
             break;
Signature · 1 line
2.7.4
#1 lore raw

ACK, thanks ("stared at code, ran my test suite").

Your patch has been applied to the master and release/2.4 branch.

Hopefully this should build with MSVC now :-)

commit db1b4d96bfe7e744a0dec8f86cb041c32fb87964 (master) commit ce40258ddd0170df60633baab2c3d17f2c104671 (release/2.4)

Author: Steffan Karger
Date:   Thu Mar 16 10:12:17 2017 +0100
     Fix non-C99-compliant builds: don't use const size_t as array length

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://www.mail-archive.com/search?l=mid&[email protected]...
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering