Skip to content

Commit

Permalink
Squash to reset history (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
dunhor committed Jun 29, 2023
1 parent c5e995e commit 55f373e
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 87 deletions.
28 changes: 14 additions & 14 deletions include/wil/Tracelogging.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,18 +239,18 @@ namespace wil
class StoredCallContextInfo : public wil::CallContextInfo
{
public:
StoredCallContextInfo()
StoredCallContextInfo() WI_NOEXCEPT
{
::ZeroMemory(this, sizeof(*this));
}

StoredCallContextInfo(StoredCallContextInfo &&other) :
StoredCallContextInfo(StoredCallContextInfo &&other) WI_NOEXCEPT :
StoredCallContextInfo()
{
operator=(wistd::move(other));
}

StoredCallContextInfo& operator=(StoredCallContextInfo &&other)
StoredCallContextInfo& operator=(StoredCallContextInfo &&other) WI_NOEXCEPT
{
contextId = other.contextId;
contextName = other.contextName;
Expand All @@ -262,7 +262,7 @@ namespace wil
return *this;
}

StoredCallContextInfo(StoredCallContextInfo const &other) :
StoredCallContextInfo(StoredCallContextInfo const &other) WI_NOEXCEPT :
m_ownsMessage(false)
{
contextId = other.contextId;
Expand All @@ -277,15 +277,15 @@ namespace wil
}
}

StoredCallContextInfo(_In_opt_ PCSTR staticContextName) :
StoredCallContextInfo(_In_opt_ PCSTR staticContextName) WI_NOEXCEPT :
m_ownsMessage(false)
{
contextId = 0;
contextName = staticContextName;
contextMessage = nullptr;
}

StoredCallContextInfo(PCSTR staticContextName, _Printf_format_string_ PCSTR formatString, va_list argList) :
StoredCallContextInfo(PCSTR staticContextName, _Printf_format_string_ PCSTR formatString, va_list argList) WI_NOEXCEPT :
StoredCallContextInfo(staticContextName)
{
SetMessage(formatString, argList);
Expand Down Expand Up @@ -581,9 +581,9 @@ namespace wil
Initialize();
}

TraceLoggingHProvider m_providerHandle;
bool m_ownsProviderHandle;
ErrorReportingType m_errorReportingType;
TraceLoggingHProvider m_providerHandle{};
bool m_ownsProviderHandle{};
ErrorReportingType m_errorReportingType{};
};

template<
Expand Down Expand Up @@ -1389,10 +1389,10 @@ namespace wil

#define __IMPLEMENT_CALLCONTEXT_CLASS(ActivityClassName) \
protected: \
ActivityClassName(_In_ void **, PCSTR contextName, _In_opt_ _Printf_format_string_ PCSTR formatString, _In_opt_ va_list argList) : \
ActivityClassName(_In_opt_ void **, PCSTR contextName, _In_opt_ _Printf_format_string_ PCSTR formatString, _In_opt_ va_list argList) : \
ActivityBase(contextName) \
{ GetCallContext()->SetMessage(formatString, argList); StartActivity(); } \
ActivityClassName(_In_ void **, PCSTR contextName) : \
ActivityClassName(_In_opt_ void **, PCSTR contextName) : \
ActivityBase(contextName) \
{ StartActivity(); } \
public: \
Expand Down Expand Up @@ -3315,8 +3315,8 @@ namespace wil
if (m_fireEventThreadPoolTimer && !ProcessShutdownInProgress())
{
// Note this will override any pending scheduled callback
FILETIME dueTime;
*reinterpret_cast<PLONGLONG>(&dueTime) = -static_cast<LONGLONG>(m_fireEventDelay * 10000);
FILETIME dueTime{};
*reinterpret_cast<PLONGLONG>(&dueTime) = -static_cast<LONGLONG>(m_fireEventDelay) * 10000;
SetThreadpoolTimer(m_fireEventThreadPoolTimer.get(), &dueTime, 0, 0);
}
}
Expand All @@ -3325,7 +3325,7 @@ namespace wil
wil::unique_threadpool_timer m_fireEventThreadPoolTimer;

