Skip to content

Commit

Permalink
Fixed a bunch of cppcheck format string warnings
Browse files Browse the repository at this point in the history
Specifically invalidScanfArgType_int and
invalidPrintfArgType_sint warnings.
  • Loading branch information
seanm committed May 18, 2016
1 parent 5b874af commit 0c6085d
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 43 deletions.
4 changes: 2 additions & 2 deletions Geovis/Core/vtkGeoImageNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void vtkGeoImageNode::CropImageForTile(
storedImage->SetSpacing(this->LongitudeRange[1], this->LatitudeRange[1], 0);
vtkXMLImageDataWriter* writer = vtkXMLImageDataWriter::New();
char fn[512];
sprintf(fn, "%s/tile_%d_%ld.vti", prefix, this->Level, this->Id);
sprintf(fn, "%s/tile_%d_%lu.vti", prefix, this->Level, this->Id);
writer->SetFileName(fn);
writer->SetInputData(storedImage);
writer->Write();
Expand All @@ -191,7 +191,7 @@ void vtkGeoImageNode::LoadAnImage(const char* prefix)
{
vtkXMLImageDataReader* reader = vtkXMLImageDataReader::New();
char fn[512];
sprintf(fn, "%s/tile_%d_%ld.vti", prefix, this->Level, this->Id);
sprintf(fn, "%s/tile_%d_%lu.vti", prefix, this->Level, this->Id);
reader->SetFileName(fn);
reader->Update();
vtkImageData* image = reader->GetOutput();
Expand Down
86 changes: 45 additions & 41 deletions IO/Geometry/vtkFLUENTReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct vtkFLUENTReader::Cell
struct vtkFLUENTReader::Face
{
int type;
int zone;
unsigned int zone;
std::vector< int > nodes;
int c0;
int c1;
Expand All @@ -93,14 +93,14 @@ struct vtkFLUENTReader::Face
struct vtkFLUENTReader::ScalarDataChunk
{
int subsectionId;
int zoneId;
unsigned int zoneId;
std::vector< double > scalarData;
};

struct vtkFLUENTReader::VectorDataChunk
{
int subsectionId;
int zoneId;
unsigned int zoneId;
std::vector< double > iComponentData;
std::vector< double > jComponentData;
std::vector< double > kComponentData;
Expand Down Expand Up @@ -2509,7 +2509,8 @@ void vtkFLUENTReader::GetNodesAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, type, nd;
unsigned int zoneId, firstIndex, lastIndex;
int type, nd;
sscanf(info.c_str(), "%x %x %x %d %d", &zoneId, &firstIndex, &lastIndex,
&type, &nd);

Expand All @@ -2528,7 +2529,7 @@ void vtkFLUENTReader::GetNodesAscii()
double x, y, z;
if (this->GridDimension == 3)
{
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
pdatastream >> x;
pdatastream >> y;
Expand All @@ -2538,7 +2539,7 @@ void vtkFLUENTReader::GetNodesAscii()
}
else
{
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
pdatastream >> x;
pdatastream >> y;
Expand All @@ -2554,7 +2555,8 @@ void vtkFLUENTReader::GetNodesSinglePrecision()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, type;
unsigned int zoneId, firstIndex, lastIndex;
int type;
sscanf(info.c_str(), "%x %x %x %d", &zoneId, &firstIndex, &lastIndex, &type);

size_t dstart = this->CaseBuffer->value.find('(', 7);
Expand All @@ -2563,7 +2565,7 @@ void vtkFLUENTReader::GetNodesSinglePrecision()
double x, y, z;
if (this->GridDimension == 3)
{
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
x = this->GetCaseBufferFloat( static_cast< int >(ptr) );
ptr = ptr + 4;
Expand All @@ -2578,7 +2580,7 @@ void vtkFLUENTReader::GetNodesSinglePrecision()
}
else
{
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
x = this->GetCaseBufferFloat( static_cast< int >(ptr) );
ptr = ptr + 4;
Expand All @@ -2599,15 +2601,16 @@ void vtkFLUENTReader::GetNodesDoublePrecision()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, type;
unsigned int zoneId, firstIndex, lastIndex;
int type;
sscanf(info.c_str(), "%x %x %x %d", &zoneId, &firstIndex, &lastIndex, &type);

size_t dstart = this->CaseBuffer->value.find('(', 7);
size_t ptr = dstart+1;

if (this->GridDimension == 3)
{
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
double x = this->GetCaseBufferDouble( static_cast< int >(ptr) );
ptr = ptr + 8;
Expand All @@ -2622,7 +2625,7 @@ void vtkFLUENTReader::GetNodesDoublePrecision()
}
else
{
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
double x = this->GetCaseBufferDouble( static_cast< int >(ptr) );
ptr = ptr + 8;
Expand All @@ -2643,7 +2646,8 @@ void vtkFLUENTReader::GetCellsAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, type;
unsigned int zoneId, firstIndex, lastIndex;
int type;
sscanf(info.c_str(), "%x %x %x %d", &zoneId, &firstIndex, &lastIndex,
&type);
this->Cells->value.resize(lastIndex);
Expand All @@ -2653,7 +2657,8 @@ void vtkFLUENTReader::GetCellsAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, type, elementType;
unsigned int zoneId, firstIndex, lastIndex;
int type, elementType;
sscanf(info.c_str(), "%x %x %x %d %d", &zoneId, &firstIndex, &lastIndex,
&type, &elementType);

Expand All @@ -2664,7 +2669,7 @@ void vtkFLUENTReader::GetCellsAscii()
std::string pdata = this->CaseBuffer->
value.substr(dstart+1, dend-start-1);
std::stringstream pdatastream(pdata);
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
pdatastream >> this->Cells->value[i-1].type;
this->Cells->value[i-1].zone = zoneId;
Expand All @@ -2674,7 +2679,7 @@ void vtkFLUENTReader::GetCellsAscii()
}
else
{
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
this->Cells->value[i-1].type = elementType;
this->Cells->value[i-1].zone = zoneId;
Expand All @@ -2691,15 +2696,15 @@ void vtkFLUENTReader::GetCellsBinary()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, type, elementType;
unsigned int zoneId, firstIndex, lastIndex, type, elementType;
sscanf(info.c_str(), "%x %x %x %x %x", &zoneId, &firstIndex, &lastIndex,
&type, &elementType);

if (elementType == 0)
{
size_t dstart = this->CaseBuffer->value.find('(', 7);
size_t ptr = dstart + 1;
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
this->Cells->value[i-1].type =
this->GetCaseBufferInt( static_cast< int >(ptr) );
Expand All @@ -2711,7 +2716,7 @@ void vtkFLUENTReader::GetCellsBinary()
}
else
{
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
this->Cells->value[i-1].type = elementType;
this->Cells->value[i-1].zone = zoneId;
Expand All @@ -2730,7 +2735,7 @@ void vtkFLUENTReader::GetFacesAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, bcType;
unsigned int zoneId, firstIndex, lastIndex, bcType;
sscanf(info.c_str(), "%x %x %x %x", &zoneId, &firstIndex, &lastIndex,
&bcType);

Expand All @@ -2741,7 +2746,7 @@ void vtkFLUENTReader::GetFacesAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, bcType, faceType;
unsigned int zoneId, firstIndex, lastIndex, bcType, faceType;
sscanf(info.c_str(), "%x %x %x %x %x", &zoneId, &firstIndex, &lastIndex,
&bcType, &faceType);

Expand All @@ -2752,7 +2757,7 @@ void vtkFLUENTReader::GetFacesAscii()
std::stringstream pdatastream(pdata);

int numberOfNodesInFace = 0;
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
if (faceType == 0 || faceType == 5)
{
Expand Down Expand Up @@ -2799,13 +2804,13 @@ void vtkFLUENTReader::GetFacesBinary()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int zoneId, firstIndex, lastIndex, bcType, faceType;
unsigned int zoneId, firstIndex, lastIndex, bcType, faceType;
sscanf(info.c_str(), "%x %x %x %x %x", &zoneId, &firstIndex, &lastIndex,
&bcType, &faceType);
size_t dstart = this->CaseBuffer->value.find('(', 7);
int numberOfNodesInFace = 0;
size_t ptr = dstart + 1;
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
if ((faceType == 0) || (faceType == 5))
{
Expand Down Expand Up @@ -2861,7 +2866,7 @@ void vtkFLUENTReader::GetPeriodicShadowFacesAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int firstIndex, lastIndex, periodicZone, shadowZone;
unsigned int firstIndex, lastIndex, periodicZone, shadowZone;
sscanf(info.c_str(), "%x %x %x %x", &firstIndex, &lastIndex, &periodicZone,
&shadowZone);

Expand All @@ -2871,7 +2876,7 @@ void vtkFLUENTReader::GetPeriodicShadowFacesAscii()
std::stringstream pdatastream(pdata);

int faceIndex1, faceIndex2;
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
pdatastream >> hex >> faceIndex1;
pdatastream >> hex >> faceIndex2;
Expand All @@ -2885,15 +2890,15 @@ void vtkFLUENTReader::GetPeriodicShadowFacesBinary()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int firstIndex, lastIndex, periodicZone, shadowZone;
unsigned int firstIndex, lastIndex, periodicZone, shadowZone;
sscanf(info.c_str(), "%x %x %x %x", &firstIndex, &lastIndex, &periodicZone,
&shadowZone);

size_t dstart = this->CaseBuffer->value.find('(', 7);
size_t ptr = dstart + 1;

//int faceIndex1, faceIndex2;
for (int i = firstIndex; i <=lastIndex; i++)
for (unsigned int i = firstIndex; i <= lastIndex; i++)
{
//faceIndex1 = this->GetCaseBufferInt(ptr);
this->GetCaseBufferInt( static_cast< int >(ptr) );
Expand All @@ -2910,7 +2915,7 @@ void vtkFLUENTReader::GetCellTreeAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int cellId0, cellId1, parentZoneId, childZoneId;
unsigned int cellId0, cellId1, parentZoneId, childZoneId;
sscanf(info.c_str(), "%x %x %x %x", &cellId0, &cellId1, &parentZoneId,
&childZoneId);

Expand All @@ -2920,7 +2925,7 @@ void vtkFLUENTReader::GetCellTreeAscii()
std::stringstream pdatastream(pdata);

int numberOfKids, kid;
for (int i = cellId0; i <=cellId1; i++)
for (unsigned int i = cellId0; i <= cellId1; i++)
{
this->Cells->value[i-1].parent = 1;
pdatastream >> hex >> numberOfKids;
Expand All @@ -2939,15 +2944,15 @@ void vtkFLUENTReader::GetCellTreeBinary()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int cellId0, cellId1, parentZoneId, childZoneId;
unsigned int cellId0, cellId1, parentZoneId, childZoneId;
sscanf(info.c_str(), "%x %x %x %x", &cellId0, &cellId1, &parentZoneId,
&childZoneId);

size_t dstart = this->CaseBuffer->value.find('(', 7);
size_t ptr = dstart + 1;

int numberOfKids, kid;
for (int i = cellId0; i <=cellId1; i++)
for (unsigned int i = cellId0; i <= cellId1; i++)
{
this->Cells->value[i-1].parent = 1;
numberOfKids = this->GetCaseBufferInt( static_cast< int >(ptr) );
Expand All @@ -2967,7 +2972,7 @@ void vtkFLUENTReader::GetFaceTreeAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int faceId0, faceId1, parentZoneId, childZoneId;
unsigned int faceId0, faceId1, parentZoneId, childZoneId;
sscanf(info.c_str(), "%x %x %x %x", &faceId0, &faceId1, &parentZoneId,
&childZoneId);

Expand All @@ -2977,7 +2982,7 @@ void vtkFLUENTReader::GetFaceTreeAscii()
std::stringstream pdatastream(pdata);

int numberOfKids, kid;
for (int i = faceId0; i <=faceId1; i++)
for (unsigned int i = faceId0; i <= faceId1; i++)
{
this->Faces->value[i-1].parent = 1;
pdatastream >> hex >> numberOfKids;
Expand All @@ -2995,15 +3000,15 @@ void vtkFLUENTReader::GetFaceTreeBinary()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int faceId0, faceId1, parentZoneId, childZoneId;
unsigned int faceId0, faceId1, parentZoneId, childZoneId;
sscanf(info.c_str(), "%x %x %x %x", &faceId0, &faceId1, &parentZoneId,
&childZoneId);

size_t dstart = this->CaseBuffer->value.find('(', 7);
size_t ptr = dstart + 1;

int numberOfKids, kid;
for (int i = faceId0; i <=faceId1; i++)
for (unsigned int i = faceId0; i <= faceId1; i++)
{
this->Faces->value[i-1].parent = 1;
numberOfKids = this->GetCaseBufferInt( static_cast< int >(ptr) );
Expand All @@ -3023,7 +3028,7 @@ void vtkFLUENTReader::GetInterfaceFaceParentsAscii()
size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int faceId0, faceId1;
unsigned int faceId0, faceId1;
sscanf(info.c_str(), "%x %x", &faceId0, &faceId1);

size_t dstart = this->CaseBuffer->value.find('(', 7);
Expand All @@ -3032,7 +3037,7 @@ void vtkFLUENTReader::GetInterfaceFaceParentsAscii()
std::stringstream pdatastream(pdata);

int parentId0, parentId1;
for (int i = faceId0; i <=faceId1; i++)
for (unsigned int i = faceId0; i <= faceId1; i++)
{
pdatastream >> hex >> parentId0;
pdatastream >> hex >> parentId1;
Expand All @@ -3046,18 +3051,17 @@ void vtkFLUENTReader::GetInterfaceFaceParentsAscii()
//----------------------------------------------------------------------------
void vtkFLUENTReader::GetInterfaceFaceParentsBinary()
{

size_t start = this->CaseBuffer->value.find('(', 1);
size_t end = this->CaseBuffer->value.find(')',1);
std::string info = this->CaseBuffer->value.substr(start+1,end-start-1 );
int faceId0, faceId1;
unsigned int faceId0, faceId1;
sscanf(info.c_str(), "%x %x", &faceId0, &faceId1);

size_t dstart = this->CaseBuffer->value.find('(', 7);
size_t ptr = dstart + 1;

int parentId0, parentId1;
for (int i = faceId0; i <=faceId1; i++)
for (unsigned int i = faceId0; i <= faceId1; i++)
{
parentId0 = this->GetCaseBufferInt( static_cast< int >(ptr) );
ptr = ptr + 4;
Expand Down

0 comments on commit 0c6085d

Please sign in to comment.