From 2065481c401dcfc66f6ca2f405bda73a2ae38717 Mon Sep 17 00:00:00 2001 From: David Benjamin Date: Fri, 7 Apr 2017 11:29:35 -0400 Subject: [PATCH] Fix CRYPTO_once_t initialization test. Windows doesn't like uninitialized function-level static consts and Android complains we're casting away a volatile. Change-Id: I7c53de45cff9fa2ef298f015cf3f5ecca82194d0 Reviewed-on: https://boringssl-review.googlesource.com/14807 Commit-Queue: David Benjamin Reviewed-by: Adam Langley --- crypto/thread_test.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crypto/thread_test.c b/crypto/thread_test.c index bc6bfa74..714bef7a 100644 --- a/crypto/thread_test.c +++ b/crypto/thread_test.c @@ -100,6 +100,9 @@ static void call_once_thread(void) { CRYPTO_once(&g_test_once, once_init); } +static CRYPTO_once_t once_init_value = CRYPTO_ONCE_INIT; +static CRYPTO_once_t once_bss; + static int test_once(void) { if (g_once_init_called != 0) { fprintf(stderr, "g_once_init_called was non-zero at start.\n"); @@ -126,10 +129,8 @@ static int test_once(void) { if (FIPS_mode()) { /* Our FIPS tooling currently requires that |CRYPTO_ONCE_INIT| is all * zeros, so the |CRYPTO_once_t| is placed in the bss. */ - static const CRYPTO_once_t once_init_value = CRYPTO_ONCE_INIT; - static const CRYPTO_once_t once_bss; - if (OPENSSL_memcmp(&once_init_value, &once_bss, sizeof(CRYPTO_once_t)) != - 0) { + if (OPENSSL_memcmp((void *)&once_init_value, (void *)&once_bss, + sizeof(CRYPTO_once_t)) != 0) { fprintf(stderr, "CRYPTO_ONCE_INIT did not expand to all zeros.\n"); return 0; }