diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_client.hpp index 2f4ed153b..467acd9de 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/blob_client.hpp @@ -260,7 +260,7 @@ namespace Azure { namespace Storage { namespace Blobs { */ Azure::Response DownloadTo( uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const DownloadBlobToOptions& options = DownloadBlobToOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/block_blob_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/block_blob_client.hpp index bffc07800..5a5cb8b92 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/block_blob_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/block_blob_client.hpp @@ -139,7 +139,7 @@ namespace Azure { namespace Storage { namespace Blobs { */ Azure::Response UploadFrom( const uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const UploadBlockBlobFromOptions& options = UploadBlockBlobFromOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; diff --git a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp index 9d19c5526..951f70a08 100644 --- a/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp +++ b/sdk/storage/azure-storage-blobs/inc/azure/storage/blobs/protocol/blob_rest_client.hpp @@ -2726,7 +2726,7 @@ namespace Azure { namespace Storage { namespace Blobs { "deleted", }; std::string ret; - for (std::size_t i = 0; i < sizeof(value_list) / sizeof(ListBlobContainersIncludeFlags); ++i) + for (size_t i = 0; i < sizeof(value_list) / sizeof(ListBlobContainersIncludeFlags); ++i) { if ((val & value_list[i]) == value_list[i]) { @@ -2759,7 +2759,7 @@ namespace Azure { namespace Storage { namespace Blobs { "uncommittedblobs", }; std::string ret; - for (std::size_t i = 0; i < sizeof(value_list) / sizeof(ListBlobsIncludeFlags); ++i) + for (size_t i = 0; i < sizeof(value_list) / sizeof(ListBlobsIncludeFlags); ++i) { if ((val & value_list[i]) == value_list[i]) { diff --git a/sdk/storage/azure-storage-blobs/sample/blob_getting_started.cpp b/sdk/storage/azure-storage-blobs/sample/blob_getting_started.cpp index 341acb9aa..3addddbbc 100644 --- a/sdk/storage/azure-storage-blobs/sample/blob_getting_started.cpp +++ b/sdk/storage/azure-storage-blobs/sample/blob_getting_started.cpp @@ -33,7 +33,7 @@ void BlobsGettingStarted() { std::cout << metadata.first << ":" << metadata.second << std::endl; } - blobContent.resize(static_cast(properties.BlobSize)); + blobContent.resize(static_cast(properties.BlobSize)); blobClient.DownloadTo(reinterpret_cast(&blobContent[0]), blobContent.size()); diff --git a/sdk/storage/azure-storage-blobs/src/blob_client.cpp b/sdk/storage/azure-storage-blobs/src/blob_client.cpp index 334e33e0a..5e0cb408c 100644 --- a/sdk/storage/azure-storage-blobs/src/blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/blob_client.cpp @@ -218,7 +218,7 @@ namespace Azure { namespace Storage { namespace Blobs { Azure::Response BlobClient::DownloadTo( uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const DownloadBlobToOptions& options, const Azure::Core::Context& context) const { @@ -258,7 +258,7 @@ namespace Azure { namespace Storage { namespace Blobs { } firstChunkLength = std::min(firstChunkLength, blobRangeSize); - if (static_cast(blobRangeSize) > bufferSize) + if (static_cast(blobRangeSize) > bufferSize) { throw Azure::Core::RequestFailedException( "buffer is not big enough, blob range size is " + std::to_string(blobRangeSize)); @@ -372,15 +372,14 @@ namespace Azure { namespace Storage { namespace Blobs { auto bodyStreamToFile = [](Azure::Core::IO::BodyStream& stream, _internal::FileWriter& fileWriter, int64_t offset, - int64_t length, + size_t length, const Azure::Core::Context& context) { - constexpr std::size_t bufferSize = 4 * 1024 * 1024; + constexpr size_t bufferSize = 4 * 1024 * 1024; std::vector buffer(bufferSize); while (length > 0) { - int64_t readSize = std::min(static_cast(bufferSize), length); - int64_t bytesRead - = stream.ReadToCount(buffer.data(), static_cast(readSize), context); + size_t readSize = std::min(bufferSize, length); + size_t bytesRead = stream.ReadToCount(buffer.data(), readSize, context); if (bytesRead != readSize) { throw Azure::Core::RequestFailedException("error when reading body stream"); @@ -391,7 +390,12 @@ namespace Azure { namespace Storage { namespace Blobs { } }; - bodyStreamToFile(*(firstChunk.Value.BodyStream), fileWriter, 0, firstChunkLength, context); + bodyStreamToFile( + *(firstChunk.Value.BodyStream), + fileWriter, + 0, + static_cast(firstChunkLength), + context); firstChunk.Value.BodyStream.reset(); auto returnTypeConverter = [](Azure::Response& response) { @@ -422,7 +426,7 @@ namespace Azure { namespace Storage { namespace Blobs { *(chunk.Value.BodyStream), fileWriter, offset - firstChunkOffset, - chunkOptions.Range.Value().Length.Value(), + static_cast(chunkOptions.Range.Value().Length.Value()), context); if (chunkId == numChunks - 1) diff --git a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp index c66e91d53..dda11e03f 100644 --- a/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp +++ b/sdk/storage/azure-storage-blobs/src/block_blob_client.cpp @@ -118,7 +118,7 @@ namespace Azure { namespace Storage { namespace Blobs { Azure::Response BlockBlobClient::UploadFrom( const uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const UploadBlockBlobFromOptions& options, const Azure::Core::Context& context) const { @@ -127,7 +127,7 @@ namespace Azure { namespace Storage { namespace Blobs { constexpr int64_t MaxBlockNumber = 50000; constexpr int64_t BlockGrainSize = 1 * 1024 * 1024; - if (bufferSize <= static_cast(options.TransferOptions.SingleUploadThreshold)) + if (bufferSize <= static_cast(options.TransferOptions.SingleUploadThreshold)) { Azure::Core::IO::MemoryBodyStream contentStream(buffer, bufferSize); UploadBlockBlobOptions uploadBlockBlobOptions; @@ -155,7 +155,7 @@ namespace Azure { namespace Storage { namespace Blobs { std::vector blockIds; auto getBlockId = [](int64_t id) { - constexpr std::size_t BlockIdLength = 64; + constexpr size_t BlockIdLength = 64; std::string blockId = std::to_string(id); blockId = std::string(BlockIdLength - blockId.length(), '0') + blockId; return Azure::Core::Convert::Base64Encode( @@ -170,14 +170,14 @@ namespace Azure { namespace Storage { namespace Blobs { auto blockInfo = StageBlock(getBlockId(chunkId), contentStream, chunkOptions, context); if (chunkId == numChunks - 1) { - blockIds.resize(static_cast(numChunks)); + blockIds.resize(static_cast(numChunks)); } }; _internal::ConcurrentTransfer( 0, bufferSize, chunkSize, options.TransferOptions.Concurrency, uploadBlockFunc); - for (std::size_t i = 0; i < blockIds.size(); ++i) + for (size_t i = 0; i < blockIds.size(); ++i) { blockIds[i] = getBlockId(static_cast(i)); } @@ -223,7 +223,7 @@ namespace Azure { namespace Storage { namespace Blobs { std::vector blockIds; auto getBlockId = [](int64_t id) { - constexpr std::size_t BlockIdLength = 64; + constexpr size_t BlockIdLength = 64; std::string blockId = std::to_string(id); blockId = std::string(BlockIdLength - blockId.length(), '0') + blockId; return Azure::Core::Convert::Base64Encode( @@ -239,7 +239,7 @@ namespace Azure { namespace Storage { namespace Blobs { auto blockInfo = StageBlock(getBlockId(chunkId), contentStream, chunkOptions, context); if (chunkId == numChunks - 1) { - blockIds.resize(static_cast(numChunks)); + blockIds.resize(static_cast(numChunks)); } }; @@ -266,7 +266,7 @@ namespace Azure { namespace Storage { namespace Blobs { options.TransferOptions.Concurrency, uploadBlockFunc); - for (std::size_t i = 0; i < blockIds.size(); ++i) + for (size_t i = 0; i < blockIds.size(); ++i) { blockIds[i] = getBlockId(static_cast(i)); } diff --git a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp index cbeb96a07..46edba1a8 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/block_blob_client_test.cpp @@ -40,7 +40,7 @@ namespace Azure { namespace Storage { namespace Test { StandardStorageConnectionString(), m_containerName, m_blobName); m_blockBlobClient = std::make_shared(std::move(blockBlobClient)); - m_blobContent.resize(static_cast(8_MB)); + m_blobContent.resize(static_cast(8_MB)); RandomBuffer(reinterpret_cast(&m_blobContent[0]), m_blobContent.size()); m_blobUploadOptions.Metadata = {{"key1", "V1"}, {"key2", "Value2"}}; m_blobUploadOptions.HttpHeaders.ContentType = "application/x-binary"; @@ -99,9 +99,9 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ( ReadBodyStream(res.Value.BodyStream), std::vector( - m_blobContent.begin() + static_cast(options.Range.Value().Offset), + m_blobContent.begin() + static_cast(options.Range.Value().Offset), m_blobContent.begin() - + static_cast( + + static_cast( options.Range.Value().Offset + options.Range.Value().Length.Value()))); EXPECT_EQ(res.Value.ContentRange.Offset, options.Range.Value().Offset); EXPECT_EQ(res.Value.ContentRange.Length.Value(), options.Range.Value().Length.Value()); @@ -459,7 +459,7 @@ namespace Azure { namespace Storage { namespace Test { expectedData.clear(); } } - downloadBuffer.resize(static_cast(downloadSize), '\x00'); + downloadBuffer.resize(static_cast(downloadSize), '\x00'); Blobs::DownloadBlobToOptions options; options.TransferOptions.Concurrency = concurrency; if (offset.HasValue() || length.HasValue()) @@ -483,7 +483,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(res.Value.BlobSize, blobSize); EXPECT_EQ(res.Value.ContentRange.Length.Value(), actualDownloadSize); EXPECT_EQ(res.Value.ContentRange.Offset, offset.HasValue() ? offset.Value() : 0); - downloadBuffer.resize(static_cast(res.Value.ContentRange.Length.Value())); + downloadBuffer.resize(static_cast(res.Value.ContentRange.Length.Value())); EXPECT_EQ(downloadBuffer, expectedData); } else @@ -626,11 +626,11 @@ namespace Azure { namespace Storage { namespace Test { for (int64_t length : {1ULL, 2ULL, 4_KB, 5_KB, 8_KB, 11_KB, 20_KB}) { std::vector downloadBuffer; - downloadBuffer.resize(static_cast(length - 1)); + downloadBuffer.resize(static_cast(length - 1)); options.Range.Value().Length = length; EXPECT_THROW( m_blockBlobClient->DownloadTo( - downloadBuffer.data(), static_cast(length - 1), options), + downloadBuffer.data(), static_cast(length - 1), options), std::runtime_error); } @@ -726,7 +726,7 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_TRUE(ReadFile(tempFilename).empty()); DeleteFile(tempFilename); - res = blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB)); + res = blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB)); EXPECT_EQ(res.Value.BlobSize, 0); EXPECT_EQ(res.Value.ContentRange.Length.Value(), 0); EXPECT_TRUE(res.Value.Details.ETag.HasValue()); @@ -752,8 +752,7 @@ namespace Azure { namespace Storage { namespace Test { options.TransferOptions.ChunkSize = 10; options.TransferOptions.Concurrency = c; - res = blockBlobClient.DownloadTo( - emptyContent.data(), static_cast(8_MB), options); + res = blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options); EXPECT_EQ(res.Value.BlobSize, 0); EXPECT_EQ(res.Value.ContentRange.Length.Value(), 0); EXPECT_TRUE(res.Value.Details.ETag.HasValue()); @@ -775,27 +774,27 @@ namespace Azure { namespace Storage { namespace Test { options.Range = Core::Http::HttpRange(); options.Range.Value().Offset = 0; EXPECT_THROW( - blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options), + blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options), StorageException); EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageException); options.Range.Value().Offset = 1; EXPECT_THROW( - blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options), + blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options), StorageException); EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageException); options.Range.Value().Offset = 0; options.Range.Value().Length = 1; EXPECT_THROW( - blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options), + blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options), StorageException); EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageException); options.Range.Value().Offset = 100; options.Range.Value().Length = 100; EXPECT_THROW( - blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options), + blockBlobClient.DownloadTo(emptyContent.data(), static_cast(8_MB), options), StorageException); EXPECT_THROW(blockBlobClient.DownloadTo(tempFilename, options), StorageException); DeleteFile(tempFilename); @@ -804,7 +803,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(BlockBlobClientTest, ConcurrentUpload) { - std::vector blobContent = RandomBuffer(static_cast(8_MB)); + std::vector blobContent = RandomBuffer(static_cast(8_MB)); auto testUploadFromBuffer = [&](int concurrency, int64_t blobSize) { auto blockBlobClient = m_blobContainerClient->GetBlockBlobClient(RandomString()); @@ -816,8 +815,8 @@ namespace Azure { namespace Storage { namespace Test { options.HttpHeaders.ContentHash.Value.clear(); options.Metadata = m_blobUploadOptions.Metadata; options.AccessTier = m_blobUploadOptions.AccessTier; - auto res = blockBlobClient.UploadFrom( - blobContent.data(), static_cast(blobSize), options); + auto res + = blockBlobClient.UploadFrom(blobContent.data(), static_cast(blobSize), options); EXPECT_TRUE(res.Value.ETag.HasValue()); EXPECT_TRUE(IsValidTime(res.Value.LastModified)); auto properties = blockBlobClient.GetProperties().Value; @@ -828,12 +827,12 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(properties.AccessTier.Value(), options.AccessTier.Value()); EXPECT_EQ(properties.ETag, res.Value.ETag); EXPECT_EQ(properties.LastModified, res.Value.LastModified); - std::vector downloadContent(static_cast(blobSize), '\x00'); - blockBlobClient.DownloadTo(downloadContent.data(), static_cast(blobSize)); + std::vector downloadContent(static_cast(blobSize), '\x00'); + blockBlobClient.DownloadTo(downloadContent.data(), static_cast(blobSize)); EXPECT_EQ( downloadContent, std::vector( - blobContent.begin(), blobContent.begin() + static_cast(blobSize))); + blobContent.begin(), blobContent.begin() + static_cast(blobSize))); }; auto testUploadFromFile = [&](int concurrency, int64_t blobSize) { @@ -850,7 +849,7 @@ namespace Azure { namespace Storage { namespace Test { std::string tempFilename = RandomString(); { Azure::Storage::_internal::FileWriter fileWriter(tempFilename); - fileWriter.Write(blobContent.data(), blobSize, 0); + fileWriter.Write(blobContent.data(), static_cast(blobSize), 0); } auto res = blockBlobClient.UploadFrom(tempFilename, options); EXPECT_TRUE(res.Value.ETag.HasValue()); @@ -863,12 +862,12 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(properties.AccessTier.Value(), options.AccessTier.Value()); EXPECT_EQ(properties.ETag, res.Value.ETag); EXPECT_EQ(properties.LastModified, res.Value.LastModified); - std::vector downloadContent(static_cast(blobSize), '\x00'); - blockBlobClient.DownloadTo(downloadContent.data(), static_cast(blobSize)); + std::vector downloadContent(static_cast(blobSize), '\x00'); + blockBlobClient.DownloadTo(downloadContent.data(), static_cast(blobSize)); EXPECT_EQ( downloadContent, std::vector( - blobContent.begin(), blobContent.begin() + static_cast(blobSize))); + blobContent.begin(), blobContent.begin() + static_cast(blobSize))); DeleteFile(tempFilename); }; @@ -878,7 +877,7 @@ namespace Azure { namespace Storage { namespace Test { for (int64_t l : {0ULL, 1ULL, 2ULL, 2_KB, 4_KB, 999_KB, 1_MB, 2_MB - 1, 3_MB, 5_MB, 8_MB - 1234, 8_MB}) { - ASSERT_GE(blobContent.size(), static_cast(l)); + ASSERT_GE(blobContent.size(), static_cast(l)); futures.emplace_back(std::async(std::launch::async, testUploadFromBuffer, c, l)); futures.emplace_back(std::async(std::launch::async, testUploadFromFile, c, l)); } diff --git a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp index 36fd56d07..b68c48ef5 100644 --- a/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp +++ b/sdk/storage/azure-storage-blobs/test/ut/page_blob_client_test.cpp @@ -27,7 +27,7 @@ namespace Azure { namespace Storage { namespace Test { StandardStorageConnectionString(), m_containerName, m_blobName); m_pageBlobClient = std::make_shared(std::move(pageBlobClient)); - m_blobContent.resize(static_cast(1_KB)); + m_blobContent.resize(static_cast(1_KB)); RandomBuffer(reinterpret_cast(&m_blobContent[0]), m_blobContent.size()); m_blobUploadOptions.Metadata = {{"key1", "V1"}, {"key2", "Value2"}}; m_blobUploadOptions.HttpHeaders.ContentType = "application/x-binary"; @@ -78,7 +78,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(PageBlobClientTest, UploadClear) { std::vector blobContent; - blobContent.resize(static_cast(4_KB)); + blobContent.resize(static_cast(4_KB)); RandomBuffer(reinterpret_cast(&blobContent[0]), blobContent.size()); auto pageBlobClient = Azure::Storage::Blobs::PageBlobClient::CreateFromConnectionString( @@ -87,13 +87,13 @@ namespace Azure { namespace Storage { namespace Test { auto pageContent = Azure::Core::IO::MemoryBodyStream(blobContent.data(), blobContent.size()); pageBlobClient.UploadPages(2_KB, pageContent); // |_|_|x|x| |x|x|_|_| - blobContent.insert(blobContent.begin(), static_cast(2_KB), '\x00'); - blobContent.resize(static_cast(8_KB), '\x00'); + blobContent.insert(blobContent.begin(), static_cast(2_KB), '\x00'); + blobContent.resize(static_cast(8_KB), '\x00'); pageBlobClient.ClearPages({2_KB, 1_KB}); // |_|_|_|x| |x|x|_|_| std::fill( - blobContent.begin() + static_cast(2_KB), - blobContent.begin() + static_cast(2_KB + 1_KB), + blobContent.begin() + static_cast(2_KB), + blobContent.begin() + static_cast(2_KB + 1_KB), '\x00'); auto downloadContent = pageBlobClient.Download(); @@ -127,7 +127,7 @@ namespace Azure { namespace Storage { namespace Test { auto snapshot = pageBlobClient.CreateSnapshot().Value.Snapshot; // |_|_|_|x| |x|x|_|_| This is what's in snapshot - blobContent.resize(static_cast(1_KB)); + blobContent.resize(static_cast(1_KB)); auto pageClient = Azure::Core::IO::MemoryBodyStream(blobContent.data(), blobContent.size()); pageBlobClient.UploadPages(0, pageClient); pageBlobClient.ClearPages({3_KB, 1_KB}); @@ -254,7 +254,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(PageBlobClientTest, ContentMd5) { std::vector blobContent; - blobContent.resize(static_cast(4_KB)); + blobContent.resize(static_cast(4_KB)); RandomBuffer(reinterpret_cast(&blobContent[0]), blobContent.size()); auto pageBlobClient = Azure::Storage::Blobs::PageBlobClient::CreateFromConnectionString( @@ -282,7 +282,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(PageBlobClientTest, ContentCrc64) { std::vector blobContent; - blobContent.resize(static_cast(4_KB)); + blobContent.resize(static_cast(4_KB)); RandomBuffer(reinterpret_cast(&blobContent[0]), blobContent.size()); auto pageBlobClient = Azure::Storage::Blobs::PageBlobClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/concurrent_transfer.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/concurrent_transfer.hpp index fdb7f2d9a..884f61a07 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/concurrent_transfer.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/concurrent_transfer.hpp @@ -36,7 +36,7 @@ namespace Azure { namespace Storage { namespace _internal { break; } int64_t chunkOffset = offset + chunkSize * chunkId; - int64_t chunkLength = (std::min)(length - chunkSize * chunkId, chunkSize); + int64_t chunkLength = std::min(length - chunkSize * chunkId, chunkSize); try { transferFunc(chunkOffset, chunkLength, chunkId, numChunks); diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp index 57759c519..e6afda269 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/crypt.hpp @@ -32,8 +32,8 @@ namespace Azure { namespace Storage { uint64_t m_context = 0ULL; uint64_t m_length = 0ULL; - void OnAppend(const uint8_t* data, std::size_t length) override; - std::vector OnFinal(const uint8_t* data, std::size_t length) override; + void OnAppend(const uint8_t* data, size_t length) override; + std::vector OnFinal(const uint8_t* data, size_t length) override; }; namespace _internal { diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/file_io.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/file_io.hpp index c25e4c820..26c3d55b8 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/file_io.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/file_io.hpp @@ -39,7 +39,7 @@ namespace Azure { namespace Storage { namespace _internal { FileHandle GetHandle() const { return m_handle; } - void Write(const uint8_t* buffer, int64_t length, int64_t offset); + void Write(const uint8_t* buffer, size_t length, int64_t offset); private: FileHandle m_handle; diff --git a/sdk/storage/azure-storage-common/inc/azure/storage/common/xml_wrapper.hpp b/sdk/storage/azure-storage-common/inc/azure/storage/common/xml_wrapper.hpp index aa4b6281f..8b756313e 100644 --- a/sdk/storage/azure-storage-common/inc/azure/storage/common/xml_wrapper.hpp +++ b/sdk/storage/azure-storage-common/inc/azure/storage/common/xml_wrapper.hpp @@ -31,7 +31,7 @@ namespace Azure { namespace Storage { namespace _internal { class XmlReader final { public: - explicit XmlReader(const char* data, std::size_t length); + explicit XmlReader(const char* data, size_t length); ~XmlReader(); XmlNode Read(); diff --git a/sdk/storage/azure-storage-common/src/crypt.cpp b/sdk/storage/azure-storage-common/src/crypt.cpp index 7e41f493e..ae6191827 100644 --- a/sdk/storage/azure-storage-common/src/crypt.cpp +++ b/sdk/storage/azure-storage-common/src/crypt.cpp @@ -91,8 +91,8 @@ namespace Azure { namespace Storage { struct AlgorithmProviderInstance final { BCRYPT_ALG_HANDLE Handle; - std::size_t ContextSize; - std::size_t HashLength; + size_t ContextSize; + size_t HashLength; AlgorithmProviderInstance(AlgorithmType type) { @@ -910,7 +910,7 @@ namespace Azure { namespace Storage { return vr[0] ^ vr[1]; } - void Crc64Hash::OnAppend(const uint8_t* data, std::size_t length) + void Crc64Hash::OnAppend(const uint8_t* data, size_t length) { m_length += length; @@ -1087,12 +1087,12 @@ namespace Azure { namespace Storage { m_context ^= other.m_context; } - std::vector Crc64Hash::OnFinal(const uint8_t* data, std::size_t length) + std::vector Crc64Hash::OnFinal(const uint8_t* data, size_t length) { OnAppend(data, length); std::vector binary; binary.resize(sizeof(m_context)); - for (std::size_t i = 0; i < sizeof(m_context); ++i) + for (size_t i = 0; i < sizeof(m_context); ++i) { binary[i] = (m_context >> (8 * i)) & 0xff; } diff --git a/sdk/storage/azure-storage-common/src/file_io.cpp b/sdk/storage/azure-storage-common/src/file_io.cpp index f728302e9..e968d708b 100644 --- a/sdk/storage/azure-storage-common/src/file_io.cpp +++ b/sdk/storage/azure-storage-common/src/file_io.cpp @@ -101,7 +101,7 @@ namespace Azure { namespace Storage { namespace _internal { FileWriter::~FileWriter() { CloseHandle(static_cast(m_handle)); } - void FileWriter::Write(const uint8_t* buffer, int64_t length, int64_t offset) + void FileWriter::Write(const uint8_t* buffer, size_t length, int64_t offset) { if (length > std::numeric_limits::max()) { @@ -155,16 +155,14 @@ namespace Azure { namespace Storage { namespace _internal { FileWriter::~FileWriter() { close(m_handle); } - void FileWriter::Write(const uint8_t* buffer, int64_t length, int64_t offset) + void FileWriter::Write(const uint8_t* buffer, size_t length, int64_t offset) { - if (static_cast(length) > std::numeric_limits::max() - || offset > static_cast(std::numeric_limits::max())) + if (offset > static_cast(std::numeric_limits::max())) { throw std::runtime_error("failed to write file"); } - ssize_t bytesWritten - = pwrite(m_handle, buffer, static_cast(length), static_cast(offset)); - if (bytesWritten != length) + ssize_t bytesWritten = pwrite(m_handle, buffer, length, static_cast(offset)); + if (bytesWritten < 0 || static_cast(bytesWritten) != length) { throw std::runtime_error("failed to write file"); } diff --git a/sdk/storage/azure-storage-common/src/xml_wrapper.cpp b/sdk/storage/azure-storage-common/src/xml_wrapper.cpp index ff0118341..c366b9bae 100644 --- a/sdk/storage/azure-storage-common/src/xml_wrapper.cpp +++ b/sdk/storage/azure-storage-common/src/xml_wrapper.cpp @@ -19,11 +19,11 @@ namespace Azure { namespace Storage { namespace _internal { static void XmlGlobalInitialize() { static XmlGlobalInitializer globalInitializer; } - XmlReader::XmlReader(const char* data, std::size_t length) + XmlReader::XmlReader(const char* data, size_t length) { XmlGlobalInitialize(); - if (length > static_cast(std::numeric_limits::max())) + if (length > static_cast(std::numeric_limits::max())) { throw std::runtime_error("xml data too big"); } diff --git a/sdk/storage/azure-storage-common/test/crypt_functions_test.cpp b/sdk/storage/azure-storage-common/test/crypt_functions_test.cpp index b11111a6c..11ae81402 100644 --- a/sdk/storage/azure-storage-common/test/crypt_functions_test.cpp +++ b/sdk/storage/azure-storage-common/test/crypt_functions_test.cpp @@ -53,15 +53,15 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(Azure::Core::Convert::Base64Encode(ComputeHash("")), "AAAAAAAAAAA="); EXPECT_EQ(Azure::Core::Convert::Base64Encode(ComputeHash("Hello Azure!")), "DtjZpL9/o8c="); - auto data = RandomBuffer(static_cast(16_MB)); + auto data = RandomBuffer(static_cast(16_MB)); { Crc64Hash crc64Single; Crc64Hash crc64Streaming; - std::size_t length = 0; + size_t length = 0; while (length < data.size()) { - std::size_t s = static_cast(RandomInt(0, 4_MB)); + size_t s = static_cast(RandomInt(0, 4_MB)); s = std::min(s, data.size() - length); crc64Streaming.Append(&data[length], s); crc64Streaming.Append(&data[length], 0); @@ -80,7 +80,7 @@ namespace Azure { namespace Storage { namespace Test { Crc64Hash instance2; for (auto i = RandomInt(0, 5); i > 0; --i) { - std::size_t s = static_cast(RandomInt(0, 512_KB)); + size_t s = static_cast(RandomInt(0, 512_KB)); std::string data2; data2.resize(s); RandomBuffer(&data2[0], s); @@ -103,7 +103,7 @@ namespace Azure { namespace Storage { namespace Test { break; } case 2: { - std::size_t s = static_cast(RandomInt(0, 512_KB)); + size_t s = static_cast(RandomInt(0, 512_KB)); std::string data2; data2.resize(s); RandomBuffer(&data2[0], s); diff --git a/sdk/storage/azure-storage-common/test/test_base.cpp b/sdk/storage/azure-storage-common/test/test_base.cpp index caf2ca6d5..665f4cf72 100644 --- a/sdk/storage/azure-storage-common/test/test_base.cpp +++ b/sdk/storage/azure-storage-common/test/test_base.cpp @@ -187,7 +187,7 @@ namespace Azure { namespace Storage { namespace Test { static char RandomChar() { const char charset[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; - std::uniform_int_distribution distribution(0, sizeof(charset) - 2); + std::uniform_int_distribution distribution(0, sizeof(charset) - 2); return charset[distribution(random_generator)]; } @@ -216,12 +216,12 @@ namespace Azure { namespace Storage { namespace Test { return result; } - void RandomBuffer(char* buffer, std::size_t length) + void RandomBuffer(char* buffer, size_t length) { char* start_addr = buffer; char* end_addr = buffer + length; - const std::size_t rand_int_size = sizeof(uint64_t); + const size_t rand_int_size = sizeof(uint64_t); while (uintptr_t(start_addr) % rand_int_size != 0 && start_addr < end_addr) { @@ -250,9 +250,9 @@ namespace Azure { namespace Storage { namespace Test { } fseek(fin, 0, SEEK_END); int64_t fileSize = ftell(fin); - std::vector fileContent(static_cast(fileSize)); + std::vector fileContent(static_cast(fileSize)); fseek(fin, 0, SEEK_SET); - std::size_t elementsRead = fread(fileContent.data(), static_cast(fileSize), 1, fin); + size_t elementsRead = fread(fileContent.data(), static_cast(fileSize), 1, fin); if (elementsRead != 1 && fileSize != 0) { throw std::runtime_error("failed to read file"); @@ -263,7 +263,7 @@ namespace Azure { namespace Storage { namespace Test { void DeleteFile(const std::string& filename) { std::remove(filename.data()); } - std::vector RandomBuffer(std::size_t length) + std::vector RandomBuffer(size_t length) { std::vector result(length); char* dataPtr = reinterpret_cast(&result[0]); diff --git a/sdk/storage/azure-storage-common/test/test_base.hpp b/sdk/storage/azure-storage-common/test/test_base.hpp index cc38814df..f6847367c 100644 --- a/sdk/storage/azure-storage-common/test/test_base.hpp +++ b/sdk/storage/azure-storage-common/test/test_base.hpp @@ -74,12 +74,12 @@ namespace Azure { namespace Storage { namespace Test { Storage::Metadata RandomMetadata(size_t size = 5); - void RandomBuffer(char* buffer, std::size_t length); - inline void RandomBuffer(uint8_t* buffer, std::size_t length) + void RandomBuffer(char* buffer, size_t length); + inline void RandomBuffer(uint8_t* buffer, size_t length) { RandomBuffer(reinterpret_cast(buffer), length); } - std::vector RandomBuffer(std::size_t length); + std::vector RandomBuffer(size_t length); inline std::vector ReadBodyStream(std::unique_ptr& stream) { diff --git a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp index 4123cfb0c..76b456c50 100644 --- a/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp +++ b/sdk/storage/azure-storage-files-datalake/inc/azure/storage/files/datalake/datalake_file_client.hpp @@ -200,7 +200,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { */ Azure::Response UploadFrom( const uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const UploadFileFromOptions& options = UploadFileFromOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; @@ -233,7 +233,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { */ Azure::Response DownloadTo( uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const DownloadFileToOptions& options = DownloadFileToOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; 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 508928703..c489da281 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 @@ -271,7 +271,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { Azure::Response DataLakeFileClient::UploadFrom( const uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const UploadFileFromOptions& options, const Azure::Core::Context& context) const { @@ -287,7 +287,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake { Azure::Response DataLakeFileClient::DownloadTo( uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const DownloadFileToOptions& options, const Azure::Core::Context& context) const { diff --git a/sdk/storage/azure-storage-files-datalake/test/datalake_file_client_test.cpp b/sdk/storage/azure-storage-files-datalake/test/datalake_file_client_test.cpp index 7216ce660..665efaab2 100644 --- a/sdk/storage/azure-storage-files-datalake/test/datalake_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-datalake/test/datalake_file_client_test.cpp @@ -371,7 +371,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(DataLakeFileClientTest, ConcurrentUploadDownload) { - std::vector fileContent = RandomBuffer(static_cast(8_MB)); + std::vector fileContent = RandomBuffer(static_cast(8_MB)); auto testUploadFromBuffer = [&](int concurrency, int64_t fileSize) { auto fileClient = m_fileSystemClient->GetFileClient(RandomString()); @@ -381,8 +381,7 @@ namespace Azure { namespace Storage { namespace Test { options.TransferOptions.Concurrency = concurrency; options.HttpHeaders = GetInterestingHttpHeaders(); options.Metadata = RandomMetadata(); - auto res - = fileClient.UploadFrom(fileContent.data(), static_cast(fileSize), options); + auto res = fileClient.UploadFrom(fileContent.data(), static_cast(fileSize), options); auto lastModified = fileClient.GetProperties().Value.LastModified; EXPECT_TRUE(res.Value.ETag.HasValue()); EXPECT_TRUE(IsValidTime(res.Value.LastModified)); @@ -394,12 +393,12 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(properties.ETag, res.Value.ETag); EXPECT_TRUE(IsValidTime(res.Value.LastModified)); EXPECT_EQ(properties.LastModified, res.Value.LastModified); - std::vector downloadContent(static_cast(fileSize), '\x00'); - fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize)); + std::vector downloadContent(static_cast(fileSize), '\x00'); + fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize)); EXPECT_EQ( downloadContent, std::vector( - fileContent.begin(), fileContent.begin() + static_cast(fileSize))); + fileContent.begin(), fileContent.begin() + static_cast(fileSize))); }; auto testUploadFromFile = [&](int concurrency, int64_t fileSize) { @@ -414,7 +413,7 @@ namespace Azure { namespace Storage { namespace Test { std::string tempFilename = RandomString(); { Azure::Storage::_internal::FileWriter fileWriter(tempFilename); - fileWriter.Write(fileContent.data(), fileSize, 0); + fileWriter.Write(fileContent.data(), static_cast(fileSize), 0); } auto res = fileClient.UploadFrom(tempFilename, options); auto lastModified = fileClient.GetProperties().Value.LastModified; @@ -427,12 +426,12 @@ namespace Azure { namespace Storage { namespace Test { EXPECT_EQ(properties.Metadata, options.Metadata); EXPECT_EQ(properties.ETag, res.Value.ETag); EXPECT_EQ(properties.LastModified, res.Value.LastModified); - std::vector downloadContent(static_cast(fileSize), '\x00'); - fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize)); + std::vector downloadContent(static_cast(fileSize), '\x00'); + fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize)); EXPECT_EQ( downloadContent, std::vector( - fileContent.begin(), fileContent.begin() + static_cast(fileSize))); + fileContent.begin(), fileContent.begin() + static_cast(fileSize))); std::string tempFileDestinationName = RandomString(); fileClient.DownloadTo(tempFileDestinationName); Azure::Storage::_internal::FileReader fileReader(tempFileDestinationName); @@ -448,7 +447,7 @@ namespace Azure { namespace Storage { namespace Test { for (int64_t l : {0ULL, 1ULL, 2ULL, 2_KB, 4_KB, 999_KB, 1_MB, 2_MB - 1, 3_MB, 5_MB, 8_MB - 1234, 8_MB}) { - ASSERT_GE(fileContent.size(), static_cast(l)); + ASSERT_GE(fileContent.size(), static_cast(l)); futures.emplace_back(std::async(std::launch::async, testUploadFromBuffer, c, l)); futures.emplace_back(std::async(std::launch::async, testUploadFromFile, c, l)); } @@ -491,7 +490,7 @@ namespace Azure { namespace Storage { namespace Test { { // Create from Anonymous credential. std::vector blobContent; - blobContent.resize(static_cast(1_MB)); + blobContent.resize(static_cast(1_MB)); RandomBuffer(reinterpret_cast(&blobContent[0]), blobContent.size()); auto objectName = RandomString(10); auto containerClient = Azure::Storage::Blobs::BlobContainerClient::CreateFromConnectionString( diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/protocol/share_rest_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/protocol/share_rest_client.hpp index 4b3a894be..2e7e246a7 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/protocol/share_rest_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/protocol/share_rest_client.hpp @@ -1473,7 +1473,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { "deleted", }; std::string result; - for (std::size_t i = 0; i < sizeof(value_list) / sizeof(ListSharesIncludeFlags); ++i) + for (size_t i = 0; i < sizeof(value_list) / sizeof(ListSharesIncludeFlags); ++i) { if ((val & value_list[i]) == value_list[i]) { diff --git a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp index 523e94178..22e6dee0b 100644 --- a/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp +++ b/sdk/storage/azure-storage-files-shares/inc/azure/storage/files/shares/share_file_client.hpp @@ -135,7 +135,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { */ Azure::Response DownloadTo( uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const DownloadFileToOptions& options = DownloadFileToOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; @@ -167,7 +167,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { */ Azure::Response UploadFrom( const uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const UploadFileFromOptions& options = UploadFileFromOptions(), const Azure::Core::Context& context = Azure::Core::Context()) const; diff --git a/sdk/storage/azure-storage-files-shares/sample/file_share_getting_started.cpp b/sdk/storage/azure-storage-files-shares/sample/file_share_getting_started.cpp index f4b40255b..6fc3bcc02 100644 --- a/sdk/storage/azure-storage-files-shares/sample/file_share_getting_started.cpp +++ b/sdk/storage/azure-storage-files-shares/sample/file_share_getting_started.cpp @@ -39,7 +39,7 @@ void FileShareGettingStarted() { std::cout << metadata.first << ":" << metadata.second << std::endl; } - fileContent.resize(static_cast(properties.FileSize)); + fileContent.resize(static_cast(properties.FileSize)); fileClient.DownloadTo(reinterpret_cast(&fileContent[0]), fileContent.size()); 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 542158def..405a83e02 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 @@ -646,7 +646,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Azure::Response ShareFileClient::DownloadTo( uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const DownloadFileToOptions& options, const Azure::Core::Context& context) const { @@ -688,7 +688,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } firstChunkLength = std::min(firstChunkLength, fileRangeSize); - if (static_cast(fileRangeSize) > bufferSize) + if (static_cast(fileRangeSize) > bufferSize) { throw Azure::Core::RequestFailedException( "buffer is not big enough, file range size is " + std::to_string(fileRangeSize)); @@ -796,15 +796,14 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { auto bodyStreamToFile = [](Azure::Core::IO::BodyStream& stream, _internal::FileWriter& fileWriter, int64_t offset, - int64_t length, + size_t length, const Azure::Core::Context& context) { - constexpr std::size_t bufferSize = 4 * 1024 * 1024; + constexpr size_t bufferSize = 4 * 1024 * 1024; std::vector buffer(bufferSize); while (length > 0) { - int64_t readSize = std::min(static_cast(bufferSize), length); - int64_t bytesRead - = stream.ReadToCount(buffer.data(), static_cast(readSize), context); + size_t readSize = std::min(bufferSize, length); + size_t bytesRead = stream.ReadToCount(buffer.data(), readSize, context); if (bytesRead != readSize) { throw Azure::Core::RequestFailedException("error when reading body stream"); @@ -815,7 +814,12 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { } }; - bodyStreamToFile(*(firstChunk.Value.BodyStream), fileWriter, 0, firstChunkLength, context); + bodyStreamToFile( + *(firstChunk.Value.BodyStream), + fileWriter, + 0, + static_cast(firstChunkLength), + context); firstChunk.Value.BodyStream.reset(); auto returnTypeConverter = [](Azure::Response& response) { @@ -840,7 +844,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { *(chunk.Value.BodyStream), fileWriter, offset - firstChunkOffset, - chunkOptions.Range.Value().Length.Value(), + static_cast(chunkOptions.Range.Value().Length.Value()), context); if (chunkId == numChunks - 1) @@ -865,7 +869,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { Azure::Response ShareFileClient::UploadFrom( const uint8_t* buffer, - std::size_t bufferSize, + size_t bufferSize, const UploadFileFromOptions& options, const Azure::Core::Context& context) const { @@ -949,7 +953,7 @@ namespace Azure { namespace Storage { namespace Files { namespace Shares { }; int64_t chunkSize = options.TransferOptions.ChunkSize; - if (bufferSize < static_cast(options.TransferOptions.SingleUploadThreshold)) + if (bufferSize < static_cast(options.TransferOptions.SingleUploadThreshold)) { chunkSize = bufferSize; } diff --git a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp index 84932afe8..34a1f9a87 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_file_client_test.cpp @@ -328,7 +328,7 @@ namespace Azure { namespace Storage { namespace Test { TEST_F(FileShareFileClientTest, ConcurrentUpload) { - std::vector fileContent = RandomBuffer(static_cast(8_MB)); + std::vector fileContent = RandomBuffer(static_cast(8_MB)); auto testUploadFromBuffer = [&](int concurrency, int64_t fileSize) { auto fileClient = m_fileShareDirectoryClient->GetFileClient(RandomString()); @@ -339,18 +339,17 @@ namespace Azure { namespace Storage { namespace Test { options.HttpHeaders = GetInterestingHttpHeaders(); options.Metadata = RandomMetadata(); - auto res - = fileClient.UploadFrom(fileContent.data(), static_cast(fileSize), options); + auto res = fileClient.UploadFrom(fileContent.data(), static_cast(fileSize), options); auto properties = fileClient.GetProperties().Value; EXPECT_EQ(properties.FileSize, fileSize); EXPECT_EQ(properties.Metadata, options.Metadata); - std::vector downloadContent(static_cast(fileSize), '\x00'); - fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize)); + std::vector downloadContent(static_cast(fileSize), '\x00'); + fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize)); EXPECT_EQ( downloadContent, std::vector( - fileContent.begin(), fileContent.begin() + static_cast(fileSize))); + fileContent.begin(), fileContent.begin() + static_cast(fileSize))); }; auto testUploadFromFile = [&](int concurrency, int64_t fileSize) { @@ -365,7 +364,7 @@ namespace Azure { namespace Storage { namespace Test { std::string tempFilename = RandomString(); { Azure::Storage::_internal::FileWriter fileWriter(tempFilename); - fileWriter.Write(fileContent.data(), fileSize, 0); + fileWriter.Write(fileContent.data(), static_cast(fileSize), 0); } auto res = fileClient.UploadFrom(tempFilename, options); @@ -373,12 +372,12 @@ namespace Azure { namespace Storage { namespace Test { auto properties = fileClient.GetProperties().Value; EXPECT_EQ(properties.FileSize, fileSize); EXPECT_EQ(properties.Metadata, options.Metadata); - std::vector downloadContent(static_cast(fileSize), '\x00'); - fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize)); + std::vector downloadContent(static_cast(fileSize), '\x00'); + fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize)); EXPECT_EQ( downloadContent, std::vector( - fileContent.begin(), fileContent.begin() + static_cast(fileSize))); + fileContent.begin(), fileContent.begin() + static_cast(fileSize))); DeleteFile(tempFilename); }; @@ -388,7 +387,7 @@ namespace Azure { namespace Storage { namespace Test { { for (int64_t l : {0ULL, 512ULL, 1_KB, 4_KB, 1_MB, 4_MB + 512}) { - ASSERT_GE(fileContent.size(), static_cast(l)); + ASSERT_GE(fileContent.size(), static_cast(l)); futures.emplace_back(std::async(std::launch::async, testUploadFromBuffer, c, l)); futures.emplace_back(std::async(std::launch::async, testUploadFromFile, c, l)); } @@ -442,7 +441,7 @@ namespace Azure { namespace Storage { namespace Test { expectedData.clear(); } } - downloadBuffer.resize(static_cast(downloadSize), '\x00'); + downloadBuffer.resize(static_cast(downloadSize), '\x00'); Files::Shares::DownloadFileToOptions options; options.TransferOptions.Concurrency = concurrency; if (offset.HasValue()) @@ -464,7 +463,7 @@ namespace Azure { namespace Storage { namespace Test { { auto res = m_fileClient->DownloadTo(downloadBuffer.data(), downloadBuffer.size(), options); EXPECT_EQ(res.Value.ContentRange.Length.Value(), actualDownloadSize); - downloadBuffer.resize(static_cast(res.Value.ContentRange.Length.Value())); + downloadBuffer.resize(static_cast(res.Value.ContentRange.Length.Value())); EXPECT_EQ(downloadBuffer, expectedData); } else @@ -605,11 +604,11 @@ namespace Azure { namespace Storage { namespace Test { for (int64_t length : {1ULL, 2ULL, 4_KB, 5_KB, 8_KB, 11_KB, 20_KB}) { std::vector downloadBuffer; - downloadBuffer.resize(static_cast(length - 1)); + downloadBuffer.resize(static_cast(length - 1)); options.Range.Value().Length = length; EXPECT_THROW( m_fileClient->DownloadTo( - downloadBuffer.data(), static_cast(length - 1), options), + downloadBuffer.data(), static_cast(length - 1), options), std::runtime_error); } } @@ -725,9 +724,8 @@ namespace Azure { namespace Storage { namespace Test { fileClient.Create(fileSize); EXPECT_NO_THROW(fileClient.UploadRange(0, memBodyStream)); EXPECT_NO_THROW(fileClient.ClearRange(fileSize / 2, fileSize / 2)); - std::vector downloadContent(static_cast(fileSize), '\x00'); - EXPECT_NO_THROW( - fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize))); + std::vector downloadContent(static_cast(fileSize), '\x00'); + EXPECT_NO_THROW(fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize))); EXPECT_EQ(halfContent, downloadContent); EXPECT_NO_THROW(fileClient.ClearRange(512, 512)); @@ -755,9 +753,8 @@ namespace Azure { namespace Storage { namespace Test { fileClient.Create(fileSize); EXPECT_NO_THROW(fileClient.UploadRange(0, memBodyStream)); EXPECT_NO_THROW(fileClient.ClearRange(fileSize / 2, fileSize / 2)); - std::vector downloadContent(static_cast(fileSize), '\x00'); - EXPECT_NO_THROW( - fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize))); + std::vector downloadContent(static_cast(fileSize), '\x00'); + EXPECT_NO_THROW(fileClient.DownloadTo(downloadContent.data(), static_cast(fileSize))); EXPECT_EQ(halfContent, downloadContent); auto snapshot1 = m_shareClient->CreateSnapshot().Value.Snapshot; diff --git a/sdk/storage/azure-storage-files-shares/test/share_sas_test.cpp b/sdk/storage/azure-storage-files-shares/test/share_sas_test.cpp index 0e4de8247..90cdb2c25 100644 --- a/sdk/storage/azure-storage-files-shares/test/share_sas_test.cpp +++ b/sdk/storage/azure-storage-files-shares/test/share_sas_test.cpp @@ -45,8 +45,7 @@ namespace Azure { namespace Storage { namespace Test { auto fileClient = Files::Shares::ShareFileClient(fileUrl + sas); auto downloadedContent = fileClient.Download(); EXPECT_EQ( - ReadBodyStream(downloadedContent.Value.BodyStream).size(), - static_cast(fileSize)); + ReadBodyStream(downloadedContent.Value.BodyStream).size(), static_cast(fileSize)); }; auto verifyFileCreate = [&](const std::string& sas) {