Use one C99-style for loop. Switch one for loop to the new spelling as a canary. All our compilers seem to support it fine, except GCC needs to be told to build with -std=c99. (And, upon doing so, it'll require _XOPEN_SOURCE=700 for pthread_rwlock_t.) We'll let this sit for a bit until it's gotten into downstreams without issue and then open the floodgates. BUG=47 Change-Id: I1c69d4b2df8206e0b55f30aa59b5874d82fca893 Reviewed-on: https://boringssl-review.googlesource.com/8235 Reviewed-by: Adam Langley <agl@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c5db63..bd7f432 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -98,9 +98,18 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") endif() -if((CMAKE_COMPILER_IS_GNUCXX AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR - CMAKE_CXX_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -D_XOPEN_SOURCE=700") +if(CMAKE_COMPILER_IS_GNUCXX) + if ((CMAKE_C_COMPILER_VERSION VERSION_GREATER "4.8.99") OR + CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") + endif() +endif() + +# pthread_rwlock_t requires a feature flag. +if(NOT WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700") endif() if(FUZZ)
diff --git a/crypto/mem.c b/crypto/mem.c index 7d73c73..c83eb5a 100644 --- a/crypto/mem.c +++ b/crypto/mem.c
@@ -118,12 +118,11 @@ } int CRYPTO_memcmp(const void *in_a, const void *in_b, size_t len) { - size_t i; const uint8_t *a = in_a; const uint8_t *b = in_b; uint8_t x = 0; - for (i = 0; i < len; i++) { + for (size_t i = 0; i < len; i++) { x |= a[i] ^ b[i]; }