Commit 5da80674 authored by Sean McBride's avatar Sean McBride

Reverse order of AND statements

cppcheck warned because the later check involved an
index that’s used in the earlier check.  That could
easily be backwards if the index is not in range
without the check happening first.

Change-Id: Iaa79b07bb1eccd51db5e27252ab83d39f8e8b2f2
parent dd72b672
...@@ -1442,7 +1442,7 @@ void vtkFunctionParser::BuildInternalSubstringStructure(int beginIndex, ...@@ -1442,7 +1442,7 @@ void vtkFunctionParser::BuildInternalSubstringStructure(int beginIndex,
if (mathFunctionNum > 0) if (mathFunctionNum > 0)
{ {
beginIndex2 = beginIndex; beginIndex2 = beginIndex;
while (this->Function[beginIndex2] != '(' && beginIndex2 <= endIndex) while (beginIndex2 <= endIndex && this->Function[beginIndex2] != '(')
{ {
beginIndex2++; beginIndex2++;
} }
......
...@@ -704,8 +704,8 @@ int vtkDelaunay2D::RequestData( ...@@ -704,8 +704,8 @@ int vtkDelaunay2D::RequestData(
//traverse all points, create vertices if none used //traverse all points, create vertices if none used
for (ptId=0; ptId<(numPoints+8); ptId++) for (ptId=0; ptId<(numPoints+8); ptId++)
{ {
if ( !pointUse[ptId] if ( (ptId < numPoints || this->BoundingTriangulation)
&& (ptId < numPoints || this->BoundingTriangulation) ) && !pointUse[ptId] )
{ {
pts[0] = ptId; pts[0] = ptId;
alphaVerts->InsertNextCell(1,pts); alphaVerts->InsertNextCell(1,pts);
......
...@@ -700,7 +700,7 @@ int vtkDelaunay3D::RequestData( ...@@ -700,7 +700,7 @@ int vtkDelaunay3D::RequestData(
//traverse all points, create vertices if none used //traverse all points, create vertices if none used
for (ptId=0; ptId<(numPoints+6); ptId++) for (ptId=0; ptId<(numPoints+6); ptId++)
{ {
if (!pointUse[ptId] && (ptId < numPoints || this->BoundingTriangulation)) if ((ptId < numPoints || this->BoundingTriangulation) && !pointUse[ptId])
{ {
pts[0] = ptId; pts[0] = ptId;
output->InsertNextCell(VTK_VERTEX,1,pts); output->InsertNextCell(VTK_VERTEX,1,pts);
......
...@@ -87,7 +87,7 @@ int TestScalarBarCombinatorics(int argc, char* argv[]) ...@@ -87,7 +87,7 @@ int TestScalarBarCombinatorics(int argc, char* argv[])
double threshold = 10.; double threshold = 10.;
for (int cc = 1; cc < argc; ++cc) for (int cc = 1; cc < argc; ++cc)
{ {
if (argv[cc][0] == '-' && argv[cc][1] == 'E' && cc < argc - 1) if ((cc < argc - 1) && (argv[cc][0] == '-') && (argv[cc][1] == 'E'))
{ {
threshold = atof(argv[++cc]); threshold = atof(argv[++cc]);
continue; continue;
......
...@@ -293,7 +293,8 @@ inline void vtkLinearRayIntegratorTransferFunction::GetColor(double x, ...@@ -293,7 +293,8 @@ inline void vtkLinearRayIntegratorTransferFunction::GetColor(double x,
double c[4]) double c[4])
{ {
int i = 1; int i = 1;
while ((this->ControlPoints[i] < x) && (i < this->NumControlPoints-1)) i++; while ((i < this->NumControlPoints-1) && (this->ControlPoints[i] < x))
i++;
double before = this->ControlPoints[i-1]; double before = this->ControlPoints[i-1];
double after = this->ControlPoints[i]; double after = this->ControlPoints[i];
......
...@@ -273,7 +273,7 @@ inline void vtkPartialPreIntegrationTransferFunction::GetColor(double x, ...@@ -273,7 +273,7 @@ inline void vtkPartialPreIntegrationTransferFunction::GetColor(double x,
c[3] = 0.0; c[3] = 0.0;
return; return;
} }
while (this->ControlPoints[i] < x && i < size-1) while ((i < size-1) && (this->ControlPoints[i] < x))
{ {
i++; i++;
} }
......
...@@ -64,7 +64,7 @@ static string vtkTestingGetArgOrEnvOrDefault( ...@@ -64,7 +64,7 @@ static string vtkTestingGetArgOrEnvOrDefault(
int argc = static_cast<int>(argv.size()); int argc = static_cast<int>(argv.size());
for (int i = 0; i < argc; i++) for (int i = 0; i < argc; i++)
{ {
if (argName == argv[i] && i < (argc - 1)) if ((i < (argc - 1)) && (argName == argv[i]))
{ {
argValue = argv[i + 1]; argValue = argv[i + 1];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment