mirror of
https://github.com/microsoft/DirectXTex
synced 2024-11-23 04:50:06 +00:00
Fix CodeQL warnings in OpenEXR module (#549)
This commit is contained in:
parent
d8e9d5b12a
commit
79c65ffce8
@ -45,8 +45,13 @@
|
|||||||
#pragma warning(disable : 4244 4996)
|
#pragma warning(disable : 4244 4996)
|
||||||
#include <ImfRgbaFile.h>
|
#include <ImfRgbaFile.h>
|
||||||
#include <ImfIO.h>
|
#include <ImfIO.h>
|
||||||
|
|
||||||
|
// https://openexr.com/en/latest/PortingGuide.html
|
||||||
|
#include <OpenEXRConfig.h>
|
||||||
#pragma warning(pop)
|
#pragma warning(pop)
|
||||||
|
|
||||||
|
#define COMBINED_OPENEXR_VERSION ((10000*OPENEXR_VERSION_MAJOR) + (100*OPENEXR_VERSION_MINOR) + OPENEXR_VERSION_PATCH)
|
||||||
|
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
@ -148,6 +153,13 @@ namespace
|
|||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if COMBINED_OPENEXR_VERSION >= 30300
|
||||||
|
int64_t read(void *buf, uint64_t sz, uint64_t offset) override
|
||||||
|
{
|
||||||
|
return Imf::IStream::read(buf, sz, offset);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HANDLE m_hFile;
|
HANDLE m_hFile;
|
||||||
LONGLONG m_EOF;
|
LONGLONG m_EOF;
|
||||||
@ -220,7 +232,7 @@ HRESULT DirectX::GetMetadataFromEXRFile(const wchar_t* szFile, TexMetadata& meta
|
|||||||
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
||||||
if (nameLength > 0)
|
if (nameLength > 0)
|
||||||
{
|
{
|
||||||
fileName.resize(nameLength);
|
fileName.resize(static_cast<size_t>(nameLength));
|
||||||
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
{
|
{
|
||||||
@ -338,7 +350,7 @@ HRESULT DirectX::LoadFromEXRFile(const wchar_t* szFile, TexMetadata* metadata, S
|
|||||||
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
||||||
if (nameLength > 0)
|
if (nameLength > 0)
|
||||||
{
|
{
|
||||||
fileName.resize(nameLength);
|
fileName.resize(static_cast<size_t>(nameLength));
|
||||||
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
{
|
{
|
||||||
@ -487,7 +499,7 @@ HRESULT DirectX::SaveToEXRFile(const Image& image, const wchar_t* szFile)
|
|||||||
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
const int nameLength = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, nullptr, 0, nullptr, nullptr);
|
||||||
if (nameLength > 0)
|
if (nameLength > 0)
|
||||||
{
|
{
|
||||||
fileName.resize(nameLength);
|
fileName.resize(static_cast<size_t>(nameLength));
|
||||||
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
const int result = WideCharToMultiByte(CP_UTF8, 0, szFile, -1, fileName.data(), nameLength, nullptr, nullptr);
|
||||||
if (result <= 0)
|
if (result <= 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user