1
0
mirror of https://github.com/microsoft/DirectXTex synced 2024-11-21 12:00:06 +00:00

std::ignore usage instead of (void) for ignoring return values

This commit is contained in:
Chuck Walbourn 2021-10-17 11:57:07 -07:00
parent 144847dfcc
commit 1363046e2b
12 changed files with 60 additions and 50 deletions

View File

@ -130,6 +130,7 @@
#include <iterator>
#include <memory>
#include <new>
#include <tuple>
#ifndef WIN32
#include <fstream>

View File

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

View File

@ -13,6 +13,7 @@
#include <cstddef>
#include <cstdint>
#include <memory>
#include <tuple>
#ifndef WIN32
#include <cstdlib>
@ -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));
}
}

View File

@ -29,6 +29,7 @@
#include <cstring>
#include <memory>
#include <new>
#include <tuple>
#include <wincodec.h>
@ -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);
}
}
}

View File

@ -29,6 +29,7 @@
#include <cstring>
#include <memory>
#include <new>
#include <tuple>
#ifdef WIN32
#include <wincodec.h>
@ -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);
}
}
}

View File

@ -23,6 +23,7 @@
#include <cstring>
#include <memory>
#include <new>
#include <tuple>
#include <wincodec.h>
@ -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);
}
}

View File

@ -35,6 +35,7 @@
#include <new>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
@ -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))

View File

@ -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));
}
}

View File

@ -36,6 +36,7 @@
#include <new>
#include <set>
#include <string>
#include <tuple>
#include <wrl\client.h>
@ -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<wchar_t*>(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));

View File

@ -32,9 +32,10 @@
#include <list>
#include <locale>
#include <memory>
#include <new>
#include <set>
#include <string>
#include <new>
#include <tuple>
#include <vector>
#include <dxgiformat.h>
@ -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))

View File

@ -38,6 +38,7 @@
#include <iterator>
#include <memory>
#include <new>
#include <tuple>
#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);

View File

@ -28,6 +28,7 @@
#include <cstring>
#include <iterator>
#include <new>
#include <tuple>
#include <wincodec.h>
@ -469,7 +470,7 @@ namespace
sRGB = (loadFlags & WIC_LOADER_SRGB_DEFAULT) != 0;
}
(void)PropVariantClear(&value);
std::ignore = PropVariantClear(&value);
if (sRGB)
format = MakeSRGB(format);