// The timer used to determine when to fire the next telemetry event (when it's fired based on a timer).
UINT m_fireEventDelay;
UINT m_fireEventDelay{};
DWORD const c_fireEventDelayLimit = 20 * 60 * 1000; // 20 minutes
};
} // namespace details
Expand Down
6 changes: 3 additions & 3 deletions include/wil/com.h
Original file line number Diff line number Diff line change
Expand Up @@ -2275,7 +2275,7 @@ namespace wil
*/
inline HRESULT stream_seek_nothrow(_In_ IStream* stream, long long offset, unsigned long from, _Out_opt_ unsigned long long* value = nullptr)
{
LARGE_INTEGER amount;
LARGE_INTEGER amount{};
ULARGE_INTEGER landed{};
amount.QuadPart = offset;
RETURN_IF_FAILED(stream->Seek(amount, from, value ? &landed : nullptr));
Expand Down Expand Up @@ -2360,8 +2360,8 @@ namespace wil
*/
inline HRESULT stream_copy_bytes_nothrow(_In_ IStream* source, _In_ IStream* target, unsigned long long amount, _Out_opt_ unsigned long long* pCopied = nullptr)
{
ULARGE_INTEGER toCopy;
ULARGE_INTEGER copied;
ULARGE_INTEGER toCopy{};
ULARGE_INTEGER copied{};
toCopy.QuadPart = amount;
RETURN_IF_FAILED(source->CopyTo(target, toCopy, nullptr, &copied));
assign_to_opt_param(pCopied, copied.QuadPart);
Expand Down
20 changes: 10 additions & 10 deletions include/wil/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace wil
// If there is a trailing slash ignore that in the search.
auto const limitedLength = ((pathLength > 0) && (path[pathLength - 1] == L'\\')) ? (pathLength - 1) : pathLength;

PCWSTR result;
PCWSTR result = nullptr;
auto const offset = FindStringOrdinal(FIND_FROMEND, path, static_cast<int>(limitedLength), L"\\", 1, TRUE);
if (offset == -1)
{
Expand Down Expand Up @@ -97,7 +97,7 @@ namespace wil
{
*parentPathLength = 0;
bool hasParent = false;
PCWSTR rootEnd;
PCWSTR rootEnd = nullptr;
if (SUCCEEDED(PathCchSkipRoot(path, &rootEnd)) && (*rootEnd != L'\0'))
{
auto const lastSegment = find_last_path_segment(path);
Expand All @@ -116,7 +116,7 @@ namespace wil
DWORD lastError = ::GetLastError();
if (lastError == ERROR_PATH_NOT_FOUND)
{
size_t parentLength;
size_t parentLength{};
if (try_get_parent_path_range(path, &parentLength))
{
wistd::unique_ptr<wchar_t[]> parent(new (std::nothrow) wchar_t[parentLength + 1]);
Expand Down Expand Up @@ -183,7 +183,7 @@ namespace wil
template <typename string_type = wil::unique_cotaskmem_string, size_t stackBufferLength = 256>
string_type GetFullPathNameW(PCWSTR file, _Outptr_opt_ PCWSTR* filePart = nullptr)
{
string_type result;
string_type result{};
THROW_IF_FAILED((GetFullPathNameW<string_type, stackBufferLength>(file, result, filePart)));
return result;
}
Expand Down Expand Up @@ -216,7 +216,7 @@ namespace wil
nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT, nullptr));
if (result)
{
FILE_ATTRIBUTE_TAG_INFO fati;
FILE_ATTRIBUTE_TAG_INFO fati{};
if (GetFileInformationByHandleEx(result.get(), FileAttributeTagInfo, &fati, sizeof(fati)) &&
details::CanRecurseIntoDirectory(fati))
{
Expand Down Expand Up @@ -261,7 +261,7 @@ namespace wil
wil::unique_hlocal_string searchPath;
RETURN_IF_FAILED(::PathAllocCombine(path.get(), L"*", combineOptions, &searchPath));

WIN32_FIND_DATAW fd;
WIN32_FIND_DATAW fd{};
wil::unique_hfind findHandle(::FindFirstFileW(searchPath.get(), &fd));
RETURN_LAST_ERROR_IF(!findHandle);

Expand Down Expand Up @@ -668,7 +668,7 @@ namespace wil
OVERLAPPED m_overlapped{};
TP_IO *m_tpIo = __nullptr;
srwlock m_cancelLock;
unsigned char m_readBuffer[4096]; // Consider alternative buffer sizes. With 512 byte buffer i was not able to observe overflow.
unsigned char m_readBuffer[4096]{}; // Consider alternative buffer sizes. With 512 byte buffer i was not able to observe overflow.
};

inline void delete_folder_change_reader_state(_In_opt_ folder_change_reader_state *storage) { delete storage; }
Expand Down Expand Up @@ -830,7 +830,7 @@ namespace wil
string_type GetFinalPathNameByHandleW(HANDLE fileHandle,
wil::VolumePrefix volumePrefix = wil::VolumePrefix::Dos, wil::PathOptions options = wil::PathOptions::Normalized)
{
string_type result;
string_type result{};
THROW_IF_FAILED((GetFinalPathNameByHandleW<string_type, stackBufferLength>(fileHandle, result, volumePrefix, options)));
return result;
}
Expand Down Expand Up @@ -861,7 +861,7 @@ namespace wil
template <typename string_type = wil::unique_cotaskmem_string, size_t stackBufferLength = 256>
string_type GetCurrentDirectoryW()
{
string_type result;
string_type result{};
THROW_IF_FAILED((GetCurrentDirectoryW<string_type, stackBufferLength>(result)));
return result;
}
Expand Down Expand Up @@ -1026,7 +1026,7 @@ namespace wil
template <FILE_INFO_BY_HANDLE_CLASS infoClass, typename wistd::enable_if<details::MapInfoClassToInfoStruct<infoClass>::isFixed, int>::type = 0>
typename details::MapInfoClassToInfoStruct<infoClass>::type GetFileInfo(HANDLE fileHandle)
{
typename details::MapInfoClassToInfoStruct<infoClass>::type result;
typename details::MapInfoClassToInfoStruct<infoClass>::type result{};
THROW_IF_FAILED(GetFileInfoNoThrow<infoClass>(fileHandle, &result));
return result;
}
Expand Down
28 changes: 14 additions & 14 deletions include/wil/registry.h
Original file line number Diff line number Diff line change
Expand Up @@ -1633,11 +1633,11 @@ namespace wil
{
#if defined(__WIL_OLEAUTO_H_)
// not allowing unique types with try_get_value: wil::unique_bstr cannot be copied and thus is difficult to work with a std::optional
static_assert(!std::is_same_v<T, ::wil::unique_bstr>, "try_get with wil::unique_bstr is disabled");
static_assert(!wistd::is_same_v<T, ::wil::unique_bstr>, "try_get with wil::unique_bstr is disabled");
#endif // #if defined(__WIL_OLEAUTO_H_)
#if defined(__WIL_OBJBASE_H_)
// not allowing unique types with try_get_value: wil::unique_cotaskmem_string cannot be copied and thus is difficult to work with a std::optional
static_assert(!std::is_same_v<T, ::wil::unique_cotaskmem_string>, "try_get with wil::unique_cotaskmem_string is disabled");
static_assert(!wistd::is_same_v<T, ::wil::unique_cotaskmem_string>, "try_get with wil::unique_cotaskmem_string is disabled");
#endif // #if defined(__WIL_OBJBASE_H_)

const reg_view_details::reg_view regview{ key };
Expand All @@ -1659,11 +1659,11 @@ namespace wil
{
#if defined(__WIL_OLEAUTO_H_)
// not allowing unique types with try_get_value: wil::unique_bstr cannot be copied and thus is difficult to work with a std::optional
static_assert(!std::is_same_v<T, ::wil::unique_bstr>, "try_get with wil::unique_bstr is disabled");
static_assert(!wistd::is_same_v<T, ::wil::unique_bstr>, "try_get with wil::unique_bstr is disabled");
#endif // #if defined(__WIL_OLEAUTO_H_)
#if defined(__WIL_OBJBASE_H_)
// not allowing unique types with try_get_value: wil::unique_cotaskmem_string cannot be copied and thus is difficult to work with a std::optional
static_assert(!std::is_same_v<T, ::wil::unique_cotaskmem_string>, "try_get with wil::unique_cotaskmem_string is disabled");
static_assert(!wistd::is_same_v<T, ::wil::unique_cotaskmem_string>, "try_get with wil::unique_cotaskmem_string is disabled");
#endif // #if defined(__WIL_OBJBASE_H_)

return ::wil::reg::try_get_value<T>(key, nullptr, value_name);
Expand Down Expand Up @@ -2195,7 +2195,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <typename T,
std::enable_if_t<!std::is_same_v<T, wchar_t>>* = nullptr>
wistd::enable_if_t<!wistd::is_same_v<T, wchar_t>>* = nullptr>
HRESULT get_value_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, _Out_ T* return_value) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
Expand All @@ -2212,7 +2212,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <typename T,
std::enable_if_t<!std::is_same_v<T, wchar_t>>* = nullptr>
wistd::enable_if_t<!wistd::is_same_v<T, wchar_t>>* = nullptr>
HRESULT get_value_nothrow(HKEY key, _In_opt_ PCWSTR value_name, _Out_ T* return_value) WI_NOEXCEPT
{
return ::wil::reg::get_value_nothrow(key, nullptr, value_name, return_value);
Expand All @@ -2232,7 +2232,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <size_t Length, typename DwordType,
std::enable_if_t<std::is_same_v<DwordType, uint32_t> || std::is_same_v<DwordType, unsigned long>>* = nullptr>
wistd::enable_if_t<wistd::is_same_v<DwordType, uint32_t> || wistd::is_same_v<DwordType, unsigned long>>* = nullptr>
HRESULT get_value_string_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, WCHAR(&return_value)[Length], _Out_opt_ DwordType * requiredBytes) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
Expand All @@ -2251,7 +2251,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <size_t Length, typename DwordType,
std::enable_if_t<std::is_same_v<DwordType, uint32_t> || std::is_same_v<DwordType, unsigned long>>* = nullptr>
wistd::enable_if_t<wistd::is_same_v<DwordType, uint32_t> || wistd::is_same_v<DwordType, unsigned long>>* = nullptr>
HRESULT get_value_string_nothrow(HKEY key, _In_opt_ PCWSTR value_name, WCHAR(&return_value)[Length], _Out_opt_ DwordType * requiredBytes) WI_NOEXCEPT
{
return ::wil::reg::get_value_string_nothrow<Length>(key, nullptr, value_name, return_value, requiredBytes);
Expand Down Expand Up @@ -2338,7 +2338,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <typename DwordType,
std::enable_if_t<std::is_same_v<DwordType, uint32_t> || std::is_same_v<DwordType, unsigned long>>* = nullptr>
wistd::enable_if_t<wistd::is_same_v<DwordType, uint32_t> || wistd::is_same_v<DwordType, unsigned long>>* = nullptr>
HRESULT get_value_dword_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, _Out_ DwordType * return_value) WI_NOEXCEPT
{
return ::wil::reg::get_value_nothrow(key, subkey, value_name, return_value);
Expand All @@ -2353,7 +2353,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <typename DwordType,
std::enable_if_t<std::is_same_v<DwordType, uint32_t> || std::is_same_v<DwordType, unsigned long>>* = nullptr>
wistd::enable_if_t<wistd::is_same_v<DwordType, uint32_t> || wistd::is_same_v<DwordType, unsigned long>>* = nullptr>
HRESULT get_value_dword_nothrow(HKEY key, _In_opt_ PCWSTR value_name, _Out_ DwordType * return_value) WI_NOEXCEPT
{
return ::wil::reg::get_value_nothrow(key, nullptr, value_name, return_value);
Expand All @@ -2370,7 +2370,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <typename QwordType,
std::enable_if_t<std::is_same_v<QwordType, uint64_t> || std::is_same_v<QwordType, unsigned long long>>* = nullptr>
wistd::enable_if_t<wistd::is_same_v<QwordType, uint64_t> || wistd::is_same_v<QwordType, unsigned long long>>* = nullptr>
HRESULT get_value_qword_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, _Out_ QwordType * return_value) WI_NOEXCEPT
{
return ::wil::reg::get_value_nothrow(key, subkey, value_name, return_value);
Expand All @@ -2385,7 +2385,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <typename QwordType,
std::enable_if_t<std::is_same_v<QwordType, uint64_t> || std::is_same_v<QwordType, unsigned long long>>* = nullptr>
wistd::enable_if_t<wistd::is_same_v<QwordType, uint64_t> || wistd::is_same_v<QwordType, unsigned long long>>* = nullptr>
HRESULT get_value_qword_nothrow(HKEY key, _In_opt_ PCWSTR value_name, _Out_ QwordType * return_value) WI_NOEXCEPT
{
return ::wil::reg::get_value_nothrow(key, nullptr, value_name, return_value);
Expand Down Expand Up @@ -2683,7 +2683,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <size_t Length, typename DwordType,
std::enable_if_t<std::is_same_v<DwordType, uint32_t> || std::is_same_v<DwordType, unsigned long>>* = nullptr>
wistd::enable_if_t<wistd::is_same_v<DwordType, uint32_t> || wistd::is_same_v<DwordType, unsigned long>>* = nullptr>
HRESULT get_value_expanded_string_nothrow(HKEY key, _In_opt_ PCWSTR subkey, _In_opt_ PCWSTR value_name, WCHAR(&return_value)[Length], _Out_opt_ DwordType * requiredBytes) WI_NOEXCEPT
{
const reg_view_details::reg_view_nothrow regview{ key };
Expand All @@ -2703,7 +2703,7 @@ namespace wil
* \return HRESULT error code indicating success or failure (does not throw C++ exceptions)
*/
template <size_t Length, typename DwordType,
std::enable_if_t<std::is_same_v<DwordType, uint32_t> || std::is_same_v<DwordType, unsigned long>>* = nullptr>
wistd::enable_if_t<wistd::is_same_v<DwordType, uint32_t> || wistd::is_same_v<DwordType, unsigned long>>* = nullptr>
HRESULT get_value_expanded_string_nothrow(HKEY key, _In_opt_ PCWSTR value_name, WCHAR(&return_value)[Length], _Out_opt_ DwordType * requiredBytes) WI_NOEXCEPT
{
return ::wil::reg::get_value_expanded_string_nothrow<Length>(key, nullptr, value_name, return_value, requiredBytes);
Expand Down
Loading

0 comments on commit 55f373e

Please sign in to comment.