Fix pointer-to-non-volatile cast in thread_win.c. Casting a pointer-to-non-volatile to pointer-to-volatile can be a no-op as the compiler only requires volatile semantics when the pointed-to object is a volatile object and there are no pointers-to-non-volatile involved. This probably doesn't matter unless building with the MSVC -volatile:iso flag, and maybe not even then, but it is good practice anyway. Change-Id: I94900d3dc61de3b8ce2ddecab2811907a9a7adbf Reviewed-on: https://boringssl-review.googlesource.com/6973 Reviewed-by: David Benjamin <davidben@google.com>
diff --git a/crypto/internal.h b/crypto/internal.h index fe4ed73..5574aab 100644 --- a/crypto/internal.h +++ b/crypto/internal.h
@@ -334,7 +334,7 @@ typedef uint32_t CRYPTO_once_t; #define CRYPTO_ONCE_INIT 0 #elif defined(OPENSSL_WINDOWS) -typedef LONG CRYPTO_once_t; +typedef volatile LONG CRYPTO_once_t; #define CRYPTO_ONCE_INIT 0 #else typedef pthread_once_t CRYPTO_once_t;
diff --git a/crypto/thread_win.c b/crypto/thread_win.c index 5efd8be..e1b3a54 100644 --- a/crypto/thread_win.c +++ b/crypto/thread_win.c
@@ -31,9 +31,7 @@ OPENSSL_COMPILE_ASSERT(sizeof(CRYPTO_MUTEX) >= sizeof(CRITICAL_SECTION), CRYPTO_MUTEX_too_small); -static void run_once(CRYPTO_once_t *in_once, void (*init)(void *), void *arg) { - volatile LONG *once = in_once; - +static void run_once(CRYPTO_once_t *once, void (*init)(void *), void *arg) { /* Values must be aligned. */ assert((((uintptr_t) once) & 3) == 0);