* Import changes from OS repo.

Almost all the changes are about fixing code analysis warnings

* Add missing SAL annotation to pal.h
This commit is contained in:
Luca Beltrami 2023-07-06 16:22:56 -07:00 коммит произвёл GitHub
Родитель 53dc58fce2
Коммит d9de7ed4e0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
17 изменённых файлов: 181 добавлений и 173 удалений

Просмотреть файл

@ -24,18 +24,18 @@ extern "C"
/// <summary>
/// A callback invoked every time a new memory buffer must be dynamically allocated by the library.
/// This callback is optionally installed by calling HCMemSetFunctions()
///
/// The callback must allocate and return a pointer to a contiguous block of memory of the
/// specified size that will remain valid until the app's corresponding HCMemFreeFunction
///
/// The callback must allocate and return a pointer to a contiguous block of memory of the
/// specified size that will remain valid until the app's corresponding HCMemFreeFunction
/// callback is invoked to release it.
///
///
/// Every non-null pointer returned by this method will be subsequently passed to the corresponding
/// HCMemFreeFunction callback once the memory is no longer needed.
/// </summary>
/// <returns>A pointer to an allocated block of memory of the specified size, or a null
/// <returns>A pointer to an allocated block of memory of the specified size, or a null
/// pointer if allocation failed.</returns>
/// <param name="size">The size of the allocation to be made. This value will never be zero.</param>
/// <param name="memoryType">An opaque identifier representing the internal category of
/// <param name="memoryType">An opaque identifier representing the internal category of
/// memory being allocated.</param>
typedef _Ret_maybenull_ _Post_writable_byte_size_(size) void*
(STDAPIVCALLTYPE* HCMemAllocFunction)(
@ -44,16 +44,16 @@ typedef _Ret_maybenull_ _Post_writable_byte_size_(size) void*
);
/// <summary>
/// A callback invoked every time a previously allocated memory buffer is no longer needed by
/// A callback invoked every time a previously allocated memory buffer is no longer needed by
/// the library and can be freed. This callback is optionally installed by calling HCMemSetFunctions()
///
/// The callback is invoked whenever the library has finished using a memory buffer previously
/// The callback is invoked whenever the library has finished using a memory buffer previously
/// returned by the app's corresponding HCMemAllocFunction such that the application can free the
/// memory buffer.
/// </summary>
/// <param name="pointer">The pointer to the memory buffer previously allocated. This value will
/// never be a null pointer.</param>
/// <param name="memoryType">An opaque identifier representing the internal category of
/// <param name="memoryType">An opaque identifier representing the internal category of
/// memory being allocated.</param>
typedef void
(STDAPIVCALLTYPE* HCMemFreeFunction)(
@ -62,23 +62,23 @@ typedef void
);
/// <summary>
/// Optionally sets the memory hook functions to allow callers to control route memory
/// Optionally sets the memory hook functions to allow callers to control route memory
/// allocations to their own memory manager.
/// </summary>
/// <param name="memAllocFunc">A pointer to the custom allocation callback to use, or a null
/// <param name="memAllocFunc">A pointer to the custom allocation callback to use, or a null
/// pointer to restore the default.</param>
/// <param name="memFreeFunc">A pointer to the custom freeing callback to use, or a null
/// <param name="memFreeFunc">A pointer to the custom freeing callback to use, or a null
/// pointer to restore the default.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, or E_HC_ALREADY_INITIALIZED.</returns>
/// <remarks>
/// This must be called before HCInitialize().
/// and can not be called again until HCCleanup().
///
/// This method allows the application to install custom memory allocation routines in order
/// This method allows the application to install custom memory allocation routines in order
/// to service all requests for new memory buffers instead of using default allocation routines.
///
/// The <paramref name="memAllocFunc" /> and <paramref name="memFreeFunc" /> parameters can be null
/// pointers to restore the default routines. Both callback pointers must be null or both must
/// pointers to restore the default routines. Both callback pointers must be null or both must
/// be non-null. Mixing custom and default routines is not permitted.
/// </remarks>
STDAPI HCMemSetFunctions(
@ -87,12 +87,12 @@ STDAPI HCMemSetFunctions(
) noexcept;
/// <summary>
/// Gets the memory hook functions to allow callers to control route memory allocations to their
/// own memory manager.
/// Gets the memory hook functions to allow callers to control route memory allocations to their
/// own memory manager.
/// </summary>
/// <param name="memAllocFunc">Set to the current allocation callback. Returns the default routine
/// <param name="memAllocFunc">Set to the current allocation callback. Returns the default routine
/// if not previously set.</param>
/// <param name="memFreeFunc">Set to the to the current memory free callback. Returns the default
/// <param name="memFreeFunc">Set to the to the current memory free callback. Returns the default
/// routine if not previously set.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, or E_FAIL.</returns>
/// <remarks>
@ -107,7 +107,7 @@ STDAPI HCMemGetFunctions(
/////////////////////////////////////////////////////////////////////////////////////////
// Global APIs
//
//
#if HC_PLATFORM == HC_PLATFORM_ANDROID
/// <summary>
@ -119,7 +119,7 @@ typedef struct HCInitArgs {
/// <summary>The Java Application Context.</summary>
jobject applicationContext;
} HCInitArgs;
#else
#else
/// <summary>
/// Dummy init args used by non-Android devices.
/// </summary>
@ -167,7 +167,7 @@ STDAPI HCCleanupAsync(XAsyncBlock* async) noexcept;
/// <summary>
/// Returns the version of the library.
/// </summary>
/// <param name="version">The UTF-8 encoded version of the library in the format of release_year.release_month.date.rev.
/// <param name="version">The UTF-8 encoded version of the library in the format of release_year.release_month.date.rev.
/// For example, 2017.07.20170710.01</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, or E_FAIL.</returns>
STDAPI HCGetLibVersion(_Outptr_ const char** version) noexcept;
@ -206,10 +206,10 @@ STDAPI_(void) HCRemoveCallRoutedHandler(
/// <summary>
/// Manually sets an explicit proxy address.
/// </summary>
/// <param name="proxyUri">The proxy address to use in the "[ip]:[port]" format.</param>
/// <param name="proxyUri">The proxy address to use in the "[ip]:[port]" format.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_HC_NOT_INITIALISED, or E_FAIL.</returns>
/// <remarks> If it is passed a null proxy, it will reset to default. Does not include proxying web socket traffic.</remarks>
STDAPI HCSetGlobalProxy(_In_ const char* proxyUri) noexcept;
STDAPI HCSetGlobalProxy(_In_z_ const char* proxyUri) noexcept;
/////////////////////////////////////////////////////////////////////////////////////////
// Http APIs
@ -226,14 +226,14 @@ STDAPI HCSetGlobalProxy(_In_ const char* proxyUri) noexcept;
/// Then call HCHttpCallPerformAsync() to perform HTTP call using the HCCallHandle.
/// This call is asynchronous, so the work will be done on a background thread and will return via the callback.
///
/// The perform call is asynchronous, so the work will be done on a background thread which calls
/// XTaskQueueDispatch( ..., XTaskQueuePort::Work ).
/// The perform call is asynchronous, so the work will be done on a background thread which calls
/// XTaskQueueDispatch( ..., XTaskQueuePort::Work ).
///
/// The results will return to the callback on the thread that calls
/// XTaskQueueDispatch( ..., XTaskQueuePort::Completion ), then get the result of the HTTP call by calling
/// The results will return to the callback on the thread that calls
/// XTaskQueueDispatch( ..., XTaskQueuePort::Completion ), then get the result of the HTTP call by calling
/// HCHttpCallResponseGet*() to get the HTTP response of the HCCallHandle.
///
/// When the HCCallHandle is no longer needed, call HCHttpCallCloseHandle() to free the
///
/// When the HCCallHandle is no longer needed, call HCHttpCallCloseHandle() to free the
/// memory associated with the HCCallHandle.
/// </remarks>
STDAPI HCHttpCallCreate(
@ -252,14 +252,14 @@ STDAPI HCHttpCallCreate(
/// Then call HCHttpCallPerformAsync() to perform HTTP call using the HCCallHandle.
/// This call is asynchronous, so the work will be done on a background thread and will return via the callback.
///
/// The perform call is asynchronous, so the work will be done on a background thread which calls
/// XTaskQueueDispatch( ..., XTaskQueuePort::Work ).
/// The perform call is asynchronous, so the work will be done on a background thread which calls
/// XTaskQueueDispatch( ..., XTaskQueuePort::Work ).
///
/// The results will return to the callback on the thread that calls
/// XTaskQueueDispatch( ..., XTaskQueuePort::Completion ), then get the result of the HTTP call by calling
/// The results will return to the callback on the thread that calls
/// XTaskQueueDispatch( ..., XTaskQueuePort::Completion ), then get the result of the HTTP call by calling
/// HCHttpCallResponseGet*() to get the HTTP response of the HCCallHandle.
///
/// When the HCCallHandle is no longer needed, call HCHttpCallCloseHandle() to free the
///
/// When the HCCallHandle is no longer needed, call HCHttpCallCloseHandle() to free the
/// memory associated with the HCCallHandle.
///
/// HCHttpCallPerformAsync can only be called once. Create new HCCallHandle to repeat the call.
@ -280,7 +280,7 @@ STDAPI_(HCCallHandle) HCHttpCallDuplicateHandle(
) noexcept;
/// <summary>
/// Decrements the reference count on the call object.
/// Decrements the reference count on the call object.
/// </summary>
/// <param name="call">The handle of the HTTP call</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, or E_FAIL.</returns>
@ -320,7 +320,7 @@ STDAPI HCHttpCallSetTracing(
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, E_OUTOFMEMORY, or E_FAIL.</returns>
STDAPI HCHttpCallGetRequestUrl(
_In_ HCCallHandle call,
_Out_ const char** url
_Outptr_result_z_ const char** url
) noexcept;
/////////////////////////////////////////////////////////////////////////////////////////
@ -345,7 +345,7 @@ STDAPI HCHttpCallRequestSetUrl(
/// Set the request body bytes of the HTTP call. This API operation is mutually exclusive with
/// HCHttpCallRequestSetRequestBodyReadFunction and will result in any custom read callbacks that were
/// previously set on this call handle to be ignored.
/// </summary>
/// </summary>
/// <param name="call">The handle of the HTTP call.</param>
/// <param name="requestBodyBytes">The request body bytes of the HTTP call.</param>
/// <param name="requestBodySize">The length in bytes of the body being set.</param>
@ -361,7 +361,7 @@ STDAPI HCHttpCallRequestSetRequestBodyBytes(
/// Set the request body string of the HTTP call. This API operation is mutually exclusive with
/// HCHttpCallRequestSetRequestBodyReadFunction and will result in any custom read callbacks that were
/// previously set on this call handle to be ignored.
/// </summary>
/// </summary>
/// <param name="call">The handle of the HTTP call.</param>
/// <param name="requestBodyString">The UTF-8 encoded request body string of the HTTP call.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, E_OUTOFMEMORY, or E_FAIL.</returns>
@ -476,7 +476,7 @@ STDAPI HCHttpCallRequestSetTimeout(
/// <param name="retryDelayInSeconds">The retry delay in seconds.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, or E_FAIL.</returns>
/// <remarks>
/// Retries are delayed using a exponential back off. By default, it will delay 2 seconds then the
/// Retries are delayed using a exponential back off. By default, it will delay 2 seconds then the
/// next retry will delay 4 seconds, then 8 seconds, and so on up to a max of 1 min until either
/// the call succeeds or the HTTP timeout window is reached, at which point the call will fail.
/// The delay is also jittered between the current and next delay to spread out service load.
@ -554,7 +554,7 @@ STDAPI HCHttpCallRequestSetSSLValidation(
enum class HCConfigSetting : uint32_t
{
/// <summary>
/// Only passed to the below API's to warn callers that this SSL validation
/// Only passed to the below API's to warn callers that this SSL validation
/// is enforced RETAIL sandboxes regardless of this setting
/// </summary>
SSLValidationEnforcedInRetailSandbox = 1
@ -568,7 +568,7 @@ enum class HCConfigSetting : uint32_t
/// <remarks>
/// On GDK console, SSL validation is enforced on RETAIL sandboxes regardless of this setting.
/// The asserts will not fire in RETAIL sandbox, and this setting has no affect in RETAIL sandboxes.
/// It is best practice to not call this API, but this can be used as a temporary way
/// It is best practice to not call this API, but this can be used as a temporary way
/// to get unblocked while in early stages of game development.
/// </remarks>
STDAPI HCHttpDisableAssertsForSSLValidationInDevSandboxes(
@ -616,7 +616,7 @@ STDAPI HCHttpCallResponseSetResponseBodyWriteFunction(
/////////////////////////////////////////////////////////////////////////////////////////
// HttpCallResponse Get APIs
//
//
/// <summary>
/// Get the response body string of the HTTP call. This API operation will fail if a custom write
@ -720,7 +720,7 @@ STDAPI HCHttpCallResponseGetPlatformNetworkErrorMessage(
STDAPI HCHttpCallResponseGetHeader(
_In_ HCCallHandle call,
_In_z_ const char* headerName,
_Out_ const char** headerValue
_Outptr_result_z_ const char** headerValue
) noexcept;
/// <summary>
@ -754,14 +754,14 @@ STDAPI HCHttpCallResponseGetNumHeaders(
STDAPI HCHttpCallResponseGetHeaderAtIndex(
_In_ HCCallHandle call,
_In_ uint32_t headerIndex,
_Out_ const char** headerName,
_Out_ const char** headerValue
_Outptr_result_z_ const char** headerName,
_Outptr_result_z_ const char** headerValue
) noexcept;
#if !HC_NOWEBSOCKETS
/////////////////////////////////////////////////////////////////////////////////////////
// WebSocket APIs
//
//
/// <summary>
/// A callback invoked every time a WebSocket receives an incoming message
@ -891,7 +891,7 @@ STDAPI HCWebSocketSetProxyUri(
STDAPI HCWebSocketSetProxyDecryptsHttps(
_In_ HCWebsocketHandle websocket,
_In_ bool allowProxyToDecryptHttps
) noexcept;
) noexcept;
#endif
/// <summary>
@ -969,7 +969,7 @@ typedef struct WebSocketCompletionResult
/// On UWP and XDK, the connection thread is owned and controlled by Windows::Networking::Sockets::MessageWebSocket.
/// On Win32 (Win 7+), iOS, and Android, all background work (including initial connection process) will be added to the queue
/// in the provided XAsyncBlock. LibHttpClient will create a reference to that queue but it is the responsibility of the
/// caller to dispatch that queue for as long as the websocket connection is active. Note that work for
/// caller to dispatch that queue for as long as the websocket connection is active. Note that work for
/// HCWebSocketSendMessageAsync calls can be assigned to a separate queue if desired.
/// </remarks>
STDAPI HCWebSocketConnectAsync(
@ -1071,7 +1071,7 @@ STDAPI_(HCWebsocketHandle) HCWebSocketDuplicateHandle(
) noexcept;
/// <summary>
/// Decrements the reference count on the WebSocket object.
/// Decrements the reference count on the WebSocket object.
/// </summary>
/// <param name="websocket">Handle to the WebSocket.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, or E_FAIL.</returns>

Просмотреть файл

@ -42,8 +42,8 @@ typedef void
/// <remarks>
/// Must be called before HCInit.
///
/// In the HCCallPerformFunction callback, use HCHttpCallRequestGet*() and HCSettingsGet*() to
/// get information about the HTTP call and perform the call as desired and set
/// In the HCCallPerformFunction callback, use HCHttpCallRequestGet*() and HCSettingsGet*() to
/// get information about the HTTP call and perform the call as desired and set
/// the response with HCHttpCallResponseSet*().
/// </remarks>
/// <returns>Result code for this API operation. Possible values are S_OK, or
@ -54,10 +54,10 @@ STDAPI HCSetHttpCallPerformFunction(
) noexcept;
/// <summary>
/// Returns the current HCCallPerformFunction callback which implements the HTTP
/// Returns the current HCCallPerformFunction callback which implements the HTTP
/// perform function on the current platform.
/// </summary>
/// <param name="performFunc">Set to the current HTTP perform function. Returns the default
/// <param name="performFunc">Set to the current HTTP perform function. Returns the default
/// routine if not previously set.</param>
/// <param name="performContext">The context for the callback.</param>
/// <remarks>
@ -107,8 +107,8 @@ STDAPI HCHttpCallSetContext(
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, or E_FAIL.</returns>
STDAPI HCHttpCallRequestGetUrl(
_In_ HCCallHandle call,
_Outptr_ const char** method,
_Outptr_ const char** url
_Outptr_result_z_ const char** method,
_Outptr_result_z_ const char** url
) noexcept;
/// <summary>
@ -233,14 +233,14 @@ STDAPI HCHttpCallRequestGetTimeout(
/// <param name="retryDelayInSeconds">The retry delay in seconds.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, or E_FAIL.</returns>
/// <remarks>
/// Retries are delayed using a exponential back off. By default, it will delay 2 seconds then the
/// Retries are delayed using a exponential back off. By default, it will delay 2 seconds then the
/// next retry will delay 4 seconds, then 8 seconds, and so on up to a max of 1 min until either
/// the call succeeds or the HTTP timeout window is reached, at which point the call will fail.
/// The delay is also jittered between the current and next delay to spread out service load.
/// The default for the HTTP timeout window is 20 seconds and can be changed using HCSettingsSetTimeoutWindow()<br />
/// <br />
/// If the service returns an HTTP error with a "Retry-After" header, then all future calls to that API
/// will immediately fail with the original error without contacting the service until the "Retry-After"
/// If the service returns an HTTP error with a "Retry-After" header, then all future calls to that API
/// will immediately fail with the original error without contacting the service until the "Retry-After"
/// time has been reached.<br />
///<br />
/// Idempotent service calls are retried when a network error occurs or the server responds <br />
@ -301,7 +301,7 @@ STDAPI HCHttpCallResponseGetResponseBodyWriteFunction(
/////////////////////////////////////////////////////////////////////////////////////////
// HttpCallResponse Set APIs
//
//
/// <summary>
/// Set the response body byte buffer of the HTTP call. If a custom write callback was previously set
@ -402,7 +402,7 @@ STDAPI HCHttpCallResponseSetHeaderWithLength(
/////////////////////////////////////////////////////////////////////////////////////////
// WebSocket Set APIs
//
//
/// <summary>
/// Function to connects to the WebSocket. This API returns immediately and will spin up a thread under the covers.
@ -477,17 +477,17 @@ typedef HRESULT
/// <summary>
/// Optionally allows the caller to implement the WebSocket functions.
/// </summary>
/// <param name="websocketConnectFunc">A callback that implements WebSocket connect function as desired.
/// <param name="websocketConnectFunc">A callback that implements WebSocket connect function as desired.
/// Pass in nullptr to use the default implementation based on the current platform.</param>
/// <param name="websocketSendMessageFunc">A callback that implements WebSocket send message function as desired.
/// <param name="websocketSendMessageFunc">A callback that implements WebSocket send message function as desired.
/// Pass in nullptr to use the default implementation based on the current platform.</param>
/// <param name="websocketSendBinaryMessageFunc">A callback that implements WebSocket send binary message function as desired.
/// <param name="websocketSendBinaryMessageFunc">A callback that implements WebSocket send binary message function as desired.
/// Pass in nullptr to use the default implementation based on the current platform.</param>
/// <param name="websocketDisconnectFunc">A callback that implements WebSocket disconnect function as desired.
/// <param name="websocketDisconnectFunc">A callback that implements WebSocket disconnect function as desired.
/// Pass in nullptr to use the default implementation based on the current platform.</param>
/// <param name="context">The context pointer for the callbacks.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, or E_FAIL.</returns>
STDAPI
STDAPI
HCSetWebSocketFunctions(
_In_ HCWebSocketConnectFunction websocketConnectFunc,
_In_ HCWebSocketSendMessageFunction websocketSendMessageFunc,
@ -505,7 +505,7 @@ HCSetWebSocketFunctions(
/// <param name="websocketDisconnectFunc">A callback that implements WebSocket disconnect function as desired.</param>
/// <param name="context">The context pointer for the callbacks.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, or E_FAIL.</returns>
STDAPI
STDAPI
HCGetWebSocketFunctions(
_Out_ HCWebSocketConnectFunction* websocketConnectFunc,
_Out_ HCWebSocketSendMessageFunction* websocketSendMessageFunc,
@ -520,7 +520,7 @@ HCGetWebSocketFunctions(
/// <param name="websocket">The handle of the WebSocket.</param>
/// <param name="proxyUri">The UTF-8 encoded proxy URI for the WebSocket.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, E_OUTOFMEMORY, or E_FAIL.</returns>
STDAPI
STDAPI
HCWebSocketGetProxyUri(
_In_ HCWebsocketHandle websocket,
_Out_ const char** proxyUri
@ -533,7 +533,7 @@ HCWebSocketGetProxyUri(
/// <param name="headerName">UTF-8 encoded header name for the WebSocket.</param>
/// <param name="headerValue">UTF-8 encoded header value for the WebSocket.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, E_OUTOFMEMORY, or E_FAIL.</returns>
STDAPI
STDAPI
HCWebSocketGetHeader(
_In_ HCWebsocketHandle websocket,
_In_z_ const char* headerName,
@ -546,7 +546,7 @@ HCWebSocketGetHeader(
/// <param name="websocket">The handle of the WebSocket.</param>
/// <param name="numHeaders">the number of headers in the WebSocket.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, or E_FAIL.</returns>
STDAPI
STDAPI
HCWebSocketGetNumHeaders(
_In_ HCWebsocketHandle websocket,
_Out_ uint32_t* numHeaders
@ -561,7 +561,7 @@ HCWebSocketGetNumHeaders(
/// <param name="headerValue">UTF-8 encoded header value for the HTTP call.</param>
/// <returns>Result code for this API operation. Possible values are S_OK, E_INVALIDARG, or E_FAIL.</returns>
/// <remarks>Use HCHttpCallGetNumHeaders() to know how many headers there are in the HTTP call.</remarks>
STDAPI
STDAPI
HCWebSocketGetHeaderAtIndex(
_In_ HCWebsocketHandle websocket,
_In_ uint32_t headerIndex,

Просмотреть файл

@ -328,7 +328,11 @@ typedef struct _LIST_ENTRY {
#endif
#ifndef _Outptr_
#define _Outptr_
#define _Outptr_
#endif
#ifndef _Outptr_result_z_
#define _Outptr_result_z_
#endif
#ifndef _Outptr_result_maybenull_

Просмотреть файл

@ -23,17 +23,27 @@ void FormatHelper(TBuffer& buffer, _In_z_ _Printf_format_string_ char const* for
{
va_list args1{};
va_copy(args1, args);
int required = std::vsnprintf(nullptr, 0, format, args1);
int required =
#if HC_PLATFORM_IS_MICROSOFT
_vscprintf(format, args1);
#else
std::vsnprintf(nullptr, 0, format, args1);
#endif
va_end(args1);
ASSERT(required > 0);
size_t originalSize = buffer.size();
buffer.resize(originalSize + static_cast<size_t>(required) + 1); // add space for null terminator
va_list args2{};
va_copy(args2, args);
buffer.resize(originalSize + static_cast<size_t>(required) + 1); // add space for null terminator
int written = std::vsnprintf(reinterpret_cast<char*>(&buffer[originalSize]), buffer.size(), format, args2);
int written =
#if HC_PLATFORM_IS_MICROSOFT
vsprintf_s(reinterpret_cast<char*>(&buffer[originalSize]), required + 1, format, args2);
#else
std::vsnprintf(reinterpret_cast<char*>(&buffer[originalSize]), required + 1, format, args2);
#endif
va_end(args2);
ASSERT(written == required);

Просмотреть файл

@ -145,9 +145,9 @@ HRESULT CALLBACK http_singleton::CleanupAsyncProvider(XAsyncOp op, const XAsyncP
// Provider cleanup really should never fail. If it does, there isn't much we can do so log error and continue with cleanup
HC_TRACE_ERROR_HR(HTTPCLIENT, cleanupResult, "HC_PERFORM_ENV::CleanupAsync failed unexpectedly, continuing with cleanup");
}
// PerformEnv cleanup complete, continue with singleton cleanup
XAsyncSchedule(singletonCleanupAsyncBlock, 0);
XAsyncSchedule(singletonCleanupAsyncBlock, 0);
};
RETURN_IF_FAILED(HC_PERFORM_ENV::CleanupAsync(std::move(singleton->m_performEnv), performEnvCleanupAsyncBlock.get()));
@ -250,7 +250,7 @@ void http_singleton::clear_retry_state(_In_ uint32_t retryAfterCacheId)
m_retryAfterCache.erase(retryAfterCacheId);
}
HRESULT http_singleton::set_global_proxy(_In_ const char* proxyUri)
HRESULT http_singleton::set_global_proxy(_In_z_ const char* proxyUri)
{
#if HC_PLATFORM == HC_PLATFORM_WIN32 && !HC_UNITTEST_API
return m_performEnv->winHttpProvider->SetGlobalProxy(proxyUri);

Просмотреть файл

@ -65,7 +65,7 @@ public:
HttpPerformInfo const m_httpPerform;
PerformEnv m_performEnv;
HRESULT set_global_proxy(_In_ const char* proxyUri);
HRESULT set_global_proxy(_In_z_ const char* proxyUri);
std::atomic<std::uint64_t> m_lastId{ 0 };
bool m_retryAllowed = true;

Просмотреть файл

@ -30,7 +30,7 @@ try
}
CATCH_RETURN()
STDAPI_(bool)
STDAPI_(bool)
HCIsInitialized() noexcept
{
auto httpSingleton = get_http_singleton();
@ -49,7 +49,7 @@ try
{
XAsyncBlock async{};
async.queue = queue; // queue is required for this call
hr = HCCleanupAsync(&async);
hr = HCCleanupAsync(&async);
if (SUCCEEDED(hr))
{
XAsyncGetStatus(&async, true);
@ -67,7 +67,7 @@ try
CATCH_RETURN()
STDAPI
HCSetGlobalProxy(_In_ const char* proxyUri) noexcept
HCSetGlobalProxy(_In_z_ const char* proxyUri) noexcept
try
{
auto httpSingleton = get_http_singleton();

Просмотреть файл

@ -628,7 +628,7 @@ void WinHttpConnection::callback_status_request_error(
return;
DWORD errorCode = error_result->dwError;
HC_TRACE_ERROR(HTTPCLIENT, "HCHttpCallPerform [ID %llu] [TID %ul] WINHTTP_CALLBACK_STATUS_REQUEST_ERROR dwResult=%d dwError=%d", TO_ULL(HCHttpCallGetId(pRequestContext->m_call)), GetCurrentThreadId(), error_result->dwResult, error_result->dwError);
HC_TRACE_ERROR(HTTPCLIENT, "HCHttpCallPerform [ID %llu] [TID %ul] WINHTTP_CALLBACK_STATUS_REQUEST_ERROR dwResult=%llu dwError=%u", TO_ULL(HCHttpCallGetId(pRequestContext->m_call)), GetCurrentThreadId(), error_result->dwResult, error_result->dwError);
bool reissueSend{ false };
@ -845,7 +845,7 @@ uint32_t WinHttpConnection::parse_status_code(
void WinHttpConnection::parse_headers_string(
_In_ HCCallHandle call,
_In_ wchar_t* headersStr)
_In_z_ wchar_t* headersStr)
{
wchar_t* context = nullptr;
wchar_t* line = wcstok_s(headersStr, CRLF, &context);
@ -1261,7 +1261,7 @@ HRESULT WinHttpConnection::set_autodiscover_proxy()
void WinHttpConnection::SendRequest()
{
HC_TRACE_INFORMATION(HTTPCLIENT, "WinHttpConnection [%d] SendRequest", TO_ULL(HCHttpCallGetId(m_call)));
HC_TRACE_INFORMATION(HTTPCLIENT, "WinHttpConnection [%llu] SendRequest", TO_ULL(HCHttpCallGetId(m_call)));
HC_UNIQUE_PTR<WinHttpCallbackContext> context = http_allocate_unique<WinHttpCallbackContext>(shared_from_this());

Просмотреть файл

@ -197,7 +197,7 @@ private:
static void read_next_response_chunk(_In_ WinHttpConnection* pRequestContext, DWORD bytesRead);
static void _multiple_segment_write_data(_In_ WinHttpConnection* pRequestContext);
static void parse_headers_string(_In_ HCCallHandle call, _In_ wchar_t* headersStr);
static void parse_headers_string(_In_ HCCallHandle call, _In_z_ wchar_t* headersStr);
// WinHttp event callbacks
static void CALLBACK completion_callback(

Просмотреть файл

@ -167,7 +167,7 @@ HRESULT CALLBACK WinHttpProvider::WebSocketDisconnectHandler(
}
#endif //!HC_NOWEBSOCKETS
HRESULT WinHttpProvider::SetGlobalProxy(_In_ const char* proxyUri) noexcept
HRESULT WinHttpProvider::SetGlobalProxy(_In_z_ const char* proxyUri) noexcept
{
std::lock_guard<std::mutex> lock(m_lock);
m_globalProxy = proxyUri;

Просмотреть файл

@ -99,7 +99,7 @@ public:
#endif
// Sets Global proxy for all HttpConnections
HRESULT SetGlobalProxy(_In_ const char* proxyUri) noexcept;
HRESULT SetGlobalProxy(_In_z_ const char* proxyUri) noexcept;
private:
WinHttpProvider() = default;

Просмотреть файл

@ -93,7 +93,7 @@ HRESULT CALLBACK HC_CALL::PerfomAsyncProvider(XAsyncOp op, XAsyncProviderData co
{
call->performCalled = true;
call->m_performStartTime = chrono_clock_t::now();
// Initialize work queues
XTaskQueuePortHandle workPort{ nullptr };
RETURN_IF_FAILED(XTaskQueueGetPort(data->async->queue, XTaskQueuePort::Work, &workPort));
@ -106,8 +106,8 @@ HRESULT CALLBACK HC_CALL::PerfomAsyncProvider(XAsyncOp op, XAsyncProviderData co
RETURN_IF_FAILED(shouldFailFast.hr);
if (shouldFailFast.Payload())
{
if (call->traceCall)
{
if (call->traceCall)
{
HC_TRACE_INFORMATION(HTTPCLIENT, "HC_CALL::PerfomAsyncProvider [ID %llu] Fast fail %d", TO_ULL(call->id), call->statusCode);
}
XAsyncComplete(data->async, S_OK, 0);
@ -219,8 +219,8 @@ HRESULT HC_CALL::PerformSingleRequestAsyncProvider(XAsyncOp op, XAsyncProviderDa
}
catch (...)
{
if (call->traceCall)
{
if (call->traceCall)
{
HC_TRACE_ERROR(HTTPCLIENT, "Caught unhandled exception in HCCallPerformFunction [ID %llu]", TO_ULL(static_cast<HC_CALL*>(call)->id));
}
return E_FAIL;
@ -266,7 +266,7 @@ void HC_CALL::PerformSingleRequestComplete(XAsyncBlock* async)
{
HC_TRACE_INFORMATION(HTTPCLIENT, "HC_CALL::PerformSingleRequestComplete [ID %llu] Retry after %lld ms", TO_ULL(call->id), TO_ULL(performDelay));
}
// Schedule retry
hr = XTaskQueueSubmitDelayedCallback(context->workQueue, XTaskQueuePort::Work, performDelay, context, HC_CALL::PerformSingleRequest);
if (SUCCEEDED(hr))
@ -274,7 +274,7 @@ void HC_CALL::PerformSingleRequestComplete(XAsyncBlock* async)
call->ResetResponseProperties();
return;
}
}
}
}
// Complete perform if we aren't retrying or if there were any XAsync failures
@ -290,7 +290,7 @@ HRESULT CALLBACK HC_CALL::ReadRequestBody(
_Out_ size_t* bytesWritten
) noexcept
{
RETURN_HR_IF(E_INVALIDARG, !call || !bytesAvailable || !destination || !bytesWritten);
RETURN_HR_IF(E_INVALIDARG, !call || !bytesAvailable || !destination || !bytesWritten);
uint8_t const* requestBody = nullptr;
uint32_t requestBodySize = 0;
@ -321,7 +321,7 @@ HRESULT CALLBACK HC_CALL::ResponseBodyWrite(
return HCHttpCallResponseAppendResponseBodyBytes(call, source, bytesAvailable);
}
Result<bool> HC_CALL::ShouldFailFast(_Out_opt_ uint32_t& performDelay)
Result<bool> HC_CALL::ShouldFailFast(uint32_t& performDelay)
{
std::shared_ptr<http_singleton> state = get_http_singleton();
RETURN_HR_IF(E_HC_NOT_INITIALISED, !state);
@ -352,14 +352,14 @@ Result<bool> HC_CALL::ShouldFailFast(_Out_opt_ uint32_t& performDelay)
// Don't have multiple calls waiting for the Retry-After window for a single endpoint.
// This causes a flood of calls to the endpoint as soon as the Retry-After windows elapses. If there is already a call
// pending to this endpoint, fail fast with the cached error code.
//
//
// Otherwise, if the Retry-After will elapse before this call's timeout, delay the call until Retry-After window but don't fail fast
performDelay = static_cast<uint32_t>(remainingTimeBeforeRetryAfterInMS.count());
// Update retry cache to indicate this request is pending to the endpoint
apiState.callPending = true;
state->set_retry_state(retryAfterCacheId, apiState);
return false;
}
@ -368,7 +368,7 @@ Result<bool> HC_CALL::ShouldFailFast(_Out_opt_ uint32_t& performDelay)
return true;
}
bool HC_CALL::ShouldRetry(_Out_opt_ uint32_t& performDelay)
bool HC_CALL::ShouldRetry(uint32_t& performDelay)
{
if (!retryAllowed)
{
@ -383,9 +383,9 @@ bool HC_CALL::ShouldRetry(_Out_opt_ uint32_t& performDelay)
auto responseReceivedTime{ chrono_clock_t::now() };
if (statusCode == 408 || // Request Timeout
statusCode == 429 || // Too Many Requests
statusCode == 429 || // Too Many Requests
statusCode == 500 || // Internal Error
statusCode == 502 || // Bad Gateway
statusCode == 502 || // Bad Gateway
statusCode == 503 || // Service Unavailable
statusCode == 504 || // Gateway Timeout
networkErrorCode != S_OK)
@ -394,7 +394,7 @@ bool HC_CALL::ShouldRetry(_Out_opt_ uint32_t& performDelay)
std::chrono::milliseconds timeElapsedSinceFirstCall = std::chrono::duration_cast<std::chrono::milliseconds>(responseReceivedTime - m_performStartTime);
std::chrono::seconds timeoutWindow = std::chrono::seconds{ timeoutWindowInSeconds };
std::chrono::milliseconds remainingTimeBeforeTimeout = timeoutWindow - timeElapsedSinceFirstCall;
if (traceCall)
if (traceCall)
{
HC_TRACE_INFORMATION(HTTPCLIENT, "HC_CALL::ShouldRetry [ID %llu] remainingTimeBeforeTimeout %lld ms", TO_ULL(id), remainingTimeBeforeTimeout.count());
}
@ -402,7 +402,7 @@ bool HC_CALL::ShouldRetry(_Out_opt_ uint32_t& performDelay)
// Based on the retry iteration, delay 2,4,8,16,etc seconds by default between retries
// Jitter the response between the current and next delay based on system clock
// Max wait time is 1 minute
double secondsToWaitMin = std::pow(retryDelayInSeconds, m_iterationNumber);
double secondsToWaitMax = std::pow(retryDelayInSeconds, m_iterationNumber + 1);
double secondsToWaitDelta = secondsToWaitMax - secondsToWaitMin;
@ -502,7 +502,7 @@ void HC_CALL::ResetResponseProperties()
responseHeaders.clear();
statusCode = 0;
networkErrorCode = S_OK;
platformNetworkErrorCode = 0;
platformNetworkErrorCode = 0;
}
bool HeaderCompare::operator()(http_internal_string const& l, http_internal_string const& r) const

Просмотреть файл

@ -91,7 +91,7 @@ public:
_In_opt_ void* context
) noexcept;
protected: // Protected for HC_MOCK_CALL
protected: // Protected for HC_MOCK_CALL
HC_CALL(uint64_t id);
private:
@ -100,16 +100,15 @@ private:
static HRESULT CALLBACK PerformSingleRequestAsyncProvider(XAsyncOp op, XAsyncProviderData const* data) noexcept;
static void CALLBACK PerformSingleRequestComplete(XAsyncBlock* async);
Result<bool> ShouldFailFast(_Out_opt_ uint32_t& performDelay);
bool ShouldRetry(_Out_opt_ uint32_t& performDelay);
Result<bool> ShouldFailFast(uint32_t& performDelay);
bool ShouldRetry(uint32_t& performDelay);
Result<std::chrono::seconds> GetRetryAfterHeaderTime();
void ResetResponseProperties();
// Retry metadata
chrono_clock_t::time_point m_performStartTime{};
uint32_t m_iterationNumber{ 0 };
uint32_t m_iterationNumber{ 0 };
HttpPerformInfo m_performInfo;
HC_PERFORM_ENV* m_performEnv{ nullptr }; // non-owning
};

Просмотреть файл

@ -121,7 +121,7 @@ CATCH_RETURN()
STDAPI HCHttpCallGetRequestUrl(
_In_ HCCallHandle call,
_Out_ const char** url
_Outptr_result_z_ const char** url
) noexcept
try
{

Просмотреть файл

@ -9,13 +9,13 @@
using namespace xbox::httpclient;
STDAPI
STDAPI
HCHttpCallRequestSetUrl(
_In_ HCCallHandle call,
_In_z_ const char* method,
_In_z_ const char* url
) noexcept
try
try
{
if (call == nullptr || method == nullptr || url == nullptr)
{
@ -36,11 +36,11 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetUrl(
_In_ HCCallHandle call,
_Outptr_ const char** method,
_Outptr_ const char** url
_Outptr_result_z_ const char** method,
_Outptr_result_z_ const char** url
) noexcept
try
{
@ -59,7 +59,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestSetRequestBodyBytes(
_In_ HCCallHandle call,
_In_reads_bytes_(requestBodySize) const uint8_t* requestBodyBytes,
@ -92,7 +92,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestSetRequestBodyString(
_In_ HCCallHandle call,
_In_z_ const char* requestBodyString
@ -141,13 +141,13 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetRequestBodyBytes(
_In_ HCCallHandle call,
_Outptr_result_bytebuffer_maybenull_(*requestBodySize) const uint8_t** requestBodyBytes,
_Out_ uint32_t* requestBodySize
) noexcept
try
try
{
if (call == nullptr || requestBodyBytes == nullptr || requestBodySize == nullptr)
{
@ -168,7 +168,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetRequestBodyString(
_In_ HCCallHandle call,
_Outptr_ const char** requestBody
@ -211,14 +211,14 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestSetHeader(
_In_ HCCallHandle call,
_In_z_ const char* headerName,
_In_z_ const char* headerValue,
_In_ bool allowTracing
) noexcept
try
try
{
if (call == nullptr || headerName == nullptr || headerValue == nullptr)
{
@ -233,13 +233,13 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetHeader(
_In_ HCCallHandle call,
_In_z_ const char* headerName,
_Out_ const char** headerValue
) noexcept
try
try
{
if (call == nullptr || headerName == nullptr || headerValue == nullptr)
{
@ -259,7 +259,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetNumHeaders(
_In_ HCCallHandle call,
_Out_ uint32_t* numHeaders
@ -276,7 +276,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetHeaderAtIndex(
_In_ HCCallHandle call,
_In_ uint32_t headerIndex,
@ -309,7 +309,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestSetRetryCacheId(
_In_opt_ HCCallHandle call,
_In_ uint32_t retryAfterCacheId
@ -331,7 +331,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestSetRetryAllowed(
_In_opt_ HCCallHandle call,
_In_ bool retryAllowed
@ -357,7 +357,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetRetryAllowed(
_In_opt_ HCCallHandle call,
_Out_ bool* retryAllowed
@ -385,7 +385,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetRetryCacheId(
_In_ HCCallHandle call,
_Out_ uint32_t* retryAfterCacheId
@ -404,7 +404,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestSetTimeout(
_In_opt_ HCCallHandle call,
_In_ uint32_t timeoutInSeconds
@ -431,7 +431,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetTimeout(
_In_opt_ HCCallHandle call,
_Out_ uint32_t* timeoutInSeconds
@ -460,7 +460,7 @@ try
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestSetTimeoutWindow(
_In_opt_ HCCallHandle call,
_In_ uint32_t timeoutWindowInSeconds
@ -487,7 +487,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetTimeoutWindow(
_In_opt_ HCCallHandle call,
_Out_ uint32_t* timeoutWindowInSeconds
@ -515,7 +515,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestGetRetryDelay(
_In_opt_ HCCallHandle call,
_In_ uint32_t* retryDelayInSeconds
@ -543,7 +543,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallRequestSetRetryDelay(
_In_opt_ HCCallHandle call,
_In_ uint32_t retryDelayInSeconds
@ -568,7 +568,7 @@ try
CATCH_RETURN()
#if HC_PLATFORM == HC_PLATFORM_GDK
STDAPI
STDAPI
HCHttpDisableAssertsForSSLValidationInDevSandboxes(
_In_ HCConfigSetting setting
) noexcept

Просмотреть файл

@ -51,7 +51,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseGetResponseString(
_In_ HCCallHandle call,
_Out_ const char** responseString
@ -126,11 +126,6 @@ try
return E_FAIL;
}
if (call->responseBodyBytes.size() > bufferSize)
{
return E_BOUNDS;
}
#if HC_PLATFORM_IS_MICROSOFT
memcpy_s(buffer, bufferSize, call->responseBodyBytes.data(), call->responseBodyBytes.size());
#else
@ -145,13 +140,13 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseSetResponseBodyBytes(
_In_ HCCallHandle call,
_In_reads_bytes_(bodySize) const uint8_t* bodyBytes,
_In_ size_t bodySize
) noexcept
try
try
{
if (call == nullptr || bodyBytes == nullptr)
{
@ -203,12 +198,12 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseGetStatusCode(
_In_ HCCallHandle call,
_Out_ uint32_t* statusCode
) noexcept
try
try
{
if (call == nullptr || statusCode == nullptr)
{
@ -220,12 +215,12 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseSetStatusCode(
_In_ HCCallHandle call,
_In_ uint32_t statusCode
) noexcept
try
try
{
if (call == nullptr)
{
@ -238,13 +233,13 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseGetNetworkErrorCode(
_In_ HCCallHandle call,
_Out_ HRESULT* networkErrorCode,
_Out_ uint32_t* platformNetworkErrorCode
) noexcept
try
try
{
if (call == nullptr || networkErrorCode == nullptr || platformNetworkErrorCode == nullptr)
{
@ -257,13 +252,13 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseSetNetworkErrorCode(
_In_ HCCallHandle call,
_In_ HRESULT networkErrorCode,
_In_ uint32_t platformNetworkErrorCode
) noexcept
try
try
{
if (call == nullptr)
{
@ -318,13 +313,13 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseGetHeader(
_In_ HCCallHandle call,
_In_z_ const char* headerName,
_Out_ const char** headerValue
_Outptr_result_z_ const char** headerValue
) noexcept
try
try
{
if (call == nullptr || headerName == nullptr || headerValue == nullptr)
{
@ -344,12 +339,12 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseGetNumHeaders(
_In_ HCCallHandle call,
_Out_ uint32_t* numHeaders
) noexcept
try
try
{
if (call == nullptr || numHeaders == nullptr)
{
@ -361,12 +356,12 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseGetHeaderAtIndex(
_In_ HCCallHandle call,
_In_ uint32_t headerIndex,
_Out_ const char** headerName,
_Out_ const char** headerValue
_Outptr_result_z_ const char** headerName,
_Outptr_result_z_ const char** headerValue
) noexcept
try
{
@ -394,7 +389,7 @@ try
}
CATCH_RETURN()
STDAPI
STDAPI
HCHttpCallResponseSetHeader(
_In_ HCCallHandle call,
_In_z_ const char* headerName,
@ -422,7 +417,7 @@ STDAPI HCHttpCallResponseSetHeaderWithLength(
_In_reads_(valueSize) const char* headerValue,
_In_ size_t valueSize
) noexcept
try
try
{
if (call == nullptr || headerName == nullptr || headerValue == nullptr)
{
@ -453,5 +448,3 @@ try
return S_OK;
}
CATCH_RETURN()

Просмотреть файл

@ -16,8 +16,9 @@
namespace
{
#if !HC_PLATFORM_IS_MICROSOFT
template<size_t SIZE>
int stprintf_s(char(&buffer)[SIZE], _Printf_format_string_ char const* format ...) noexcept
int sprintf_s(char(&buffer)[SIZE], _Printf_format_string_ char const* format ...) noexcept
{
va_list varArgs{};
va_start(varArgs, format);
@ -26,7 +27,7 @@ int stprintf_s(char(&buffer)[SIZE], _Printf_format_string_ char const* format ..
return result;
}
int stprintf_s(char* buffer, size_t size, _Printf_format_string_ char const* format ...) noexcept
int sprintf_s(char* buffer, size_t size, _Printf_format_string_ char const* format ...) noexcept
{
va_list varArgs{};
va_start(varArgs, format);
@ -36,10 +37,11 @@ int stprintf_s(char* buffer, size_t size, _Printf_format_string_ char const* for
}
template<size_t SIZE>
int vstprintf_s(char(&buffer)[SIZE], _Printf_format_string_ char const* format, va_list varArgs) noexcept
int vsprintf_s(char(&buffer)[SIZE], _Printf_format_string_ char const* format, va_list varArgs) noexcept
{
return vsnprintf(buffer, SIZE, format, varArgs);
}
#endif
//------------------------------------------------------------------------------
// Trace implementation
@ -81,7 +83,7 @@ void TraceMessageToDebugger(
char outputBuffer[BUFFER_SIZE] = {};
// [threadId][level][time][area] message
auto written = stprintf_s(outputBuffer, "[%04llX][%s][%02d:%02d:%02d.%03u][%s] %s",
auto written = sprintf_s(outputBuffer, "[%04llX][%s][%02d:%02d:%02d.%03u][%s] %s",
threadId,
traceLevelNames[static_cast<size_t>(level)],
fmtTime.tm_hour,
@ -101,7 +103,7 @@ void TraceMessageToDebugger(
auto remaining = BUFFER_SIZE - written;
// Print new line
auto written2 = stprintf_s(outputBuffer + written, remaining, "\r\n");
auto written2 = sprintf_s(outputBuffer + written, remaining, "\r\n");
if (written2 <= 0)
{
return;
@ -188,7 +190,7 @@ STDAPI_(void) HCTraceImplMessage_v(
char message[4096] = {};
auto result = vstprintf_s(message, format, varArgs);
auto result = vsprintf_s(message, format, varArgs);
if (result < 0)
{