From 764b839dec02343797c2df0b97a1ab8d984c1257 Mon Sep 17 00:00:00 2001 From: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com> Date: Wed, 17 Nov 2021 18:31:37 -0800 Subject: [PATCH] Make AZURE_ASSERT and related macros internal (#3059) --- sdk/core/azure-core/CHANGELOG.md | 2 + sdk/core/azure-core/CMakeLists.txt | 2 +- sdk/core/azure-core/inc/azure/core.hpp | 1 - .../inc/azure/core/azure_assert.hpp | 56 ------------------ .../azure-core/inc/azure/core/context.hpp | 4 +- .../inc/azure/core/cryptography/hash.hpp | 10 ++-- sdk/core/azure-core/inc/azure/core/etag.hpp | 7 ++- .../azure-core/inc/azure/core/http/http.hpp | 2 +- .../inc/azure/core/http/raw_response.hpp | 2 +- .../inc/azure/core/internal/azure_assert.hpp | 59 +++++++++++++++++++ .../inc/azure/core/io/body_stream.hpp | 10 ++-- .../azure-core/inc/azure/core/nullable.hpp | 8 +-- sdk/core/azure-core/src/azure_assert.cpp | 6 +- .../azure-core/src/cryptography/sha_hash.cpp | 2 +- sdk/core/azure-core/src/http/curl/curl.cpp | 4 +- sdk/core/azure-core/src/io/body_stream.cpp | 4 +- .../azure/storage/blobs/blob_responses.hpp | 2 +- .../azure-storage-blobs/src/blob_client.cpp | 4 +- .../src/blob_lease_client.cpp | 42 ++++++------- .../src/blob_responses.cpp | 2 +- .../azure-storage-common/src/crypt.cpp | 2 +- .../src/datalake_file_client.cpp | 4 +- .../src/datalake_responses.cpp | 2 +- .../storage/files/shares/share_responses.hpp | 2 +- .../src/share_file_client.cpp | 20 +++---- .../src/share_lease_client.cpp | 14 ++--- 26 files changed, 139 insertions(+), 134 deletions(-) delete mode 100644 sdk/core/azure-core/inc/azure/core/azure_assert.hpp create mode 100644 sdk/core/azure-core/inc/azure/core/internal/azure_assert.hpp diff --git a/sdk/core/azure-core/CHANGELOG.md b/sdk/core/azure-core/CHANGELOG.md index 1f24deaba..0925fa542 100644 --- a/sdk/core/azure-core/CHANGELOG.md +++ b/sdk/core/azure-core/CHANGELOG.md @@ -6,6 +6,8 @@ ### Breaking Changes +- `azure/core/azure_assert.hpp` header is moved to internal. `AzureNoReturnPath()` function is removed from global namespace. Associated macros, such as `AZURE_ASSERT` are renamed to indicate that they are internal. If your code was using the `AZURE_ASSERT` macro, consider using the standard library's `assert` as an alternative. + ### Bugs Fixed ### Other Changes diff --git a/sdk/core/azure-core/CMakeLists.txt b/sdk/core/azure-core/CMakeLists.txt index d02af5713..d69a6070a 100644 --- a/sdk/core/azure-core/CMakeLists.txt +++ b/sdk/core/azure-core/CMakeLists.txt @@ -65,6 +65,7 @@ set( inc/azure/core/http/raw_response.hpp inc/azure/core/http/policies/policy.hpp inc/azure/core/http/transport.hpp + inc/azure/core/internal/azure_assert.hpp inc/azure/core/internal/client_options.hpp inc/azure/core/internal/contract.hpp inc/azure/core/internal/cryptography/sha_hash.hpp @@ -75,7 +76,6 @@ set( inc/azure/core/internal/json/json.hpp inc/azure/core/internal/strings.hpp inc/azure/core/io/body_stream.hpp - inc/azure/core/azure_assert.hpp inc/azure/core/rtti.hpp inc/azure/core/base64.hpp inc/azure/core/case_insensitive_containers.hpp diff --git a/sdk/core/azure-core/inc/azure/core.hpp b/sdk/core/azure-core/inc/azure/core.hpp index 9f18d88a2..62395805c 100644 --- a/sdk/core/azure-core/inc/azure/core.hpp +++ b/sdk/core/azure-core/inc/azure/core.hpp @@ -9,7 +9,6 @@ #pragma once // azure/core -#include "azure/core/azure_assert.hpp" #include "azure/core/base64.hpp" #include "azure/core/case_insensitive_containers.hpp" #include "azure/core/context.hpp" diff --git a/sdk/core/azure-core/inc/azure/core/azure_assert.hpp b/sdk/core/azure-core/inc/azure/core/azure_assert.hpp deleted file mode 100644 index fcd9bf5e1..000000000 --- a/sdk/core/azure-core/inc/azure/core/azure_assert.hpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// SPDX-License-Identifier: MIT - -/** - * @file - * @brief Provide assert macros to use with pre-conditions. - * - * @remark Asserts are turned ON when `NDEBUG` is NOT defined (for Debug build). For Release build, - * `std::abort()` is directly called if the condition is false, without calling assert(). - * - */ - -#pragma once - -#include "platform.hpp" - -#include -#include - -#if defined(NDEBUG) - -/* - * NDEBUG = defined = Build is on Release - * Define AZURE_ASSERT to call abort directly on exp == false - */ - -#define AZURE_ASSERT(exp) \ - do \ - { \ - if (!(exp)) \ - { \ - std::abort(); \ - } \ - } while (0) - -#define AZURE_ASSERT_MSG(exp, msg) AZURE_ASSERT(exp) - -#else - -/* - * NDEBUG = NOT defined = Build is on Debug - * Define AZURE_ASSERT to call assert to provide better debug experience. - */ - -#include - -#define AZURE_ASSERT(exp) assert((exp)) -#define AZURE_ASSERT_MSG(exp, msg) assert(((void)msg, (exp))) - -#endif - -[[noreturn]] void AzureNoReturnPath(std::string const& msg); - -#define AZURE_ASSERT_FALSE(exp) AZURE_ASSERT(!(exp)) -#define AZURE_UNREACHABLE_CODE() AzureNoReturnPath("unreachable code!") -#define AZURE_NOT_IMPLEMENTED() AzureNoReturnPath("not implemented code!") diff --git a/sdk/core/azure-core/inc/azure/core/context.hpp b/sdk/core/azure-core/inc/azure/core/context.hpp index bc1ceb0f2..a8da7f6f8 100644 --- a/sdk/core/azure-core/inc/azure/core/context.hpp +++ b/sdk/core/azure-core/inc/azure/core/context.hpp @@ -8,9 +8,9 @@ #pragma once -#include "azure/core/azure_assert.hpp" #include "azure/core/datetime.hpp" #include "azure/core/dll_import_export.hpp" +#include "azure/core/internal/azure_assert.hpp" #include "azure/core/rtti.hpp" #include @@ -210,7 +210,7 @@ namespace Azure { namespace Core { if (ptr->Key == key) { #if defined(AZ_CORE_RTTI) - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( typeid(T) == ptr->ValueType, "Type mismatch for Context::TryGetValue()."); #endif diff --git a/sdk/core/azure-core/inc/azure/core/cryptography/hash.hpp b/sdk/core/azure-core/inc/azure/core/cryptography/hash.hpp index 9ef494cab..e3f61e721 100644 --- a/sdk/core/azure-core/inc/azure/core/cryptography/hash.hpp +++ b/sdk/core/azure-core/inc/azure/core/cryptography/hash.hpp @@ -9,7 +9,7 @@ #pragma once -#include "azure/core/azure_assert.hpp" +#include "azure/core/internal/azure_assert.hpp" #include #include @@ -64,8 +64,8 @@ namespace Azure { namespace Core { namespace Cryptography { */ void Append(const uint8_t* data, size_t length) { - AZURE_ASSERT(data || length == 0); - AZURE_ASSERT_MSG(!m_isDone, "Cannot call Append after calling Final()."); + _azure_ASSERT(data || length == 0); + _azure_ASSERT_MSG(!m_isDone, "Cannot call Append after calling Final()."); OnAppend(data, length); } @@ -80,8 +80,8 @@ namespace Azure { namespace Core { namespace Cryptography { */ std::vector Final(const uint8_t* data, size_t length) { - AZURE_ASSERT(data || length == 0); - AZURE_ASSERT_MSG(!m_isDone, "Cannot call Final() multiple times."); + _azure_ASSERT(data || length == 0); + _azure_ASSERT_MSG(!m_isDone, "Cannot call Final() multiple times."); m_isDone = true; return OnFinal(data, length); } diff --git a/sdk/core/azure-core/inc/azure/core/etag.hpp b/sdk/core/azure-core/inc/azure/core/etag.hpp index e3aabf1df..a963dadbd 100644 --- a/sdk/core/azure-core/inc/azure/core/etag.hpp +++ b/sdk/core/azure-core/inc/azure/core/etag.hpp @@ -8,7 +8,7 @@ #pragma once -#include "azure/core/azure_assert.hpp" +#include "azure/core/internal/azure_assert.hpp" #include "azure/core/nullable.hpp" #include @@ -113,7 +113,7 @@ public: break; } // Unknown comparison - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } /** @@ -140,7 +140,8 @@ public: */ const std::string& ToString() const { - AZURE_ASSERT_MSG(m_value.HasValue(), "Empty ETag, check HasValue() before calling ToString()."); + _azure_ASSERT_MSG( + m_value.HasValue(), "Empty ETag, check HasValue() before calling ToString()."); return m_value.Value(); } diff --git a/sdk/core/azure-core/inc/azure/core/http/http.hpp b/sdk/core/azure-core/inc/azure/core/http/http.hpp index d4aa0ce17..478f2a251 100644 --- a/sdk/core/azure-core/inc/azure/core/http/http.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/http.hpp @@ -227,7 +227,7 @@ namespace Azure { namespace Core { namespace Http { : m_method(std::move(httpMethod)), m_url(std::move(url)), m_bodyStream(bodyStream), m_retryModeEnabled(false), m_shouldBufferResponse(shouldBufferResponse) { - AZURE_ASSERT_MSG(bodyStream, "The bodyStream pointer cannot be null."); + _azure_ASSERT_MSG(bodyStream, "The bodyStream pointer cannot be null."); } public: diff --git a/sdk/core/azure-core/inc/azure/core/http/raw_response.hpp b/sdk/core/azure-core/inc/azure/core/http/raw_response.hpp index c93c19124..289864a79 100644 --- a/sdk/core/azure-core/inc/azure/core/http/raw_response.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/raw_response.hpp @@ -76,7 +76,7 @@ namespace Azure { namespace Core { namespace Http { response.m_statusCode, response.m_reasonPhrase) { - AZURE_ASSERT(m_bodyStream == nullptr); + _azure_ASSERT(m_bodyStream == nullptr); // Copy body m_body = response.GetBody(); } diff --git a/sdk/core/azure-core/inc/azure/core/internal/azure_assert.hpp b/sdk/core/azure-core/inc/azure/core/internal/azure_assert.hpp new file mode 100644 index 000000000..d0956177c --- /dev/null +++ b/sdk/core/azure-core/inc/azure/core/internal/azure_assert.hpp @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// SPDX-License-Identifier: MIT + +/** + * @file + * @brief Provide assert macros to use with pre-conditions. + * + * @remark Asserts are turned ON when `NDEBUG` is NOT defined (for Debug build). For Release build, + * `std::abort()` is directly called if the condition is false, without calling assert(). + * + */ + +#pragma once + +#include "azure/core/platform.hpp" + +#include +#include + +#if defined(NDEBUG) + +/* + * NDEBUG = defined = Build is on Release + * Define _azure_ASSERT to call abort directly on exp == false + */ + +#define _azure_ASSERT(exp) \ + do \ + { \ + if (!(exp)) \ + { \ + std::abort(); \ + } \ + } while (0) + +#define _azure_ASSERT_MSG(exp, msg) _azure_ASSERT(exp) + +#else + +/* + * NDEBUG = NOT defined = Build is on Debug + * Define _azure_ASSERT to call assert to provide better debug experience. + */ + +#include + +#define _azure_ASSERT(exp) assert((exp)) +#define _azure_ASSERT_MSG(exp, msg) assert(((void)msg, (exp))) + +#endif + +namespace Azure { namespace Core { namespace _internal { + [[noreturn]] void AzureNoReturnPath(std::string const& msg); +}}} // namespace Azure::Core::_internal + +#define _azure_ASSERT_FALSE(exp) _azure_ASSERT(!(exp)) +#define _azure_UNREACHABLE_CODE() ::Azure::Core::_internal::AzureNoReturnPath("unreachable code!") +#define _azure_NOT_IMPLEMENTED() \ + ::Azure::Core::_internal::AzureNoReturnPath("not implemented code!") diff --git a/sdk/core/azure-core/inc/azure/core/io/body_stream.hpp b/sdk/core/azure-core/inc/azure/core/io/body_stream.hpp index d805ab203..07401fecb 100644 --- a/sdk/core/azure-core/inc/azure/core/io/body_stream.hpp +++ b/sdk/core/azure-core/inc/azure/core/io/body_stream.hpp @@ -64,7 +64,7 @@ namespace Azure { namespace Core { namespace IO { */ virtual void Rewind() { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( false, "The specified BodyStream doesn't support Rewind which is required to guarantee fault " "tolerance when retrying any operation. Consider creating a MemoryBodyStream or " @@ -86,7 +86,7 @@ namespace Azure { namespace Core { namespace IO { size_t count, Azure::Core::Context const& context = Azure::Core::Context()) { - AZURE_ASSERT(buffer || count == 0); + _azure_ASSERT(buffer || count == 0); context.ThrowIfCancelled(); return OnRead(buffer, count, context); @@ -152,7 +152,7 @@ namespace Azure { namespace Core { namespace IO { */ explicit MemoryBodyStream(const uint8_t* data, size_t length) : m_data(data), m_length(length) { - AZURE_ASSERT(data || length == 0); + _azure_ASSERT(data || length == 0); } int64_t Length() const override { return this->m_length; } @@ -199,7 +199,7 @@ namespace Azure { namespace Core { namespace IO { RandomAccessFileBodyStream(int fileDescriptor, int64_t offset, int64_t length) : m_fileDescriptor(fileDescriptor), m_baseOffset(offset), m_length(length), m_offset(0) { - AZURE_ASSERT(fileDescriptor >= 0 && offset >= 0 && length >= 0); + _azure_ASSERT(fileDescriptor >= 0 && offset >= 0 && length >= 0); } RandomAccessFileBodyStream() : m_fileDescriptor(0), m_baseOffset(0), m_length(0), m_offset(0) @@ -224,7 +224,7 @@ namespace Azure { namespace Core { namespace IO { RandomAccessFileBodyStream(void* fileHandle, int64_t offset, int64_t length) : m_filehandle(fileHandle), m_baseOffset(offset), m_length(length), m_offset(0) { - AZURE_ASSERT(fileHandle && offset >= 0 && length >= 0); + _azure_ASSERT(fileHandle && offset >= 0 && length >= 0); } RandomAccessFileBodyStream() : m_filehandle(NULL), m_baseOffset(0), m_length(0), m_offset(0) diff --git a/sdk/core/azure-core/inc/azure/core/nullable.hpp b/sdk/core/azure-core/inc/azure/core/nullable.hpp index 80d09acdf..f3039af29 100644 --- a/sdk/core/azure-core/inc/azure/core/nullable.hpp +++ b/sdk/core/azure-core/inc/azure/core/nullable.hpp @@ -8,7 +8,7 @@ #pragma once -#include +#include "azure/core/internal/azure_assert.hpp" #include // for placement new #include @@ -234,7 +234,7 @@ public: */ const T& Value() const& noexcept { - AZURE_ASSERT_MSG(m_hasValue, "Empty Nullable, check HasValue() first."); + _azure_ASSERT_MSG(m_hasValue, "Empty Nullable, check HasValue() first."); return m_value; } @@ -245,7 +245,7 @@ public: */ T& Value() & noexcept { - AZURE_ASSERT_MSG(m_hasValue, "Empty Nullable, check HasValue() first."); + _azure_ASSERT_MSG(m_hasValue, "Empty Nullable, check HasValue() first."); return m_value; } @@ -256,7 +256,7 @@ public: */ T&& Value() && noexcept { - AZURE_ASSERT_MSG(m_hasValue, "Empty Nullable, check HasValue() first."); + _azure_ASSERT_MSG(m_hasValue, "Empty Nullable, check HasValue() first."); return std::move(m_value); } diff --git a/sdk/core/azure-core/src/azure_assert.cpp b/sdk/core/azure-core/src/azure_assert.cpp index dae8a82dc..6a5c21ad8 100644 --- a/sdk/core/azure-core/src/azure_assert.cpp +++ b/sdk/core/azure-core/src/azure_assert.cpp @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#include "azure/core/azure_assert.hpp" +#include "azure/core/internal/azure_assert.hpp" -[[noreturn]] void AzureNoReturnPath(std::string const& msg) +[[noreturn]] void Azure::Core::_internal::AzureNoReturnPath(std::string const& msg) { // void msg for Release build where Assert is ignored (void)msg; - AZURE_ASSERT_MSG(false, msg); + _azure_ASSERT_MSG(false, msg); std::abort(); } diff --git a/sdk/core/azure-core/src/cryptography/sha_hash.cpp b/sdk/core/azure-core/src/cryptography/sha_hash.cpp index 3ef52b4fb..a5018ee3c 100644 --- a/sdk/core/azure-core/src/cryptography/sha_hash.cpp +++ b/sdk/core/azure-core/src/cryptography/sha_hash.cpp @@ -88,7 +88,7 @@ public: } default: // imposible to get here - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index badf471d1..06ff40eab 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -1026,7 +1026,7 @@ size_t CurlSession::ResponseBufferParser::Parse( { // Should never happen that parser is not statusLIne or Headers and we still try // to parse more. - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } // clean internal buffer this->m_internalBuffer.clear(); @@ -1064,7 +1064,7 @@ size_t CurlSession::ResponseBufferParser::Parse( { // Should never happen that parser is not statusLIne or Headers and we still try // to parse more. - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } } diff --git a/sdk/core/azure-core/src/io/body_stream.cpp b/sdk/core/azure-core/src/io/body_stream.cpp index 2c2e03667..b8ed73934 100644 --- a/sdk/core/azure-core/src/io/body_stream.cpp +++ b/sdk/core/azure-core/src/io/body_stream.cpp @@ -43,7 +43,7 @@ static_assert(sizeof(void*) >= sizeof(HANDLE), "We must be able to cast HANDLE t // Keep reading until buffer is all fill out of the end of stream content is reached size_t BodyStream::ReadToCount(uint8_t* buffer, size_t count, Context const& context) { - AZURE_ASSERT(buffer || count == 0); + _azure_ASSERT(buffer || count == 0); size_t totalRead = 0; @@ -92,7 +92,7 @@ size_t MemoryBodyStream::OnRead(uint8_t* buffer, size_t count, Context const& co FileBodyStream::FileBodyStream(const std::string& filename) { - AZURE_ASSERT_MSG(filename.size() > 0, "The file name must not be an empty string."); + _azure_ASSERT_MSG(filename.size() > 0, "The file name must not be an empty string."); #if defined(AZ_PLATFORM_WINDOWS) HANDLE fileHandle = INVALID_HANDLE_VALUE; diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp index 00bcc02c6..60b0d8c24 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_responses.hpp @@ -187,7 +187,7 @@ namespace Azure { namespace Storage { ~StartBlobCopyOperation() override {} private: - std::string GetResumeToken() const override { AZURE_NOT_IMPLEMENTED(); } + std::string GetResumeToken() const override { _azure_NOT_IMPLEMENTED(); } std::unique_ptr PollInternal( const Azure::Core::Context& context) override; diff --git a/sdk/storage/azure-storage-blobs/src/blob_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_client.cpp index 8b1756dfc..7cd30b467 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_client.cpp @@ -3,8 +3,8 @@ #include "azure/storage/blobs/blob_client.hpp" -#include #include +#include #include #include #include @@ -554,7 +554,7 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.SourceIfNoneMatch = options.SourceAccessConditions.IfNoneMatch; if (options.TransactionalContentHash.HasValue()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.TransactionalContentHash.Value().Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 transactional content hash."); protocolLayerOptions.TransactionalContentHash = options.TransactionalContentHash; diff --git a/sdk/storage/azure-storage-blobs/src/blob_lease_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_lease_client.cpp index c0a9512a7..ed52c1b9c 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_lease_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_lease_client.cpp @@ -3,7 +3,7 @@ #include "azure/storage/blobs/blob_lease_client.hpp" -#include +#include #include namespace Azure { namespace Storage { namespace Blobs { @@ -53,13 +53,13 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince; protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince; - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), "Blob container lease doesn't support If-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), "Blob container lease doesn't support If-None-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), "Blob container lease doesn't support tag condition."); @@ -79,7 +79,7 @@ namespace Azure { namespace Storage { namespace Blobs { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } @@ -118,13 +118,13 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince; protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince; - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), "Blob container lease doesn't support If-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), "Blob container lease doesn't support If-None-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), "Blob container lease doesn't support tag condition."); @@ -144,7 +144,7 @@ namespace Azure { namespace Storage { namespace Blobs { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } @@ -182,13 +182,13 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince; protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince; - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), "Blob container lease doesn't support If-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), "Blob container lease doesn't support If-None-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), "Blob container lease doesn't support tag condition."); @@ -207,7 +207,7 @@ namespace Azure { namespace Storage { namespace Blobs { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } @@ -254,13 +254,13 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince; protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince; - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), "Blob container lease doesn't support If-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), "Blob container lease doesn't support If-None-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), "Blob container lease doesn't support tag condition."); @@ -285,7 +285,7 @@ namespace Azure { namespace Storage { namespace Blobs { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } @@ -323,13 +323,13 @@ namespace Azure { namespace Storage { namespace Blobs { protocolLayerOptions.IfModifiedSince = options.AccessConditions.IfModifiedSince; protocolLayerOptions.IfUnmodifiedSince = options.AccessConditions.IfUnmodifiedSince; - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfMatch.HasValue(), "Blob container lease doesn't support If-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.IfNoneMatch.HasValue(), "Blob container lease doesn't support If-None-Match condition."); - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !options.AccessConditions.TagConditions.HasValue(), "Blob container lease doesn't support tag condition."); @@ -348,7 +348,7 @@ namespace Azure { namespace Storage { namespace Blobs { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } }}} // namespace Azure::Storage::Blobs diff --git a/sdk/storage/azure-storage-blobs/src/blob_responses.cpp b/sdk/storage/azure-storage-blobs/src/blob_responses.cpp index 7a52c5fe9..7a91d4637 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_responses.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_responses.cpp @@ -103,7 +103,7 @@ namespace Azure { namespace Storage { namespace Blobs { *this = m_pageBlobClient->GetManagedDiskPageRangesDiff( m_previousSnapshotUrl.Value(), m_operationOptions, context); } - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } }}} // namespace Azure::Storage::Blobs diff --git a/sdk/storage/azure-storage-common/src/crypt.cpp b/sdk/storage/azure-storage-common/src/crypt.cpp index 89d24dd08..25d7dd409 100644 --- a/sdk/storage/azure-storage-common/src/crypt.cpp +++ b/sdk/storage/azure-storage-common/src/crypt.cpp @@ -152,7 +152,7 @@ namespace Azure { namespace Storage { const std::vector& data, const std::vector& key) { - AZURE_ASSERT_MSG(data.size() <= std::numeric_limits::max(), "Data size is too big."); + _azure_ASSERT_MSG(data.size() <= std::numeric_limits::max(), "Data size is too big."); static AlgorithmProviderInstance AlgorithmProvider(AlgorithmType::HmacSha256); diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp index 3f632b0e3..200f3ffa8 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_file_client.cpp @@ -159,7 +159,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { protocolLayerOptions.ContentLength = 0; if (options.ContentHash.HasValue()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.ContentHash.Value().Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); } @@ -377,7 +377,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { { Blobs::_detail::BlobRestClient::Blob::SetBlobExpiryOptions protocolLayerOptions; protocolLayerOptions.ExpiryOrigin = expiryOrigin; - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( !(options.ExpiresOn.HasValue() && options.TimeToExpire.HasValue()), "ExpiresOn and TimeToExpire are mutually exclusive."); diff --git a/sdk/storage/azure-storage-files-datalake/src/datalake_responses.cpp b/sdk/storage/azure-storage-files-datalake/src/datalake_responses.cpp index 5e6814140..2c524a0cd 100644 --- a/sdk/storage/azure-storage-files-datalake/src/datalake_responses.cpp +++ b/sdk/storage/azure-storage-files-datalake/src/datalake_responses.cpp @@ -111,7 +111,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { *this = m_dataLakePathClient->RemoveAccessControlListRecursive( m_acls, m_operationOptions, context); } - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } }}}} // namespace Azure::Storage::Files::DataLake diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp index 2f8ceb358..839bd2ed8 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_responses.hpp @@ -226,7 +226,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { ~StartFileCopyOperation() override {} private: - std::string GetResumeToken() const override { AZURE_NOT_IMPLEMENTED(); } + std::string GetResumeToken() const override { _azure_NOT_IMPLEMENTED(); } std::unique_ptr PollInternal( const Azure::Core::Context& context) override; diff --git a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp index 8e07c002e..944eb4e31 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_file_client.cpp @@ -166,7 +166,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } if (!options.HttpHeaders.ContentHash.Value.empty()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; @@ -240,7 +240,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } if (options.RangeHashAlgorithm.HasValue()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.RangeHashAlgorithm.Value() == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); if (options.RangeHashAlgorithm.Value() == HashAlgorithm::Md5) @@ -350,7 +350,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - AZURE_ASSERT_MSG(false, "Either FilePermission or FilePermissionKey must be set."); + _azure_ASSERT_MSG(false, "Either FilePermission or FilePermissionKey must be set."); } } } @@ -487,7 +487,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { + std::string("-") + std::to_string(offset + content.Length() - 1); if (options.TransactionalContentHash.HasValue()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.TransactionalContentHash.Value().Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); } @@ -940,7 +940,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } if (!options.HttpHeaders.ContentHash.Value.empty()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; @@ -1044,7 +1044,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } if (!options.HttpHeaders.ContentHash.Value.empty()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.HttpHeaders.ContentHash.Algorithm == HashAlgorithm::Md5, "This operation only supports MD5 content hash."); protocolLayerOptions.ContentMd5 = options.HttpHeaders.ContentHash; @@ -1088,7 +1088,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { const UploadFileRangeFromUriOptions& options, const Azure::Core::Context& context) const { - AZURE_ASSERT_MSG(sourceRange.Length.HasValue(), "Source length cannot be null."); + _azure_ASSERT_MSG(sourceRange.Length.HasValue(), "Source length cannot be null."); int64_t rangeLength = sourceRange.Length.Value(); auto protocolLayerOptions = _detail::ShareRestClient::File::UploadRangeFromUrlOptions(); @@ -1099,14 +1099,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { protocolLayerOptions.LeaseIdOptional = options.AccessConditions.LeaseId; if (options.TransactionalContentHash.HasValue()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.TransactionalContentHash.Value().Algorithm == HashAlgorithm::Crc64, "This operation only supports CRC64 content hash."); } protocolLayerOptions.SourceContentCrc64 = options.TransactionalContentHash; if (options.SourceAccessCondition.IfMatchContentHash.HasValue()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.SourceAccessCondition.IfMatchContentHash.Value().Algorithm == HashAlgorithm::Crc64, "This operation only supports CRC64 Source-If-Match condition."); @@ -1114,7 +1114,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { protocolLayerOptions.SourceIfMatchCrc64 = options.SourceAccessCondition.IfMatchContentHash; if (options.SourceAccessCondition.IfNoneMatchContentHash.HasValue()) { - AZURE_ASSERT_MSG( + _azure_ASSERT_MSG( options.SourceAccessCondition.IfNoneMatchContentHash.Value().Algorithm == HashAlgorithm::Crc64, "This operation only supports CRC64 Source-If-None-Match condition."); diff --git a/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp b/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp index 3863c5793..c356b191b 100644 --- a/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp +++ b/sdk/storage/azure-storage-files-shares/src/share_lease_client.cpp @@ -62,7 +62,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } @@ -73,8 +73,8 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { (void)options; if (m_fileClient.HasValue()) { - AZURE_ASSERT_MSG(false, "Share lease doesn't support renew"); - AZURE_NOT_IMPLEMENTED(); + _azure_ASSERT_MSG(false, "Share lease doesn't support renew"); + _azure_NOT_IMPLEMENTED(); } else if (m_shareClient.HasValue()) { @@ -97,7 +97,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } @@ -144,7 +144,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } @@ -206,7 +206,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } @@ -251,7 +251,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } else { - AZURE_UNREACHABLE_CODE(); + _azure_UNREACHABLE_CODE(); } } }}}} // namespace Azure::Storage::Files::Shares