From 20a685d62fa5e0418a6987f2e2c4559093791ee6 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Fri, 17 Jan 2020 12:20:39 -0800 Subject: [PATCH] Minor code review --- DirectXTex/DirectXTexUtil.cpp | 7 +++++-- ScreenGrab/ScreenGrab.cpp | 7 +++++-- ScreenGrab/ScreenGrab12.cpp | 7 +++++-- WICTextureLoader/WICTextureLoader.cpp | 7 +++++-- WICTextureLoader/WICTextureLoader12.cpp | 7 +++++-- 5 files changed, 25 insertions(+), 10 deletions(-) diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index fbd53f7..ffc347b 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -277,10 +277,13 @@ IWICImagingFactory* DirectX::GetWICFactory(bool& iswic2) noexcept static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; - InitOnceExecuteOnce(&s_initOnce, + if (!InitOnceExecuteOnce(&s_initOnce, InitializeWICFactory, nullptr, - reinterpret_cast(&g_Factory)); + reinterpret_cast(&g_Factory))) + { + return nullptr; + } iswic2 = g_WIC2; return g_Factory; diff --git a/ScreenGrab/ScreenGrab.cpp b/ScreenGrab/ScreenGrab.cpp index df74a7a..78bf6e8 100644 --- a/ScreenGrab/ScreenGrab.cpp +++ b/ScreenGrab/ScreenGrab.cpp @@ -751,10 +751,13 @@ namespace static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; IWICImagingFactory* factory = nullptr; - InitOnceExecuteOnce(&s_initOnce, + if (!InitOnceExecuteOnce(&s_initOnce, InitializeWICFactory, nullptr, - reinterpret_cast(&factory)); + reinterpret_cast(&factory))) + { + return nullptr; + } return factory; } diff --git a/ScreenGrab/ScreenGrab12.cpp b/ScreenGrab/ScreenGrab12.cpp index 8aaa5de..c977229 100644 --- a/ScreenGrab/ScreenGrab12.cpp +++ b/ScreenGrab/ScreenGrab12.cpp @@ -828,10 +828,13 @@ namespace static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; IWICImagingFactory2* factory = nullptr; - (void)InitOnceExecuteOnce(&s_initOnce, + if (!InitOnceExecuteOnce(&s_initOnce, InitializeWICFactory, nullptr, - reinterpret_cast(&factory)); + reinterpret_cast(&factory))) + { + return nullptr; + } return factory; } diff --git a/WICTextureLoader/WICTextureLoader.cpp b/WICTextureLoader/WICTextureLoader.cpp index 240700c..5e256d7 100644 --- a/WICTextureLoader/WICTextureLoader.cpp +++ b/WICTextureLoader/WICTextureLoader.cpp @@ -208,10 +208,13 @@ namespace static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; IWICImagingFactory* factory = nullptr; - (void)InitOnceExecuteOnce(&s_initOnce, + if (!InitOnceExecuteOnce(&s_initOnce, InitializeWICFactory, nullptr, - reinterpret_cast(&factory)); + reinterpret_cast(&factory))) + { + return nullptr; + } return factory; } diff --git a/WICTextureLoader/WICTextureLoader12.cpp b/WICTextureLoader/WICTextureLoader12.cpp index 45cb828..0b86bd8 100644 --- a/WICTextureLoader/WICTextureLoader12.cpp +++ b/WICTextureLoader/WICTextureLoader12.cpp @@ -166,10 +166,13 @@ namespace static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT; IWICImagingFactory2* factory = nullptr; - (void)InitOnceExecuteOnce(&s_initOnce, + if (!InitOnceExecuteOnce(&s_initOnce, InitializeWICFactory, nullptr, - reinterpret_cast(&factory)); + reinterpret_cast(&factory))) + { + return nullptr; + } return factory; }