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 <davidben@google.com> Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
parent
d0a4059102
commit
2065481c40
@ -100,6 +100,9 @@ static void call_once_thread(void) {
|
|||||||
CRYPTO_once(&g_test_once, once_init);
|
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) {
|
static int test_once(void) {
|
||||||
if (g_once_init_called != 0) {
|
if (g_once_init_called != 0) {
|
||||||
fprintf(stderr, "g_once_init_called was non-zero at start.\n");
|
fprintf(stderr, "g_once_init_called was non-zero at start.\n");
|
||||||
@ -126,10 +129,8 @@ static int test_once(void) {
|
|||||||
if (FIPS_mode()) {
|
if (FIPS_mode()) {
|
||||||
/* Our FIPS tooling currently requires that |CRYPTO_ONCE_INIT| is all
|
/* Our FIPS tooling currently requires that |CRYPTO_ONCE_INIT| is all
|
||||||
* zeros, so the |CRYPTO_once_t| is placed in the bss. */
|
* zeros, so the |CRYPTO_once_t| is placed in the bss. */
|
||||||
static const CRYPTO_once_t once_init_value = CRYPTO_ONCE_INIT;
|
if (OPENSSL_memcmp((void *)&once_init_value, (void *)&once_bss,
|
||||||
static const CRYPTO_once_t once_bss;
|
sizeof(CRYPTO_once_t)) != 0) {
|
||||||
if (OPENSSL_memcmp(&once_init_value, &once_bss, sizeof(CRYPTO_once_t)) !=
|
|
||||||
0) {
|
|
||||||
fprintf(stderr, "CRYPTO_ONCE_INIT did not expand to all zeros.\n");
|
fprintf(stderr, "CRYPTO_ONCE_INIT did not expand to all zeros.\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user