Skip to content

Commit

Permalink
Static analysis fixes
Browse files Browse the repository at this point in the history
This changelist addresses a handful of static analysis warnings flagged by Cppcheck and MSVC.
  • Loading branch information
jstone-lucasfilm committed Mar 17, 2024
1 parent 7ede137 commit 0067b57
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions source/MaterialXGenShader/Syntax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ string Syntax::getSwizzledVariable(const string& srcName, TypeDesc srcType, cons
else
{
const size_t channelIndex = it->second;
if (channelIndex < 0 || channelIndex >= srcMembers.size())
if (channelIndex >= srcMembers.size())
{
throw ExceptionShaderGenError("Given channel index: '" + string(1, ch) + "' in channels pattern is incorrect for type '" + srcType.getName() + "'.");
}
Expand Down Expand Up @@ -197,7 +197,7 @@ ValuePtr Syntax::getSwizzledValue(ValuePtr value, TypeDesc srcType, const string
else
{
const size_t channelIndex = it->second;
if (channelIndex < 0 || channelIndex >= srcMembers.size())
if (channelIndex >= srcMembers.size())
{
throw ExceptionShaderGenError("Given channel index: '" + string(1, ch) + "' in channels pattern is incorrect for type '" + srcType.getName() + "'.");
}
Expand Down
8 changes: 7 additions & 1 deletion source/MaterialXRender/GeometryHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@

MATERIALX_NAMESPACE_BEGIN

namespace
{

const float MAX_FLOAT = std::numeric_limits<float>::max();

} // anonymous namespace

void GeometryHandler::addLoader(GeometryLoaderPtr loader)
{
const StringSet& extensions = loader->supportedExtensions();
Expand Down Expand Up @@ -63,7 +70,6 @@ void GeometryHandler::getGeometry(MeshList& meshes, const string& location)

void GeometryHandler::computeBounds()
{
const float MAX_FLOAT = std::numeric_limits<float>::max();
_minimumBounds = { MAX_FLOAT, MAX_FLOAT, MAX_FLOAT };
_maximumBounds = { -MAX_FLOAT, -MAX_FLOAT, -MAX_FLOAT };
for (const auto& mesh : _meshes)
Expand Down
2 changes: 1 addition & 1 deletion source/MaterialXRenderHw/SimpleWindowWindows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ SimpleWindow::~SimpleWindow()
if (hWnd)
{
_windowWrapper->release();
DestroyWindow(hWnd);
}

DestroyWindow(hWnd);
UnregisterClass(_windowClassName, GetModuleHandle(NULL));
}

Expand Down

0 comments on commit 0067b57

Please sign in to comment.