replace ifdef for if defined (#1199)

fixes: #1057
This commit is contained in:
Victor Vazquez 2020-12-17 22:57:40 +00:00 committed by GitHub
parent bcb684f95e
commit 942c6aaffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 55 additions and 56 deletions

View File

@ -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

View File

@ -13,10 +13,10 @@
#if defined(AZ_PLATFORM_POSIX)
#include <unistd.h>
#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 <windows.h>

View File

@ -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"

View File

@ -23,7 +23,7 @@
#include <unordered_set>
#include <vector>
#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;

View File

@ -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"

View File

@ -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

View File

@ -9,11 +9,11 @@
#include <limits>
#include <stdexcept>
#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 <windows.h>
@ -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",

View File

@ -3,14 +3,14 @@
#include "azure/core/platform.hpp"
#ifdef AZ_PLATFORM_POSIX
#if defined(AZ_PLATFORM_POSIX)
#include <errno.h>
#include <unistd.h>
#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 <windows.h>
@ -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();

View File

@ -13,7 +13,7 @@
#include "curl_connection_private.hpp"
#include "curl_session_private.hpp"
#ifdef AZ_PLATFORM_POSIX
#if defined(AZ_PLATFORM_POSIX)
#include <poll.h> // for poll()
#elif defined(AZ_PLATFORM_WINDOWS)
#include <winsock2.h> // 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;

View File

@ -19,7 +19,7 @@
#include <memory>
#include <mutex>
#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

View File

@ -7,12 +7,12 @@
#include <cctype>
#include <sstream>
#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

View File

@ -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

View File

@ -9,13 +9,13 @@
#include <azure/core/http/pipeline.hpp>
#include <azure/core/platform.hpp>
#ifdef AZ_PLATFORM_POSIX
#if defined(AZ_PLATFORM_POSIX)
#include <fcntl.h>
#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 <windows.h>
@ -72,7 +72,7 @@ int main()
return 0;
}
#ifdef AZ_PLATFORM_POSIX
#if defined(AZ_PLATFORM_POSIX)
void doFileRequest(Context const& context, HttpPipeline& pipeline)
{

View File

@ -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

View File

@ -3,13 +3,13 @@
#include <azure/core/platform.hpp>
#ifdef AZ_PLATFORM_POSIX
#if defined(AZ_PLATFORM_POSIX)
#include <fcntl.h>
#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 <windows.h>
@ -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)

View File

@ -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 "

View File

@ -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 <cstdlib>
@ -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

View File

@ -5,11 +5,11 @@
#include <azure/core/platform.hpp>
#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 <windows.h>
@ -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;

View File

@ -5,7 +5,7 @@
#include "azure/storage/common/crypt.hpp"
#if defined(AZ_PLATFORM_WINDOWS)
#ifndef NOMINMAX
#if !defined(NOMINMAX)
#define NOMINMAX
#endif
#include <windows.h>