From 8fa6c2a30199e6d4cb29cb915cad05346782d9dd Mon Sep 17 00:00:00 2001 From: graebm Date: Fri, 31 May 2019 11:11:01 -0700 Subject: [PATCH] Update dependencies (#24) Using latest tagged version of all dependencies. --- CMakeLists.txt | 6 +-- aws-common-runtime/CMakeLists.txt | 17 ++++--- .../cmake/BuildAwsCCompression.cmake | 50 +++++++++++++++++++ aws-common-runtime/cmake/BuildAwsCHttp.cmake | 3 -- codebuild/common-windows.bat | 4 +- include/aws/crt/StlAllocator.h | 5 +- include/aws/crt/Types.h | 3 +- samples/mqtt_pub_sub/CMakeLists.txt | 2 +- source/Api.cpp | 3 +- source/JsonObject.cpp | 34 ++++++------- source/Types.cpp | 9 +++- source/UUID.cpp | 3 +- source/http/HttpConnection.cpp | 10 ++-- source/http/HttpConnectionManager.cpp | 2 +- tests/DateTimeTest.cpp | 2 +- tests/HMACTest.cpp | 3 +- tests/HashTest.cpp | 6 +-- tests/HttpClientTest.cpp | 6 +-- 18 files changed, 111 insertions(+), 57 deletions(-) create mode 100644 aws-common-runtime/cmake/BuildAwsCCompression.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a51520c94..48c2717e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ set(AWS_CRT_CPP_VERSION "v0.3.0") configure_file(include/aws/crt/Config.h.in ${CMAKE_CURRENT_LIST_DIR}/include/aws/crt/Config.h @ONLY) if (BUILD_DEPS) - set(AWS_DEPS_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps) + set(AWS_DEPS_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/deps CACHE STRING "If BUILD_DEPS is on, aws common runtime dependencies build in this directory.") if (DEFINED CMAKE_INSTALL_PREFIX) set(AWS_DEPS_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}) else() @@ -136,7 +136,7 @@ file(GLOB AWS_CRT_CPP_HEADERS ${AWS_CRT_EXTERNAL_HEADERS} ) -file(GLOB AWS_CRT_SRC +file(GLOB AWS_CRT_SRC "source/*.cpp" ) @@ -208,7 +208,7 @@ aws_prepare_symbol_visibility_args(${CMAKE_PROJECT_NAME} "AWS_CRT_CPP") #set warnings if (MSVC) - target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W4 /WX) + target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE /W4 /WX /wd4068) else () target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -Wall -Wno-long-long -pedantic -Werror) endif () diff --git a/aws-common-runtime/CMakeLists.txt b/aws-common-runtime/CMakeLists.txt index 20bdb3cbd..864968ef7 100644 --- a/aws-common-runtime/CMakeLists.txt +++ b/aws-common-runtime/CMakeLists.txt @@ -17,7 +17,7 @@ set(AWS_DEPS_DOWNLOAD_DIR "${AWS_DEPS_BUILD_DIR}/downloads" CACHE PATH "Dependen message("install dir ${AWS_DEPS_INSTALL_DIR}") set(AWS_C_COMMON_URL "https://github.com/awslabs/aws-c-common.git") -set(AWS_C_COMMON_SHA "v0.3.6") +set(AWS_C_COMMON_SHA "v0.3.11") include(BuildAwsCCommon) if (UNIX AND NOT APPLE) @@ -27,23 +27,28 @@ if (UNIX AND NOT APPLE) endif() set(AWS_C_IO_URL "https://github.com/awslabs/aws-c-io.git") -set(AWS_C_IO_SHA "v0.3.0") +set(AWS_C_IO_SHA "v0.3.9") include(BuildAwsCIO) +set(AWS_C_COMPRESSION_URL "https://github.com/awslabs/aws-c-compression.git") +set(AWS_C_COMPRESSION_SHA "v0.2.1") +include(BuildAwsCCompression) + set(AWS_C_HTTP_URL "https://github.com/awslabs/aws-c-http.git") -set(AWS_C_HTTP_SHA "v0.2.2") +set(AWS_C_HTTP_SHA "v0.2.16") include(BuildAwsCHttp) set(AWS_C_MQTT_URL "https://github.com/awslabs/aws-c-mqtt.git") -set(AWS_C_MQTT_SHA "v0.3.5") +set(AWS_C_MQTT_SHA "v0.3.7") include(BuildAwsCMqtt) set(AWS_C_CAL_URL "https://github.com/awslabs/aws-c-cal.git") -set(AWS_C_CAL_SHA "v0.1.4") +set(AWS_C_CAL_SHA "v0.1.5") include(BuildAwsCCal) +add_dependencies(AwsCCompression AwsCCommon) add_dependencies(AwsCMqtt AwsCIO) -add_dependencies(AwsCHttp AwsCIO) +add_dependencies(AwsCHttp AwsCIO AwsCCompression) add_dependencies(AwsCCal AwsCCommon) if (UNIX AND NOT APPLE) diff --git a/aws-common-runtime/cmake/BuildAwsCCompression.cmake b/aws-common-runtime/cmake/BuildAwsCCompression.cmake new file mode 100644 index 000000000..c623d7299 --- /dev/null +++ b/aws-common-runtime/cmake/BuildAwsCCompression.cmake @@ -0,0 +1,50 @@ +if("${TARGET_ARCH}" STREQUAL ANDROID) + ExternalProject_Add(AwsCCompression + PREFIX ${AWS_DEPS_BUILD_DIR} + GIT_REPOSITORY ${AWS_C_COMPRESSION_URL} + GIT_TAG ${AWS_C_COMPRESSION_SHA} + BUILD_IN_SOURCE 0 + UPDATE_COMMAND "" + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} + -DANDROID_ABI=${ANDROID_ABI} + -DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME} + -DANDROID_STANDALONE_TOOLCHAIN=${ANDROID_STANDALONE_TOOLCHAIN} + -DANDROID_STL=${ANDROID_STL} + -DENABLE_HW_OPTIMIZATION=OFF + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + ) +elseif(MSVC) + ExternalProject_Add(AwsCCompression + PREFIX ${AWS_DEPS_BUILD_DIR} + GIT_REPOSITORY ${AWS_C_COMPRESSION_URL} + GIT_TAG ${AWS_C_COMPRESSION_SHA} + BUILD_IN_SOURCE 0 + UPDATE_COMMAND "" + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + ) +else() + ExternalProject_Add(AwsCCompression + PREFIX ${AWS_DEPS_BUILD_DIR} + GIT_REPOSITORY ${AWS_C_COMPRESSION_URL} + GIT_TAG ${AWS_C_COMPRESSION_SHA} + BUILD_IN_SOURCE 0 + UPDATE_COMMAND "" + CMAKE_ARGS + -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} + -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} + -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} + ) +endif() \ No newline at end of file diff --git a/aws-common-runtime/cmake/BuildAwsCHttp.cmake b/aws-common-runtime/cmake/BuildAwsCHttp.cmake index 17edf19e1..ae0081c36 100644 --- a/aws-common-runtime/cmake/BuildAwsCHttp.cmake +++ b/aws-common-runtime/cmake/BuildAwsCHttp.cmake @@ -6,7 +6,6 @@ if("${TARGET_ARCH}" STREQUAL ANDROID) BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS - -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -28,7 +27,6 @@ elseif(MSVC) BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS - -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} @@ -45,7 +43,6 @@ else() BUILD_IN_SOURCE 0 UPDATE_COMMAND "" CMAKE_ARGS - -DCMAKE_PREFIX_PATH=${AWS_DEPS_INSTALL_DIR} -DCMAKE_INSTALL_PREFIX=${AWS_DEPS_INSTALL_DIR} -DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} diff --git a/codebuild/common-windows.bat b/codebuild/common-windows.bat index e23fd2da8..17482e976 100644 --- a/codebuild/common-windows.bat +++ b/codebuild/common-windows.bat @@ -1,7 +1,9 @@ mkdir build cd build -cmake %* -DBUILD_DEPS=ON -DCMAKE_BUILD_TYPE="Release" ../ || goto error + +REM Building deps to %TEMP% to avoid max path length errors during build +cmake %* -DBUILD_DEPS=ON -DAWS_DEPS_BUILD_DIR="%TEMP%" -DCMAKE_BUILD_TYPE="Release" ../ || goto error msbuild.exe aws-crt-cpp.vcxproj /p:Configuration=Release || goto error msbuild.exe tests/aws-crt-cpp-tests.vcxproj /p:Configuration=Release ctest -V || goto error diff --git a/include/aws/crt/StlAllocator.h b/include/aws/crt/StlAllocator.h index 1e5d84942..0f1f1ba00 100644 --- a/include/aws/crt/StlAllocator.h +++ b/include/aws/crt/StlAllocator.h @@ -14,7 +14,6 @@ * permissions and limitations under the License. */ -#include #include #include @@ -48,13 +47,13 @@ namespace Aws typename Base::pointer allocate(size_type n, const void *hint = nullptr) { (void)hint; - assert(g_allocator); + AWS_ASSERT(g_allocator); return reinterpret_cast(aws_mem_acquire(g_allocator, n * sizeof(T))); } void deallocate(typename Base::pointer p, size_type) { - assert(g_allocator); + AWS_ASSERT(g_allocator); aws_mem_release(g_allocator, p); } }; diff --git a/include/aws/crt/Types.h b/include/aws/crt/Types.h index c640a898f..575e0048a 100644 --- a/include/aws/crt/Types.h +++ b/include/aws/crt/Types.h @@ -67,7 +67,8 @@ namespace Aws AWS_CRT_CPP_API Allocator *DefaultAllocator() noexcept; AWS_CRT_CPP_API ByteBuf ByteBufFromCString(const char *str) noexcept; - AWS_CRT_CPP_API ByteBuf ByteBufFromArray(const uint8_t *array, size_t len) noexcept; + AWS_CRT_CPP_API ByteBuf ByteBufFromEmptyArray(const uint8_t *array, size_t len) noexcept; + AWS_CRT_CPP_API ByteBuf ByteBufFromArray(const uint8_t *array, size_t capacity) noexcept; AWS_CRT_CPP_API ByteBuf ByteBufNewCopy(Allocator *alloc, const uint8_t *array, size_t len); AWS_CRT_CPP_API void ByteBufDelete(ByteBuf &); diff --git a/samples/mqtt_pub_sub/CMakeLists.txt b/samples/mqtt_pub_sub/CMakeLists.txt index d4f167a48..c80af2d51 100644 --- a/samples/mqtt_pub_sub/CMakeLists.txt +++ b/samples/mqtt_pub_sub/CMakeLists.txt @@ -15,7 +15,7 @@ set(CMAKE_C_FLAGS_DEBUGOPT "") #set warnings if (MSVC) - target_compile_options(${PUB_SUB_PROJECT_NAME} PRIVATE /W4 /WX) + target_compile_options(${PUB_SUB_PROJECT_NAME} PRIVATE /W4 /WX /wd4068) else () target_compile_options(${PUB_SUB_PROJECT_NAME} PRIVATE -Wall -Wno-long-long -pedantic -Werror) endif () diff --git a/source/Api.cpp b/source/Api.cpp index 4083c5461..2e0f08261 100644 --- a/source/Api.cpp +++ b/source/Api.cpp @@ -35,6 +35,7 @@ namespace Aws g_allocator = allocator; Io::InitTlsStaticState(allocator); aws_http_library_init(allocator); + aws_mqtt_library_init(allocator); cJSON_Hooks hooks; hooks.malloc_fn = s_cJSONAlloc; @@ -45,6 +46,7 @@ namespace Aws static void s_cleanUpApi() { g_allocator = nullptr; + aws_mqtt_library_clean_up(); aws_http_library_clean_up(); Io::CleanUpTlsStaticState(); } @@ -59,7 +61,6 @@ namespace Aws { aws_load_error_strings(); aws_io_load_error_strings(); - aws_mqtt_load_error_strings(); } const char *ErrorDebugString(int error) noexcept { return aws_error_debug_str(error); } diff --git a/source/JsonObject.cpp b/source/JsonObject.cpp index d8769e7dd..e691a3adb 100644 --- a/source/JsonObject.cpp +++ b/source/JsonObject.cpp @@ -359,7 +359,7 @@ namespace Aws String JsonView::GetString(const char *key) const { - assert(m_value); + AWS_ASSERT(m_value); auto item = cJSON_GetObjectItemCaseSensitive(m_value, key); auto str = cJSON_GetStringValue(item); return str != nullptr ? str : ""; @@ -379,15 +379,15 @@ namespace Aws bool JsonView::GetBool(const char *key) const { - assert(m_value); + AWS_ASSERT(m_value); auto item = cJSON_GetObjectItemCaseSensitive(m_value, key); - assert(item); + AWS_ASSERT(item); return item->valueint != 0; } bool JsonView::AsBool() const { - assert(cJSON_IsBool(m_value)); + AWS_ASSERT(cJSON_IsBool(m_value)); return cJSON_IsTrue(m_value) != 0; } @@ -395,15 +395,15 @@ namespace Aws int JsonView::GetInteger(const char *key) const { - assert(m_value); + AWS_ASSERT(m_value); auto item = cJSON_GetObjectItemCaseSensitive(m_value, key); - assert(item); + AWS_ASSERT(item); return item->valueint; } int JsonView::AsInteger() const { - assert(cJSON_IsNumber(m_value)); // can be double or value larger than int_max, but at least not UB + AWS_ASSERT(cJSON_IsNumber(m_value)); // can be double or value larger than int_max, but at least not UB return m_value->valueint; } @@ -413,7 +413,7 @@ namespace Aws int64_t JsonView::AsInt64() const { - assert(cJSON_IsNumber(m_value)); + AWS_ASSERT(cJSON_IsNumber(m_value)); return static_cast(m_value->valuedouble); } @@ -421,15 +421,15 @@ namespace Aws double JsonView::GetDouble(const char *key) const { - assert(m_value); + AWS_ASSERT(m_value); auto item = cJSON_GetObjectItemCaseSensitive(m_value, key); - assert(item); + AWS_ASSERT(item); return item->valuedouble; } double JsonView::AsDouble() const { - assert(cJSON_IsNumber(m_value)); + AWS_ASSERT(cJSON_IsNumber(m_value)); return m_value->valuedouble; } @@ -437,7 +437,7 @@ namespace Aws JsonView JsonView::GetJsonObject(const char *key) const { - assert(m_value); + AWS_ASSERT(m_value); auto item = cJSON_GetObjectItemCaseSensitive(m_value, key); return item; } @@ -446,14 +446,14 @@ namespace Aws JsonObject JsonView::GetJsonObjectCopy(const char *key) const { - assert(m_value); + AWS_ASSERT(m_value); /* force a deep copy */ return JsonObject(cJSON_GetObjectItemCaseSensitive(m_value, key)); } JsonView JsonView::AsObject() const { - assert(cJSON_IsObject(m_value)); + AWS_ASSERT(cJSON_IsObject(m_value)); return m_value; } @@ -461,9 +461,9 @@ namespace Aws Vector JsonView::GetArray(const char *key) const { - assert(m_value); + AWS_ASSERT(m_value); auto array = cJSON_GetObjectItemCaseSensitive(m_value, key); - assert(cJSON_IsArray(array)); + AWS_ASSERT(cJSON_IsArray(array)); Vector returnArray(static_cast(cJSON_GetArraySize(array))); auto element = array->child; @@ -477,7 +477,7 @@ namespace Aws Vector JsonView::AsArray() const { - assert(cJSON_IsArray(m_value)); + AWS_ASSERT(cJSON_IsArray(m_value)); Vector returnArray(static_cast(cJSON_GetArraySize(m_value))); auto element = m_value->child; diff --git a/source/Types.cpp b/source/Types.cpp index 2ebab1b6d..71f2da2d2 100644 --- a/source/Types.cpp +++ b/source/Types.cpp @@ -24,9 +24,14 @@ namespace Aws ByteBuf ByteBufFromCString(const char *str) noexcept { return aws_byte_buf_from_c_str(str); } - ByteBuf ByteBufFromArray(const uint8_t *array, size_t len) noexcept + ByteBuf ByteBufFromEmptyArray(const uint8_t *array, size_t len) noexcept { - return aws_byte_buf_from_array(array, len); + return aws_byte_buf_from_empty_array(array, len); + } + + ByteBuf ByteBufFromArray(const uint8_t *array, size_t capacity) noexcept + { + return aws_byte_buf_from_array(array, capacity); } ByteBuf ByteBufNewCopy(Allocator *alloc, const uint8_t *array, size_t len) diff --git a/source/UUID.cpp b/source/UUID.cpp index 0adefbfac..298a4c744 100644 --- a/source/UUID.cpp +++ b/source/UUID.cpp @@ -50,8 +50,7 @@ namespace Aws String uuidStr; uuidStr.reserve(AWS_UUID_STR_LEN); - auto outBuf = ByteBufFromArray(reinterpret_cast(uuidStr.data()), uuidStr.capacity()); - outBuf.len = 0; + auto outBuf = ByteBufFromEmptyArray(reinterpret_cast(uuidStr.data()), uuidStr.capacity()); aws_uuid_to_str(&m_uuid, &outBuf); return uuidStr; } diff --git a/source/http/HttpConnection.cpp b/source/http/HttpConnection.cpp index 4e06c38a6..98ef363a1 100644 --- a/source/http/HttpConnection.cpp +++ b/source/http/HttpConnection.cpp @@ -97,9 +97,9 @@ namespace Aws bool HttpClientConnection::CreateConnection(const HttpClientConnectionOptions &connectionOptions) noexcept { - assert(connectionOptions.onConnectionSetup); - assert(connectionOptions.onConnectionShutdown); - assert(connectionOptions.socketOptions); + AWS_ASSERT(connectionOptions.onConnectionSetup); + AWS_ASSERT(connectionOptions.onConnectionShutdown); + AWS_ASSERT(connectionOptions.socketOptions); auto *callbackData = New(connectionOptions.allocator, connectionOptions.allocator); @@ -162,8 +162,8 @@ namespace Aws std::shared_ptr HttpClientConnection::NewClientStream( const HttpRequestOptions &requestOptions) noexcept { - assert(requestOptions.onIncomingHeaders); - assert(requestOptions.onStreamComplete); + AWS_ASSERT(requestOptions.onIncomingHeaders); + AWS_ASSERT(requestOptions.onStreamComplete); aws_http_request_options options; AWS_ZERO_STRUCT(options); diff --git a/source/http/HttpConnectionManager.cpp b/source/http/HttpConnectionManager.cpp index c1d6c0d09..12d788090 100644 --- a/source/http/HttpConnectionManager.cpp +++ b/source/http/HttpConnectionManager.cpp @@ -53,7 +53,7 @@ namespace Aws { m_initialWindowSize = connectionManagerOptions.initialWindowSize; m_bootstrap = connectionManagerOptions.bootstrap; - assert(connectionManagerOptions.hostName.ptr && connectionManagerOptions.hostName.len); + AWS_ASSERT(connectionManagerOptions.hostName.ptr && connectionManagerOptions.hostName.len); m_hostName = String((const char *)connectionManagerOptions.hostName.ptr, connectionManagerOptions.hostName.len); m_maxSize = connectionManagerOptions.maxConnections; diff --git a/tests/DateTimeTest.cpp b/tests/DateTimeTest.cpp index 3e4f7b3d6..0ea517527 100644 --- a/tests/DateTimeTest.cpp +++ b/tests/DateTimeTest.cpp @@ -42,7 +42,7 @@ static int s_TestDateTimeBinding(struct aws_allocator *allocator, void *ctx) uint8_t dateOutput[AWS_DATE_TIME_STR_MAX_LEN]; AWS_ZERO_ARRAY(dateOutput); - Aws::Crt::ByteBuf strOutput = Aws::Crt::ByteBufFromArray(dateOutput, sizeof(dateOutput)); + Aws::Crt::ByteBuf strOutput = Aws::Crt::ByteBufFromEmptyArray(dateOutput, sizeof(dateOutput)); ASSERT_TRUE(dateTime.ToGmtString(Aws::Crt::DateFormat::RFC822, strOutput)); const char *expectedLongStr = "Wed, 02 Oct 2002 08:05:09 GMT"; diff --git a/tests/HMACTest.cpp b/tests/HMACTest.cpp index c1ceb903e..d123a627e 100644 --- a/tests/HMACTest.cpp +++ b/tests/HMACTest.cpp @@ -37,8 +37,7 @@ static int s_TestSHA256HMACResourceSafety(struct aws_allocator *allocator, void Aws::Crt::ByteBuf expectedBuf = Aws::Crt::ByteBufFromArray(expected, sizeof(expected)); uint8_t output[Aws::Crt::Crypto::SHA256_HMAC_DIGEST_SIZE] = {0}; - Aws::Crt::ByteBuf outputBuf = Aws::Crt::ByteBufFromArray(output, sizeof(output)); - outputBuf.len = 0; + Aws::Crt::ByteBuf outputBuf = Aws::Crt::ByteBufFromEmptyArray(output, sizeof(output)); ASSERT_TRUE(sha256Hmac.Update(input)); ASSERT_TRUE(sha256Hmac.Digest(outputBuf)); diff --git a/tests/HashTest.cpp b/tests/HashTest.cpp index f45587c33..195657d69 100644 --- a/tests/HashTest.cpp +++ b/tests/HashTest.cpp @@ -30,8 +30,7 @@ static int s_TestSHA256ResourceSafety(struct aws_allocator *allocator, void *) Aws::Crt::ByteBuf expectedBuf = Aws::Crt::ByteBufFromArray(expected, sizeof(expected)); uint8_t output[Aws::Crt::Crypto::SHA256_DIGEST_SIZE] = {0}; - Aws::Crt::ByteBuf outputBuf = Aws::Crt::ByteBufFromArray(output, sizeof(output)); - outputBuf.len = 0; + Aws::Crt::ByteBuf outputBuf = Aws::Crt::ByteBufFromEmptyArray(output, sizeof(output)); ASSERT_TRUE(sha256.Update(input)); ASSERT_TRUE(sha256.Digest(outputBuf)); @@ -72,8 +71,7 @@ static int s_TestMD5ResourceSafety(struct aws_allocator *allocator, void *) Aws::Crt::ByteBuf expectedBuf = Aws::Crt::ByteBufFromArray(expected, sizeof(expected)); uint8_t output[Aws::Crt::Crypto::MD5_DIGEST_SIZE] = {0}; - Aws::Crt::ByteBuf outputBuf = Aws::Crt::ByteBufFromArray(output, sizeof(output)); - outputBuf.len = 0; + Aws::Crt::ByteBuf outputBuf = Aws::Crt::ByteBufFromEmptyArray(output, sizeof(output)); ASSERT_TRUE(md5.Update(input)); ASSERT_TRUE(md5.Digest(outputBuf)); diff --git a/tests/HttpClientTest.cpp b/tests/HttpClientTest.cpp index 41010089d..7d43d09ed 100644 --- a/tests/HttpClientTest.cpp +++ b/tests/HttpClientTest.cpp @@ -61,10 +61,8 @@ static int s_VerifyFilesAreTheSame(Allocator *allocator, const char *fileName1, uint8_t file2Digest[Crypto::SHA256_DIGEST_SIZE]; AWS_ZERO_ARRAY(file2Digest); - ByteBuf file1DigestBuf = ByteBufFromArray(file1Digest, sizeof(file1Digest)); - file1DigestBuf.len = 0; - ByteBuf file2DigestBuf = ByteBufFromArray(file2Digest, sizeof(file2Digest)); - file2DigestBuf.len = 0; + ByteBuf file1DigestBuf = ByteBufFromEmptyArray(file1Digest, sizeof(file1Digest)); + ByteBuf file2DigestBuf = ByteBufFromEmptyArray(file2Digest, sizeof(file2Digest)); ASSERT_TRUE(file1Hash.Digest(file1DigestBuf)); ASSERT_TRUE(file2Hash.Digest(file2DigestBuf));