Commit a5289235 authored by Sean McBride's avatar Sean McBride Committed by Code Review

Merge topic 'more-clang-analzyer' into master

57d3811f Fixed obvious null dereferences
ce0618c2 Fixed null dereference
1fa832c3 Fixed false positive warning about null deref
e2dad201 Fixed null dereference
c5917828 Fixed dead store warning by reformulating loop
8f0a469e Fixed dead store warning by removing redundant 'break'
832f091a Fixed a few dead store warnings
b8af0b7c Fixed analyzer warning about possible null deref
70d8784b Fixed analyzer warning by removing null check
93b12c9a Put initial assignment at declaration
ab36a82e Added some consts in a few places
a0c7098d Remove dead store to fix warning.
ca321864 Bail early on null parameter
parents 40836e15 57d3811f
......@@ -1046,8 +1046,8 @@ inline int vtkMath::Ceil(double x)
//----------------------------------------------------------------------------
inline float vtkMath::Normalize(float x[3])
{
float den;
if ( ( den = vtkMath::Norm( x ) ) != 0.0 )
float den = vtkMath::Norm( x );
if ( den != 0.0 )
{
for (int i=0; i < 3; i++)
{
......@@ -1060,8 +1060,8 @@ inline float vtkMath::Normalize(float x[3])
//----------------------------------------------------------------------------
inline double vtkMath::Normalize(double x[3])
{
double den;
if ( ( den = vtkMath::Norm( x ) ) != 0.0 )
double den = vtkMath::Norm( x );
if ( den != 0.0 )
{
for (int i=0; i < 3; i++)
{
......@@ -1074,8 +1074,8 @@ inline double vtkMath::Normalize(double x[3])
//----------------------------------------------------------------------------
inline float vtkMath::Normalize2D(float x[3])
{
float den;
if ( ( den = vtkMath::Norm2D( x ) ) != 0.0 )
float den = vtkMath::Norm2D( x );
if ( den != 0.0 )
{
for (int i=0; i < 2; i++)
{
......@@ -1088,8 +1088,8 @@ inline float vtkMath::Normalize2D(float x[3])
//----------------------------------------------------------------------------
inline double vtkMath::Normalize2D(double x[3])
{
double den;
if ( ( den = vtkMath::Norm2D( x ) ) != 0.0 )
double den = vtkMath::Norm2D( x );
if ( den != 0.0 )
{
for (int i=0; i < 2; i++)
{
......
......@@ -665,18 +665,16 @@ vtkIdType vtkCellLocator::FindClosestPointWithinRadius(double x[3], double radiu
vtkIdType j;
int tmpInside;
int *nei;
int closestCell = -1;
int closestSubCell = -1;
int leafStart;
int ijk[3];
double minDist2;
double pcoords[3], point[3], cachedPoint[3], weightsArray[6];
double *weights = weightsArray;
int nWeights = 6, nPoints;
int returnVal = 0;
vtkIdList *cellIds;
double refinedRadius, radius2, refinedRadius2, distance2ToBucket;
double distance2ToBucket;
double distance2ToCellBounds, cellBounds[6], currentRadius;
double distance2ToDataBounds, maxDistance;
int ii, radiusLevels[3], radiusLevel, prevMinLevel[3], prevMaxLevel[3];
......@@ -702,11 +700,11 @@ vtkIdType vtkCellLocator::FindClosestPointWithinRadius(double x[3], double radiu
// init
dist2 = -1.0;
closestCell = -1;
radius2 = radius*radius;
minDist2 = 1.1*radius2; // something slightly bigger....
refinedRadius = radius;
refinedRadius2 = radius2;
int closestCell = -1;
double radius2 = radius*radius;
double minDist2 = 1.1*radius2; // something slightly bigger....
double refinedRadius = radius;
double refinedRadius2 = radius2;
// Find bucket point is in.
//
......@@ -1902,14 +1900,12 @@ void vtkCellLocator::FindCellsAlongLine(double p1[3], double p2[3], double vtkNo
if (this->Tree[idx])
{
this->ComputeOctantBounds(pos[0]-1,pos[1]-1,pos[2]-1);
for (tMax = VTK_DOUBLE_MAX, cellId=0;
cellId < this->Tree[idx]->GetNumberOfIds(); cellId++)
for (cellId=0; cellId < this->Tree[idx]->GetNumberOfIds(); cellId++)
{
cId = this->Tree[idx]->GetId(cellId);
if (this->CellHasBeenVisited[cId] != this->QueryNumber)
{
this->CellHasBeenVisited[cId] = this->QueryNumber;
hitCellBounds = 0;
// check whether we intersect the cell bounds
if (this->CacheCellBounds)
......
......@@ -257,7 +257,7 @@ void vtkPixelExtent::Merge(deque<vtkPixelExtent> &exts)
// if a merger occurs the merged extent is added
// as a new target with the constituents marked empty
// and the current pass is terminated early
int nextPass = 0;
bool nextPass = false;
// current target
vtkPixelExtent &ext0 = tmpExts[t];
......@@ -303,8 +303,7 @@ void vtkPixelExtent::Merge(deque<vtkPixelExtent> &exts)
ext1.Clear();
// move to next target
nextPass = 1;
break;
nextPass = true;
}
}
if (nextPass)
......
......@@ -1878,8 +1878,7 @@ int vtkPolyhedron::IsInside(double x[3], double tolerance)
iterNumber++)
{
// Define a random ray to fire.
rayMag = 0.0;
while (rayMag == 0.0 )
do
{
for (i=0; i<3; i++)
{
......@@ -1887,6 +1886,7 @@ int vtkPolyhedron::IsInside(double x[3], double tolerance)
}
rayMag = vtkMath::Norm(ray);
}
while (rayMag == 0.0);
// The ray must be appropriately sized wrt the bounding box. (It has to go
// all the way through the bounding box.)
......
......@@ -118,6 +118,11 @@ vtkTree *vtkTree::GetData(vtkInformationVector *v, int i)
//----------------------------------------------------------------------------
bool vtkTree::IsStructureValid(vtkGraph *g)
{
if (!g)
{
return false;
}
vtkTree *tree = vtkTree::SafeDownCast(g);
if (tree)
{
......
......@@ -60,7 +60,7 @@ void vtkVertexListIterator::SetGraph(vtkGraph *graph)
if (helper)
{
int myRank
= graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
= this->Graph->GetInformation()->Get(vtkDataObject::DATA_PIECE_NUMBER());
this->Current = helper->MakeDistributedId(myRank, this->Current);
this->End = helper->MakeDistributedId(myRank, this->End);
}
......
......@@ -1191,8 +1191,8 @@ void vtkAlgorithm::RemoveInputConnection(int port, vtkAlgorithmOutput* input)
vtkDebugMacro("Removing connection to input port index " << consumerPort
<< " from output port index " << producerPort
<< " on algorithm "
<< (producer? producer->GetAlgorithm()->GetClassName() : "")
<< "(" << (producer? producer->GetAlgorithm() : 0) << ").");
<< producer->GetAlgorithm()->GetClassName()
<< "(" << producer->GetAlgorithm() << ").");
// Get the information object from the producer of the old input.
vtkInformation* oldInfo = producer->GetOutputInformation(producerPort);
......
......@@ -954,7 +954,7 @@ void vtkHyperTreeGridSource::SubdivideFromBitsDescriptor(
void vtkHyperTreeGridSource::SubdivideFromQuadric( vtkHyperTreeCursor* cursor,
unsigned int level,
int treeIdx,
int idx[3],
const int idx[3],
double origin[3],
double size[3] )
{
......
......@@ -214,7 +214,7 @@ protected:
void SubdivideFromQuadric( vtkHyperTreeCursor* cursor,
unsigned int level,
int treeIdx,
int idx[3],
const int idx[3],
double origin[3],
double size[3] );
......
......@@ -101,7 +101,7 @@ void vtkImageConvolve::SetKernel5x5(const double kernel[25])
//----------------------------------------------------------------------------
// Set a 7x7 kernel
void vtkImageConvolve::SetKernel7x7(double kernel[49])
void vtkImageConvolve::SetKernel7x7(const double kernel[49])
{
// Fill the kernel
this->SetKernel(kernel, 7, 7, 1);
......@@ -117,7 +117,7 @@ void vtkImageConvolve::SetKernel3x3x3(const double kernel[27])
//----------------------------------------------------------------------------
// Set a 5x5x5 kernel
void vtkImageConvolve::SetKernel5x5x5(double kernel[125])
void vtkImageConvolve::SetKernel5x5x5(const double kernel[125])
{
// Fill the kernel
this->SetKernel(kernel, 5, 5, 5);
......@@ -125,7 +125,7 @@ void vtkImageConvolve::SetKernel5x5x5(double kernel[125])
//----------------------------------------------------------------------------
// Set a 7x7x7 kernel
void vtkImageConvolve::SetKernel7x7x7(double kernel[343])
void vtkImageConvolve::SetKernel7x7x7(const double kernel[343])
{
// Fill the kernel
this->SetKernel(kernel, 7, 7, 7);
......
......@@ -42,7 +42,7 @@ public:
void SetKernel3x3(const double kernel[9]);
void SetKernel5x5(const double kernel[25]);
//BTX
void SetKernel7x7(double kernel[49]);
void SetKernel7x7(const double kernel[49]);
//ETX
// Description:
......@@ -60,8 +60,8 @@ public:
// Set the kernel to be a 3x3x3 or 5x5x5 or 7x7x7 kernel.
void SetKernel3x3x3(const double kernel[27]);
//BTX
void SetKernel5x5x5(double kernel[125]);
void SetKernel7x7x7(double kernel[343]);
void SetKernel5x5x5(const double kernel[125]);
void SetKernel7x7x7(const double kernel[343]);
//ETX
// Description:
......
......@@ -355,7 +355,6 @@ void vtkImageSlabExecute(vtkImageSlab *self,
{
*rowPtr++ += f*(*inPtrX++);
}
inSlicePtr += inInc[dimIndex];
}
rowPtr = rowBuffer;
......
......@@ -138,7 +138,7 @@ int vtkSliceCubesContour(T *slice, S *scalars, int imageRange[2], int dims[3],
double xmin[3], double xmax[3], FILE *outFP,
vtkVolumeReader *reader, unsigned char debug)
{
S *slice0scalars=NULL, *slice1scalars;
S *slice0scalars=NULL, *slice1scalars=NULL;
S *slice2scalars, *slice3scalars;
T *slice0, *slice1, *slice2, *slice3;
vtkImageData *sp;
......@@ -166,7 +166,6 @@ int vtkSliceCubesContour(T *slice, S *scalars, int imageRange[2], int dims[3],
doubleScalars->Allocate(sliceSize);
}
slice1scalars = NULL;
slice2scalars = scalars;
slice2scalars->Register(NULL);
......@@ -387,7 +386,10 @@ int vtkSliceCubesContour(T *slice, S *scalars, int imageRange[2], int dims[3],
{
slice3scalars->Delete();
}
slice1scalars->Delete();
if (slice1scalars)
{
slice1scalars->Delete();
}
slice2scalars->Delete();
return numTriangles;
......
......@@ -80,6 +80,7 @@ void vtkAbstractMapper::RemoveClippingPlane(vtkPlane *plane)
if (this->ClippingPlanes == NULL)
{
vtkErrorMacro(<< "Cannot remove clipping plane: mapper has none");
return;
}
this->ClippingPlanes->RemoveItem(plane);
this->Modified();
......
......@@ -274,6 +274,7 @@ void vtkInteractorEventRecorder::Rewind()
if ( ! this->InputStream ) //need to already have an open file
{
vtkGenericWarningMacro(<<"No input file opened to rewind...");
return;
}
this->InputStream->clear();
this->InputStream->seekg(0);
......
......@@ -186,6 +186,11 @@ int vtkMapArrayValues::RequestData(
return 0;
}
}
else
{
vtkErrorMacro(<<"Invalid input type");
return 0;
}
vtkAbstractArray *inputArray = ods->GetAbstractArray(this->InputArrayName);
if (!inputArray)
......
......@@ -323,7 +323,8 @@ void vtkOpenGLImageSliceMapper::RenderTexturedPolygon(
}
GLenum interp = GL_LINEAR;
if (property->GetInterpolationType() == VTK_NEAREST_INTERPOLATION &&
if (property &&
property->GetInterpolationType() == VTK_NEAREST_INTERPOLATION &&
!this->ExactPixelMatch)
{
interp = GL_NEAREST;
......
......@@ -268,18 +268,15 @@ void vtkPrimitivePainter::RenderInternal(vtkRenderer* renderer,
// Edge flag
ef = input->GetPointData()->GetAttribute(vtkDataSetAttributes::EDGEFLAG);
if (ef)
if (ef && ef->GetNumberOfComponents() != 1)
{
if (ef->GetNumberOfComponents() != 1)
{
vtkDebugMacro(<< "Currently only 1d edge flags are supported.");
ef = NULL;
}
if (!ef->IsA("vtkUnsignedCharArray"))
{
vtkDebugMacro(<< "Currently only unsigned char edge flags are suported.");
ef = NULL;
}
vtkDebugMacro(<< "Currently only 1d edge flags are supported.");
ef = NULL;
}
if (ef && !ef->IsA("vtkUnsignedCharArray"))
{
vtkDebugMacro(<< "Currently only unsigned char edge flags are suported.");
ef = NULL;
}
// Set the flags
......
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