Commit 61f6edd5 authored by Sean McBride's avatar Sean McBride Committed by Code Review

Merge topic 'static-analysis' into master

bcba6dab Fix null deref, likely due to && vs || typo
87ecf6fa Reformulate assert to pacify cppcheck
dedac30c Removed _probably_ dead code
c107164f Move index ‘i’ check after usage
f1f33bc9 Fixed possible array overrun found by cppcheck
c10d56be Fixed minor format string mismatch
b1d28712 Silence clang analyzer warning
3cf511d7 Removed unneeded c_str() usage
a283cf6a Removed dead code found by cppcheck
parents 49f7791e bcba6dab
......@@ -141,7 +141,6 @@ public:
if ( !name.empty() && color.GetSize() == 4 )
{
vtkStdString s = this->ToLowercase(name);
std::vector<unsigned char> uv;
unsigned char r, g, b, a;
r = static_cast<unsigned char>(color.GetRed() * 255.0);
g = static_cast<unsigned char>(color.GetGreen() * 255.0);
......
......@@ -974,7 +974,7 @@ template <typename T>
T vtkVariantStringToNumeric(vtkStdString str, bool* valid, T* vtkNotUsed(ignored) = 0)
{
vtksys_ios::istringstream vstr(str);
T data;
T data = 0;
vstr >> data;
if(!vstr.eof())
{
......
......@@ -1037,15 +1037,6 @@ void vtkCompositeDataPipeline::MarkOutputsGenerated(
{
this->Superclass::MarkOutputsGenerated(request,inInfoVec,outInfoVec);
// Save the information about COMPOSITE_INDICES() as needed in the data
// object.
int outputPort = 0;
if(request->Has(FROM_OUTPUT_PORT()))
{
outputPort = request->Get(FROM_OUTPUT_PORT());
outputPort = (outputPort >= 0 ? outputPort : 0);
}
for (int i=0; i < outInfoVec->GetNumberOfInformationObjects(); ++i)
{
vtkInformation* outInfo = outInfoVec->GetInformationObject(i);
......
......@@ -877,8 +877,9 @@ void vtkAMRResampleFilter::ExtractRegion(
// std::cout << "NumProcs: " << this->Controller->GetNumberOfProcesses() << std::endl;
// std::cout.flush();
assert( !this->Controller || ( "pre: NumProcs must be less than or equal to NumBlocks" &&
( static_cast<int>(this->ROI->GetNumberOfBlocks()) <= this->Controller->GetNumberOfProcesses())));
assert( "pre: NumProcs must be less than or equal to NumBlocks" &&
(!this->Controller ||
(static_cast<int>(this->ROI->GetNumberOfBlocks()) <= this->Controller->GetNumberOfProcesses())));
mbds->SetNumberOfBlocks( this->ROI->GetNumberOfBlocks( ) );
for( unsigned int block=0; block < this->ROI->GetNumberOfBlocks(); ++block )
......
......@@ -277,36 +277,6 @@ class vtkCellTreeBuilder
}
}
//----------------------------------------------------------------------------
void FindMinD( const PerCell* begin, const PerCell* end,
unsigned int d, float& min )
{
min = begin->Min[d];
while( ++begin != end )
{
if( begin->Min[d] < min )
{
min = begin->Min[d];
}
}
}
void FindMaxD( const PerCell* begin, const PerCell* end,
unsigned int d, float& max )
{
max = begin->Max[d];
while( ++begin != end )
{
if( begin->Max[d] > max )
{
max = begin->Max[d];
}
}
}
// -------------------------------------------------------------------------
void Split( unsigned int index, float min[3], float max[3] )
......
......@@ -558,7 +558,7 @@ bool vtkExtractCTHPart::ExtractContourOnBlock(
vtkPolyData* output =
vtkPolyData::SafeDownCast(contourer->GetOutputDataObject(0));
if (!output && output->GetNumberOfPoints()== 0)
if (!output || output->GetNumberOfPoints()== 0)
{
return true;
}
......
......@@ -97,7 +97,7 @@ int TestPUnstructuredGridConnectivity(int argc, char* argv[])
UpdateGrid(i);
#ifdef DEBUG
WriteDataSet(Grid,grdfname.str().c_str());
WriteDataSet(Grid,grdfname.str());
#endif
vtkMPIUtilities::Printf(cntrl,"[INFO]: iteration=%d\n",i);
......@@ -124,7 +124,7 @@ int TestPUnstructuredGridConnectivity(int argc, char* argv[])
#ifdef DEBUG
assert("pre: ghost grid should not be NULL!" && (ghostGrid != NULL) );
WriteDataSet(ghostGrid,ghostfname.str().c_str());
WriteDataSet(ghostGrid,ghostfname.str());
#endif
rc += CheckGrid(ghostGrid,i);
......
......@@ -78,7 +78,7 @@ int TestPUnstructuredGridGhostDataGenerator(int argc, char* argv[])
UpdateGrid(i);
global::Grid->Modified();
#ifdef DEBUG
WriteDataSet(global::Grid,grdfname.str().c_str());
WriteDataSet(global::Grid,grdfname.str());
#endif
// update ghost zones in this iteration...
......@@ -108,7 +108,7 @@ int TestPUnstructuredGridGhostDataGenerator(int argc, char* argv[])
ghostGrid->DeepCopy(ghostGenerator->GetOutput());
#ifdef DEBUG
assert("pre: ghost gird should not be NULL!" && (ghostGrid != NULL) );
WriteDataSet(ghostGrid,ghostfname.str().c_str());
WriteDataSet(ghostGrid,ghostfname.str());
#endif
rc += CheckGrid(ghostGrid,i);
......
......@@ -137,7 +137,7 @@ int vtkFixedWidthTextReader::RequestData(
// here because an unsigned int will never take up enough
// characters to fill up this buffer.
char fieldName[64];
sprintf(fieldName, "Field %d", i);
sprintf(fieldName, "Field %u", i);
headers.push_back(fieldName);
}
}
......
......@@ -1147,7 +1147,7 @@ void vtkWin32VideoSource::DoVFWFormatSetup()
this->Internal->BitMapPtr->bmiHeader.biClrUsed = 0;
this->Internal->BitMapPtr->bmiHeader.biClrImportant = 0;
for (i = 0; i < 4; i++)
for (i = 0; i < 3; i++)
{ // try for a
if (this->OutputFormat == VTK_RGBA || this->OutputFormat == VTK_RGB)
{
......
......@@ -397,7 +397,6 @@ static int preproc_evaluate_char(
else if (*cp == 'f') { *val = '\f'; }
else if (*cp == 'n') { *val = '\n'; }
else if (*cp == 'r') { *val = '\r'; }
else if (*cp == 'b') { *val = '\b'; }
else if (*cp == 't') { *val = '\t'; }
else if (*cp == 'v') { *val = '\v'; }
else if (*cp == '\'') { *val = '\''; }
......
......@@ -224,7 +224,7 @@ size_t vtkWrapPython_PyTemplateName(const char *name, char *pname)
j = i;
m = 1;
while (name[i] != '>' && i < n && m != 0)
while (i < n && m != 0 && name[i] != '>')
{
if (name[i] >= '0' && name[i] <= '9')
{
......
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