From 942c6aaffaa50d474840bfbeef8e8eb1b3e3ad0a Mon Sep 17 00:00:00 2001 From: Victor Vazquez Date: Thu, 17 Dec 2020 22:57:40 +0000 Subject: [PATCH] replace ifdef for if defined (#1199) fixes: #1057 --- .../azure-core/inc/azure/core/context.hpp | 4 ++-- .../inc/azure/core/http/body_stream.hpp | 4 ++-- .../inc/azure/core/http/curl/curl.hpp | 2 +- .../azure-core/inc/azure/core/http/http.hpp | 4 ++-- .../core/http/winhttp/win_http_client.hpp | 2 +- .../inc/azure/core/internal/contract.hpp | 2 +- sdk/core/azure-core/src/datetime.cpp | 24 +++++++++---------- sdk/core/azure-core/src/http/body_stream.cpp | 8 +++---- sdk/core/azure-core/src/http/curl/curl.cpp | 10 ++++---- .../curl/curl_connection_pool_private.hpp | 4 ++-- .../azure-core/src/http/telemetry_policy.cpp | 6 ++--- .../e2e/azure_core_storage_test_sample.cpp | 2 +- .../e2e/azure_core_with_curl_bodyBuffer.cpp | 6 ++--- sdk/core/azure-core/test/e2e/azure_hang.cpp | 2 +- .../test/ut/transport_adapter_base.cpp | 12 +++++----- .../test/ut/transport_adapter_curl.cpp | 2 +- .../src/environment_credential.cpp | 7 +++--- .../inc/azure/storage/common/file_io.hpp | 8 +++---- .../azure-storage-common/src/crypt.cpp | 2 +- 19 files changed, 55 insertions(+), 56 deletions(-) diff --git a/sdk/core/azure-core/inc/azure/core/context.hpp b/sdk/core/azure-core/inc/azure/core/context.hpp index e304abab9..2ac6eb740 100644 --- a/sdk/core/azure-core/inc/azure/core/context.hpp +++ b/sdk/core/azure-core/inc/azure/core/context.hpp @@ -69,7 +69,7 @@ namespace Azure { namespace Core { }; public: -#ifdef _MSC_VER +#if defined(_MSC_VER) #pragma warning(push) #pragma warning(disable : 26495) #endif @@ -152,7 +152,7 @@ namespace Azure { namespace Core { break; } } -#ifdef _MSC_VER +#if defined(_MSC_VER) #pragma warning(pop) #endif diff --git a/sdk/core/azure-core/inc/azure/core/http/body_stream.hpp b/sdk/core/azure-core/inc/azure/core/http/body_stream.hpp index 4bb43d91f..21e99e2c1 100644 --- a/sdk/core/azure-core/inc/azure/core/http/body_stream.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/body_stream.hpp @@ -13,10 +13,10 @@ #if defined(AZ_PLATFORM_POSIX) #include #elif defined(AZ_PLATFORM_WINDOWS) -#ifndef WIN32_LEAN_AND_MEAN +#if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN #endif -#ifndef NOMINMAX +#if !defined(NOMINMAX) #define NOMINMAX #endif #include diff --git a/sdk/core/azure-core/inc/azure/core/http/curl/curl.hpp b/sdk/core/azure-core/inc/azure/core/http/curl/curl.hpp index 4faf0fb8f..cf03b5734 100644 --- a/sdk/core/azure-core/inc/azure/core/http/curl/curl.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/curl/curl.hpp @@ -8,7 +8,7 @@ #pragma once -#ifdef BUILD_CURL_HTTP_TRANSPORT_ADAPTER +#if defined(BUILD_CURL_HTTP_TRANSPORT_ADAPTER) #include "azure/core/context.hpp" #include "azure/core/http/http.hpp" 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 ee9d9f311..ec4256795 100644 --- a/sdk/core/azure-core/inc/azure/core/http/http.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/http.hpp @@ -23,7 +23,7 @@ #include #include -#ifdef TESTING_BUILD +#if defined(TESTING_BUILD) // Define the class used from tests to validate retry enabled namespace Azure { namespace Core { namespace Test { class TestHttp_getters_Test; @@ -449,7 +449,7 @@ namespace Azure { namespace Core { namespace Http { */ class Request { friend class RetryPolicy; -#ifdef TESTING_BUILD +#if defined(TESTING_BUILD) // make tests classes friends to validate set Retry friend class Azure::Core::Test::TestHttp_getters_Test; friend class Azure::Core::Test::TestHttp_query_parameter_Test; diff --git a/sdk/core/azure-core/inc/azure/core/http/winhttp/win_http_client.hpp b/sdk/core/azure-core/inc/azure/core/http/winhttp/win_http_client.hpp index 3a37d2496..a4128c3b7 100644 --- a/sdk/core/azure-core/inc/azure/core/http/winhttp/win_http_client.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/winhttp/win_http_client.hpp @@ -7,7 +7,7 @@ #pragma once -#ifdef BUILD_TRANSPORT_WINHTTP_ADAPTER +#if defined(BUILD_TRANSPORT_WINHTTP_ADAPTER) #include "azure/core/context.hpp" #include "azure/core/http/http.hpp" diff --git a/sdk/core/azure-core/inc/azure/core/internal/contract.hpp b/sdk/core/azure-core/inc/azure/core/internal/contract.hpp index 891e9f821..59538ab96 100644 --- a/sdk/core/azure-core/inc/azure/core/internal/contract.hpp +++ b/sdk/core/azure-core/inc/azure/core/internal/contract.hpp @@ -3,7 +3,7 @@ #pragma once -#ifdef NO_CONTRACTS_CHECKING +#if defined(NO_CONTRACTS_CHECKING) #define AZ_CONTRACT(condition, error) #define AZ_CONTRACT_ARG_NOT_NULL(arg) #else diff --git a/sdk/core/azure-core/src/datetime.cpp b/sdk/core/azure-core/src/datetime.cpp index 0e2d8aa8f..0084fddbe 100644 --- a/sdk/core/azure-core/src/datetime.cpp +++ b/sdk/core/azure-core/src/datetime.cpp @@ -9,11 +9,11 @@ #include #include -#ifdef AZ_PLATFORM_WINDOWS -#ifndef WIN32_LEAN_AND_MEAN +#if defined(AZ_PLATFORM_WINDOWS) +#if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN #endif -#ifndef NOMINMAX +#if !defined(NOMINMAX) #define NOMINMAX #endif #include @@ -25,7 +25,7 @@ using namespace Azure::Core; DateTime DateTime::Now() { -#ifdef AZ_PLATFORM_WINDOWS +#if defined(AZ_PLATFORM_WINDOWS) FILETIME fileTime = {}; GetSystemTimeAsFileTime(&fileTime); @@ -179,13 +179,13 @@ std::string DateTime::GetString(DateFormat format, TimeFractionFormat fractionFo switch (format) { case DateFormat::Rfc1123: -#ifdef _MSC_VER +#if defined(_MSC_VER) sprintf_s( #else std::sprintf( #endif outCursor, -#ifdef _MSC_VER +#if defined(_MSC_VER) 26, #endif "%s, %02d %s %04d %02d:%02d:%02d", @@ -203,13 +203,13 @@ std::string DateTime::GetString(DateFormat format, TimeFractionFormat fractionFo return std::string(outBuffer, outCursor); case DateFormat::Rfc3339: -#ifdef _MSC_VER +#if defined(_MSC_VER) sprintf_s( #else std::sprintf( #endif outCursor, -#ifdef _MSC_VER +#if defined(_MSC_VER) 20, #endif "%04d-%02d-%02dT%02d:%02d:%02d", @@ -227,13 +227,13 @@ std::string DateTime::GetString(DateFormat format, TimeFractionFormat fractionFo // Append fractional second, which is a 7-digit value with no trailing zeros // This way, '1200' becomes '00012' size_t appended = -#ifdef _MSC_VER +#if defined(_MSC_VER) sprintf_s( #else std::sprintf( #endif outCursor, -#ifdef _MSC_VER +#if defined(_MSC_VER) 9, #endif ".%07d", @@ -841,13 +841,13 @@ DateTime::DateTime( // 1970-01-01T00:00:00.1234567Z\0 char* outCursor = outBuffer; -#ifdef _MSC_VER +#if defined(_MSC_VER) sprintf_s( #else std::sprintf( #endif outCursor, -#ifdef _MSC_VER +#if defined(_MSC_VER) 20, #endif "%04d-%02d-%02dT%02d:%02d:%02d", diff --git a/sdk/core/azure-core/src/http/body_stream.cpp b/sdk/core/azure-core/src/http/body_stream.cpp index e25d5c76c..73d230032 100644 --- a/sdk/core/azure-core/src/http/body_stream.cpp +++ b/sdk/core/azure-core/src/http/body_stream.cpp @@ -3,14 +3,14 @@ #include "azure/core/platform.hpp" -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) #include #include #elif defined(AZ_PLATFORM_WINDOWS) -#ifndef WIN32_LEAN_AND_MEAN +#if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN #endif -#ifndef NOMINMAX +#if !defined(NOMINMAX) #define NOMINMAX #endif #include @@ -83,7 +83,7 @@ int64_t MemoryBodyStream::Read(Context const& context, uint8_t* buffer, int64_t return copy_length; } -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) int64_t FileBodyStream::Read(Azure::Core::Context const& context, uint8_t* buffer, int64_t count) { context.ThrowIfCanceled(); diff --git a/sdk/core/azure-core/src/http/curl/curl.cpp b/sdk/core/azure-core/src/http/curl/curl.cpp index 30042e43f..9364fd2c3 100644 --- a/sdk/core/azure-core/src/http/curl/curl.cpp +++ b/sdk/core/azure-core/src/http/curl/curl.cpp @@ -13,7 +13,7 @@ #include "curl_connection_private.hpp" #include "curl_session_private.hpp" -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) #include // for poll() #elif defined(AZ_PLATFORM_WINDOWS) #include // for WSAPoll(); @@ -102,7 +102,7 @@ int pollSocketUntilEventOrTimeout( { // check cancelation context.ThrowIfCanceled(); -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) result = poll(&poller, 1, interval); #elif defined(AZ_PLATFORM_WINDOWS) result = WSAPoll(&poller, 1, interval); @@ -112,7 +112,7 @@ int pollSocketUntilEventOrTimeout( return result; } -#ifdef AZ_PLATFORM_WINDOWS +#if defined(AZ_PLATFORM_WINDOWS) // Windows needs this after every write to socket or performance would be reduced to 1/4 for // uploading operation. // https://github.com/Azure/azure-sdk-for-cpp/issues/644 @@ -371,7 +371,7 @@ CURLcode CurlConnection::SendBuffer( } }; } -#ifdef AZ_PLATFORM_WINDOWS +#if defined(AZ_PLATFORM_WINDOWS) WinSocketSetBuffSize(m_curlSocket); #endif return CURLE_OK; @@ -752,7 +752,7 @@ int64_t CurlConnection::ReadFromSocket(Context const& context, uint8_t* buffer, } } } -#ifdef AZ_PLATFORM_WINDOWS +#if defined(AZ_PLATFORM_WINDOWS) WinSocketSetBuffSize(m_curlSocket); #endif return readBytes; diff --git a/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp b/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp index 5bd48bc18..61a79bd2c 100644 --- a/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp +++ b/sdk/core/azure-core/src/http/curl/curl_connection_pool_private.hpp @@ -19,7 +19,7 @@ #include #include -#ifdef TESTING_BUILD +#if defined(TESTING_BUILD) // Define the class name that reads from ConnectionPool private members namespace Azure { namespace Core { namespace Test { class TransportAdapter_connectionPoolTest_Test; @@ -36,7 +36,7 @@ namespace Azure { namespace Core { namespace Http { * connection pool per application. */ class CurlConnectionPool { -#ifdef TESTING_BUILD +#if defined(TESTING_BUILD) // Give access to private to this tests class friend class Azure::Core::Test::TransportAdapter_connectionPoolTest_Test; #endif diff --git a/sdk/core/azure-core/src/http/telemetry_policy.cpp b/sdk/core/azure-core/src/http/telemetry_policy.cpp index 6be8b25aa..4f1daa758 100644 --- a/sdk/core/azure-core/src/http/telemetry_policy.cpp +++ b/sdk/core/azure-core/src/http/telemetry_policy.cpp @@ -7,12 +7,12 @@ #include #include -#ifdef AZ_PLATFORM_WINDOWS +#if defined(AZ_PLATFORM_WINDOWS) -#ifndef WIN32_LEAN_AND_MEAN +#if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN #endif -#ifndef NOMINMAX +#if !defined(NOMINMAX) #define NOMINMAX #endif diff --git a/sdk/core/azure-core/test/e2e/azure_core_storage_test_sample.cpp b/sdk/core/azure-core/test/e2e/azure_core_storage_test_sample.cpp index 913db7c37..9616e99db 100644 --- a/sdk/core/azure-core/test/e2e/azure_core_storage_test_sample.cpp +++ b/sdk/core/azure-core/test/e2e/azure_core_storage_test_sample.cpp @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT -#ifdef _MSC_VER +#if defined(_MSC_VER) #define _CRT_SECURE_NO_WARNINGS #endif diff --git a/sdk/core/azure-core/test/e2e/azure_core_with_curl_bodyBuffer.cpp b/sdk/core/azure-core/test/e2e/azure_core_with_curl_bodyBuffer.cpp index c912ecbd7..5fc887f17 100644 --- a/sdk/core/azure-core/test/e2e/azure_core_with_curl_bodyBuffer.cpp +++ b/sdk/core/azure-core/test/e2e/azure_core_with_curl_bodyBuffer.cpp @@ -9,13 +9,13 @@ #include #include -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) #include #elif defined(AZ_PLATFORM_WINDOWS) #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif -#ifndef NOMINMAX +#if !defined(NOMINMAX) #define NOMINMAX #endif #include @@ -72,7 +72,7 @@ int main() return 0; } -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) void doFileRequest(Context const& context, HttpPipeline& pipeline) { diff --git a/sdk/core/azure-core/test/e2e/azure_hang.cpp b/sdk/core/azure-core/test/e2e/azure_hang.cpp index 72b399e4c..2dba901ed 100644 --- a/sdk/core/azure-core/test/e2e/azure_hang.cpp +++ b/sdk/core/azure-core/test/e2e/azure_hang.cpp @@ -7,7 +7,7 @@ * */ -#ifdef _MSC_VER +#if defined(_MSC_VER) // this option is used to allow the application to use std::getenv without getting a compilation // warning about it on MSVC. #define _CRT_SECURE_NO_WARNINGS diff --git a/sdk/core/azure-core/test/ut/transport_adapter_base.cpp b/sdk/core/azure-core/test/ut/transport_adapter_base.cpp index 3ab66b4ff..43b8ecdac 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter_base.cpp +++ b/sdk/core/azure-core/test/ut/transport_adapter_base.cpp @@ -3,13 +3,13 @@ #include -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) #include #elif defined(AZ_PLATFORM_WINDOWS) -#ifndef WIN32_LEAN_AND_MEAN +#if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN #endif -#ifndef NOMINMAX +#if !defined(NOMINMAX) #define NOMINMAX #endif #include @@ -438,7 +438,7 @@ namespace Azure { namespace Core { namespace Test { Azure::Core::Http::Url host("http://httpbin.org/put"); std::string testDataPath(AZURE_TEST_DATA_PATH); -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) testDataPath.append("/fileData"); int f = open(testDataPath.data(), O_RDONLY); #elif defined(AZ_PLATFORM_WINDOWS) @@ -474,7 +474,7 @@ namespace Azure { namespace Core { namespace Test { Azure::Core::Http::Url host("http://httpbin.org/put"); std::string testDataPath(AZURE_TEST_DATA_PATH); -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) testDataPath.append("/fileData"); int f = open(testDataPath.data(), O_RDONLY); #elif defined(AZ_PLATFORM_WINDOWS) @@ -510,7 +510,7 @@ namespace Azure { namespace Core { namespace Test { Azure::Core::Http::Url host("http://httpbin.org/put"); std::string testDataPath(AZURE_TEST_DATA_PATH); -#ifdef AZ_PLATFORM_POSIX +#if defined(AZ_PLATFORM_POSIX) testDataPath.append("/fileData"); int f = open(testDataPath.data(), O_RDONLY); #elif defined(AZ_PLATFORM_WINDOWS) diff --git a/sdk/core/azure-core/test/ut/transport_adapter_curl.cpp b/sdk/core/azure-core/test/ut/transport_adapter_curl.cpp index 3af73c7fe..e0bce4eb0 100644 --- a/sdk/core/azure-core/test/ut/transport_adapter_curl.cpp +++ b/sdk/core/azure-core/test/ut/transport_adapter_curl.cpp @@ -73,7 +73,7 @@ namespace Azure { namespace Core { namespace Test { // Two connections re-used plus one connection created EXPECT_EQ(Http::CurlConnectionPool::ConnectionsOnPool("httpbin.org"), 3); -#ifdef RUN_LONG_UNIT_TESTS +#if defined(RUN_LONG_UNIT_TESTS) { // Test pool clean routine std::cout << "Running Connection Pool Cleaner Test. This test takes more than 3 minutes to " diff --git a/sdk/identity/azure-identity/src/environment_credential.cpp b/sdk/identity/azure-identity/src/environment_credential.cpp index 30c9f960d..831a63c18 100644 --- a/sdk/identity/azure-identity/src/environment_credential.cpp +++ b/sdk/identity/azure-identity/src/environment_credential.cpp @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // SPDX-License-Identifier: MIT - -#include "azure/identity/client_secret_credential.hpp" #include "azure/identity/environment_credential.hpp" +#include "azure/identity/client_secret_credential.hpp" #include @@ -11,7 +10,7 @@ using namespace Azure::Identity; EnvironmentCredential::EnvironmentCredential() { -#ifdef _MSC_VER +#if defined(_MSC_VER) #pragma warning(push) // warning C4996: 'getenv': This function or variable may be unsafe. Consider using _dupenv_s // instead. @@ -29,7 +28,7 @@ EnvironmentCredential::EnvironmentCredential() // // auto clientCertificatePath = std::getenv("AZURE_CLIENT_CERTIFICATE_PATH"); -#ifdef _MSC_VER +#if defined(_MSC_VER) #pragma warning(pop) #endif 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 e596f3576..f0d0aea07 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 @@ -5,11 +5,11 @@ #include -#ifdef AZ_PLATFORM_WINDOWS -#ifndef WIN32_LEAN_AND_MEAN +#if defined(AZ_PLATFORM_WINDOWS) +#if !defined(WIN32_LEAN_AND_MEAN) #define WIN32_LEAN_AND_MEAN #endif -#ifndef NOMINMAX +#if !defined(NOMINMAX) #define NOMINMAX #endif #include @@ -20,7 +20,7 @@ namespace Azure { namespace Storage { namespace Details { -#ifdef AZ_PLATFORM_WINDOWS +#if defined(AZ_PLATFORM_WINDOWS) using FileHandle = HANDLE; #elif defined(AZ_PLATFORM_POSIX) using FileHandle = int; diff --git a/sdk/storage/azure-storage-common/src/crypt.cpp b/sdk/storage/azure-storage-common/src/crypt.cpp index 7e1e460ab..ba31183fa 100644 --- a/sdk/storage/azure-storage-common/src/crypt.cpp +++ b/sdk/storage/azure-storage-common/src/crypt.cpp @@ -5,7 +5,7 @@ #include "azure/storage/common/crypt.hpp" #if defined(AZ_PLATFORM_WINDOWS) -#ifndef NOMINMAX +#if !defined(NOMINMAX) #define NOMINMAX #endif #include