From 1363046e2b6a501fe8603890e2fe97d513d8e070 Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Sun, 17 Oct 2021 11:57:07 -0700 Subject: [PATCH] std::ignore usage instead of (void) for ignoring return values --- DirectXTex/DirectXTexP.h | 1 + DirectXTex/DirectXTexWIC.cpp | 26 ++++++++++++------------- DirectXTex/scoped.h | 3 ++- ScreenGrab/ScreenGrab11.cpp | 17 ++++++++-------- ScreenGrab/ScreenGrab12.cpp | 17 ++++++++-------- ScreenGrab/ScreenGrab9.cpp | 9 +++++---- Texassemble/texassemble.cpp | 9 +++++---- Texconv/PortablePixMap.cpp | 2 +- Texconv/texconv.cpp | 15 +++++++------- Texdiag/texdiag.cpp | 5 +++-- WICTextureLoader/WICTextureLoader11.cpp | 3 ++- WICTextureLoader/WICTextureLoader12.cpp | 3 ++- 12 files changed, 60 insertions(+), 50 deletions(-) diff --git a/DirectXTex/DirectXTexP.h b/DirectXTex/DirectXTexP.h index 40396c8..24e426a 100644 --- a/DirectXTex/DirectXTexP.h +++ b/DirectXTex/DirectXTexP.h @@ -130,6 +130,7 @@ #include #include #include +#include #ifndef WIN32 #include diff --git a/DirectXTex/DirectXTexWIC.cpp b/DirectXTex/DirectXTexWIC.cpp index 94f92f3..cabf63f 100644 --- a/DirectXTex/DirectXTexWIC.cpp +++ b/DirectXTex/DirectXTexWIC.cpp @@ -390,7 +390,7 @@ namespace return E_NOTIMPL; } - HRESULT STDMETHODCALLTYPE Revert(void) override + HRESULT STDMETHODCALLTYPE Revert() override { return E_NOTIMPL; } @@ -635,7 +635,7 @@ namespace } #endif - (void)PropVariantClear(&value); + std::ignore = PropVariantClear(&value); if (sRGB) metadata.format = MakeSRGB(metadata.format); @@ -889,65 +889,65 @@ namespace if (memcmp(&containerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) { // Set Software name - (void)metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); + std::ignore = metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); // Set sRGB chunk if (sRGB) { value.vt = VT_UI1; value.bVal = 0; - (void)metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); + std::ignore = metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); } else { // add gAMA chunk with gamma 1.0 value.vt = VT_UI4; value.uintVal = 100000; // gama value * 100,000 -- i.e. gamma 1.0 - (void)metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); + std::ignore = metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); // remove sRGB chunk which is added by default. - (void)metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); + std::ignore = metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); } } #if (defined(_XBOX_ONE) && defined(_TITLE)) || defined(_GAMING_XBOX) else if (memcmp(&containerFormat, &GUID_ContainerFormatJpeg, sizeof(GUID)) == 0) { // Set Software name - (void)metawriter->SetMetadataByName(L"/app1/ifd/{ushort=305}", &value); + std::ignore = metawriter->SetMetadataByName(L"/app1/ifd/{ushort=305}", &value); if (sRGB) { // Set EXIF Colorspace of sRGB value.vt = VT_UI2; value.uiVal = 1; - (void)metawriter->SetMetadataByName(L"/app1/ifd/exif/{ushort=40961}", &value); + std::ignore = metawriter->SetMetadataByName(L"/app1/ifd/exif/{ushort=40961}", &value); } } else if (memcmp(&containerFormat, &GUID_ContainerFormatTiff, sizeof(GUID)) == 0) { // Set Software name - (void)metawriter->SetMetadataByName(L"/ifd/{ushort=305}", &value); + std::ignore = metawriter->SetMetadataByName(L"/ifd/{ushort=305}", &value); if (sRGB) { // Set EXIF Colorspace of sRGB value.vt = VT_UI2; value.uiVal = 1; - (void)metawriter->SetMetadataByName(L"/ifd/exif/{ushort=40961}", &value); + std::ignore = metawriter->SetMetadataByName(L"/ifd/exif/{ushort=40961}", &value); } } #else else { // Set Software name - (void)metawriter->SetMetadataByName(L"System.ApplicationName", &value); + std::ignore = metawriter->SetMetadataByName(L"System.ApplicationName", &value); if (sRGB) { // Set EXIF Colorspace of sRGB value.vt = VT_UI2; value.uiVal = 1; - (void)metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); + std::ignore = metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); } } #endif @@ -1109,7 +1109,7 @@ namespace VARIANT varValue; varValue.vt = VT_BOOL; varValue.boolVal = VARIANT_TRUE; - (void)props->Write(1, &option, &varValue); + std::ignore = props->Write(1, &option, &varValue); } if (setCustomProps) diff --git a/DirectXTex/scoped.h b/DirectXTex/scoped.h index 20dd23d..d8f768c 100644 --- a/DirectXTex/scoped.h +++ b/DirectXTex/scoped.h @@ -13,6 +13,7 @@ #include #include #include +#include #ifndef WIN32 #include @@ -98,7 +99,7 @@ public: { FILE_DISPOSITION_INFO info = {}; info.DeleteFile = TRUE; - (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); + std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); } } diff --git a/ScreenGrab/ScreenGrab11.cpp b/ScreenGrab/ScreenGrab11.cpp index a9a63d1..cc561c2 100644 --- a/ScreenGrab/ScreenGrab11.cpp +++ b/ScreenGrab/ScreenGrab11.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -212,7 +213,7 @@ namespace { FILE_DISPOSITION_INFO info = {}; info.DeleteFile = TRUE; - (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); + std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); } } @@ -1049,7 +1050,7 @@ HRESULT DirectX::SaveWICTextureToFile( VARIANT varValue; varValue.vt = VT_BOOL; varValue.boolVal = VARIANT_TRUE; - (void)props->Write(1, &option, &varValue); + std::ignore = props->Write(1, &option, &varValue); } if (setCustomProps) @@ -1135,37 +1136,37 @@ HRESULT DirectX::SaveWICTextureToFile( if (memcmp(&guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) { // Set Software name - (void)metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); + std::ignore = metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); // Set sRGB chunk if (sRGB) { value.vt = VT_UI1; value.bVal = 0; - (void)metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); + std::ignore = metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); } else { // add gAMA chunk with gamma 1.0 value.vt = VT_UI4; value.uintVal = 100000; // gama value * 100,000 -- i.e. gamma 1.0 - (void)metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); + std::ignore = metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); // remove sRGB chunk which is added by default. - (void)metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); + std::ignore = metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); } } else { // Set Software name - (void)metawriter->SetMetadataByName(L"System.ApplicationName", &value); + std::ignore = metawriter->SetMetadataByName(L"System.ApplicationName", &value); if (sRGB) { // Set EXIF Colorspace of sRGB value.vt = VT_UI2; value.uiVal = 1; - (void)metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); + std::ignore = metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); } } } diff --git a/ScreenGrab/ScreenGrab12.cpp b/ScreenGrab/ScreenGrab12.cpp index 7fafd03..71d99b2 100644 --- a/ScreenGrab/ScreenGrab12.cpp +++ b/ScreenGrab/ScreenGrab12.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #ifdef WIN32 #include @@ -234,7 +235,7 @@ namespace { FILE_DISPOSITION_INFO info = {}; info.DeleteFile = TRUE; - (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); + std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); } } @@ -1226,7 +1227,7 @@ HRESULT DirectX::SaveWICTextureToFile( VARIANT varValue; varValue.vt = VT_BOOL; varValue.boolVal = VARIANT_TRUE; - (void)props->Write(1, &option, &varValue); + std::ignore = props->Write(1, &option, &varValue); } if (setCustomProps) @@ -1303,37 +1304,37 @@ HRESULT DirectX::SaveWICTextureToFile( if (memcmp(&guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) { // Set Software name - (void)metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); + std::ignore = metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); // Set sRGB chunk if (sRGB) { value.vt = VT_UI1; value.bVal = 0; - (void)metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); + std::ignore = metawriter->SetMetadataByName(L"/sRGB/RenderingIntent", &value); } else { // add gAMA chunk with gamma 1.0 value.vt = VT_UI4; value.uintVal = 100000; // gama value * 100,000 -- i.e. gamma 1.0 - (void)metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); + std::ignore = metawriter->SetMetadataByName(L"/gAMA/ImageGamma", &value); // remove sRGB chunk which is added by default. - (void)metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); + std::ignore = metawriter->RemoveMetadataByName(L"/sRGB/RenderingIntent"); } } else { // Set Software name - (void)metawriter->SetMetadataByName(L"System.ApplicationName", &value); + std::ignore = metawriter->SetMetadataByName(L"System.ApplicationName", &value); if (sRGB) { // Set EXIF Colorspace of sRGB value.vt = VT_UI2; value.uiVal = 1; - (void)metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); + std::ignore = metawriter->SetMetadataByName(L"System.Image.ColorSpace", &value); } } } diff --git a/ScreenGrab/ScreenGrab9.cpp b/ScreenGrab/ScreenGrab9.cpp index 455c3d2..1974d21 100644 --- a/ScreenGrab/ScreenGrab9.cpp +++ b/ScreenGrab/ScreenGrab9.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include @@ -225,7 +226,7 @@ namespace { FILE_DISPOSITION_INFO info = {}; info.DeleteFile = TRUE; - (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); + std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); } } @@ -831,7 +832,7 @@ HRESULT DirectX::SaveWICTextureToFile( VARIANT varValue; varValue.vt = VT_BOOL; varValue.boolVal = VARIANT_TRUE; - (void)props->Write(1, &option, &varValue); + std::ignore = props->Write(1, &option, &varValue); } if (setCustomProps) @@ -923,12 +924,12 @@ HRESULT DirectX::SaveWICTextureToFile( if (memcmp(&guidContainerFormat, &GUID_ContainerFormatPng, sizeof(GUID)) == 0) { // Set Software name - (void)metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); + std::ignore = metawriter->SetMetadataByName(L"/tEXt/{str=Software}", &value); } else { // Set Software name - (void)metawriter->SetMetadataByName(L"System.ApplicationName", &value); + std::ignore = metawriter->SetMetadataByName(L"System.ApplicationName", &value); } } diff --git a/Texassemble/texassemble.cpp b/Texassemble/texassemble.cpp index 4fe814f..45d1824 100644 --- a/Texassemble/texassemble.cpp +++ b/Texassemble/texassemble.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -1980,7 +1981,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (dwOptions & (1 << OPT_TOLOWER)) { - (void)_wcslwr_s(szOutputFile); + std::ignore = _wcslwr_s(szOutputFile); } if (~dwOptions & (1 << OPT_OVERWRITE)) @@ -2048,7 +2049,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (dwOptions & (1 << OPT_TOLOWER)) { - (void)_wcslwr_s(szOutputFile); + std::ignore = _wcslwr_s(szOutputFile); } if (~dwOptions & (1 << OPT_OVERWRITE)) @@ -2119,7 +2120,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (dwOptions & (1 << OPT_TOLOWER)) { - (void)_wcslwr_s(szOutputFile); + std::ignore = _wcslwr_s(szOutputFile); } if (~dwOptions & (1 << OPT_OVERWRITE)) @@ -2229,7 +2230,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (dwOptions & (1 << OPT_TOLOWER)) { - (void)_wcslwr_s(szOutputFile); + std::ignore = _wcslwr_s(szOutputFile); } if (~dwOptions & (1 << OPT_OVERWRITE)) diff --git a/Texconv/PortablePixMap.cpp b/Texconv/PortablePixMap.cpp index 847523b..5bcae2d 100644 --- a/Texconv/PortablePixMap.cpp +++ b/Texconv/PortablePixMap.cpp @@ -52,7 +52,7 @@ namespace { FILE_DISPOSITION_INFO info = {}; info.DeleteFile = TRUE; - (void)SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); + std::ignore = SetFileInformationByHandle(m_handle, FileDispositionInfo, &info, sizeof(info)); } } diff --git a/Texconv/texconv.cpp b/Texconv/texconv.cpp index 0f6ece1..8388809 100644 --- a/Texconv/texconv.cpp +++ b/Texconv/texconv.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include @@ -1958,10 +1959,10 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) } LARGE_INTEGER qpcFreq = {}; - (void)QueryPerformanceFrequency(&qpcFreq); + std::ignore = QueryPerformanceFrequency(&qpcFreq); LARGE_INTEGER qpcStart = {}; - (void)QueryPerformanceCounter(&qpcStart); + std::ignore = QueryPerformanceCounter(&qpcStart); // Convert images bool sizewarn = false; @@ -3549,7 +3550,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (dwOptions & (uint64_t(1) << OPT_TOLOWER)) { - (void)_wcslwr_s(szDest); + std::ignore = _wcslwr_s(szDest); } if (wcslen(szDest) > _MAX_PATH) @@ -3632,7 +3633,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) options.pstrName = const_cast(L"ImageQuality"); varValues.vt = VT_R4; varValues.fltVal = (wicLossless) ? 1.f : wicQuality; - (void)props->Write(1, &options, &varValues); + std::ignore = props->Write(1, &options, &varValues); } break; @@ -3652,7 +3653,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) varValues.vt = VT_R4; varValues.fltVal = wicQuality; } - (void)props->Write(1, &options, &varValues); + std::ignore = props->Write(1, &options, &varValues); } break; @@ -3674,7 +3675,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) varValues.vt = VT_R4; varValues.fltVal = wicQuality; } - (void)props->Write(1, &options, &varValues); + std::ignore = props->Write(1, &options, &varValues); } break; } @@ -3710,7 +3711,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (dwOptions & (uint64_t(1) << OPT_TIMING)) { LARGE_INTEGER qpcEnd = {}; - (void)QueryPerformanceCounter(&qpcEnd); + std::ignore = QueryPerformanceCounter(&qpcEnd); LONGLONG delta = qpcEnd.QuadPart - qpcStart.QuadPart; wprintf(L"\n Processing time: %f seconds\n", double(delta) / double(qpcFreq.QuadPart)); diff --git a/Texdiag/texdiag.cpp b/Texdiag/texdiag.cpp index 1a0f428..5b13a9d 100644 --- a/Texdiag/texdiag.cpp +++ b/Texdiag/texdiag.cpp @@ -32,9 +32,10 @@ #include #include #include +#include #include #include -#include +#include #include #include @@ -3549,7 +3550,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[]) if (dwOptions & (1 << OPT_TOLOWER)) { - (void)_wcslwr_s(szOutputFile); + std::ignore = _wcslwr_s(szOutputFile); } if (~dwOptions & (1 << OPT_OVERWRITE)) diff --git a/WICTextureLoader/WICTextureLoader11.cpp b/WICTextureLoader/WICTextureLoader11.cpp index 00505a4..3e09d3f 100644 --- a/WICTextureLoader/WICTextureLoader11.cpp +++ b/WICTextureLoader/WICTextureLoader11.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #ifdef __clang__ #pragma clang diagnostic ignored "-Wcovered-switch-default" @@ -557,7 +558,7 @@ namespace sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; } - (void)PropVariantClear(&value); + std::ignore = PropVariantClear(&value); if (sRGB) format = MakeSRGB(format); diff --git a/WICTextureLoader/WICTextureLoader12.cpp b/WICTextureLoader/WICTextureLoader12.cpp index 04bfc49..997af15 100644 --- a/WICTextureLoader/WICTextureLoader12.cpp +++ b/WICTextureLoader/WICTextureLoader12.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -469,7 +470,7 @@ namespace sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0; } - (void)PropVariantClear(&value); + std::ignore = PropVariantClear(&value); if (sRGB) format = MakeSRGB(format);