View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0013389VTK(No Category)public2012-08-24 04:292012-09-11 00:27
ReporterAndrey 
Assigned ToDavid Gobbi 
PrioritynormalSeverityminorReproducibilityhave not tried
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version5.8.0 
Target VersionFixed in Version 
Summary0013389: PVS-Studio static code analyzer for C/C++
DescriptionI check the VTK project by using PVS-Studio - http://www.viva64.com/en/pvs-studio/. [^] Perhaps you would be interested.

----------------------------------
V501 There are identical sub-expressions 'newPos[2] != oldPos[2]' to the left and to the right of the '||' operator. vtkCharts vtkpiecewisecontrolpointsitem.cxx 129

void vtkPiecewiseControlPointsItem::SetControlPoint(vtkIdType index, double* newPos)
{
  double oldPos[4];
  this->PiecewiseFunction->GetNodeValue(index, oldPos);
  if (newPos[0] != oldPos[0] || newPos[1] != oldPos[1] ||
      newPos[2] != oldPos[2] || newPos[2] != oldPos[2])
    {
      this->PiecewiseFunction->SetNodeValue(index, newPos);
    }
}
----------------------------------
V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[0] - outExt[0] vtkFiltering vtkdatasetattributes.cxx 457
V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[2] - outExt[2] vtkFiltering vtkdatasetattributes.cxx 458
V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[4] - outExt[4] vtkFiltering vtkdatasetattributes.cxx 459
V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[0] - outExt[0] vtkFiltering vtkdatasetattributes.cxx 490
V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[2] - outExt[2] vtkFiltering vtkdatasetattributes.cxx 491
V501 There are identical sub-expressions to the left and to the right of the '-' operator: outExt[4] - outExt[4] vtkFiltering vtkdatasetattributes.cxx 492

template <class iterT>
void vtkDataSetAttributesCopyValues(....)
{
  ...
  inZPtr += (outExt[0]-outExt[0])*inIncs[0] * data_type_size +
            (outExt[2] - outExt[2])*inIncs[1] * data_type_size +
            (outExt[4] - outExt[4])*inIncs[2] * data_type_size;
  ...
}

Nonsensical code. This is equivalent:
inZPtr += 0;
----------------------------------
V501 There are identical sub-expressions 'this->GetMTime() > this->BuildTime' to the left and to the right of the '||' operator. vtkFiltering vtkdiscretizablecolortransferfunction.cxx 85

void vtkDiscretizableColorTransferFunction::Build()
{
  ...
  if (this->Discretize &&
      (this->GetMTime() > this->BuildTime ||
       this->GetMTime() > this->BuildTime))
  ...
}
----------------------------------
V501 There are identical sub-expressions to the left and to the right of the '||' operator: gridType == 11 || gridType == 11 vtkHybrid vtktransformtogrid.cxx 184

void vtkTransformToGrid::UpdateShiftScale()
{
  int gridType = this->GridScalarType;
  if (gridType == VTK_DOUBLE || gridType == VTK_DOUBLE)
  ...
}
----------------------------------
V501 There are identical sub-expressions to the left and to the right of the '>=' operator: allocateExtent[1] >= allocateExtent[1] vtkImaging vtkimagestencildata.cxx 1178

void vtkImageStencilRaster::PrepareForNewData(....)
{
  ...
  if (allocateExtent && allocateExtent[1] >= allocateExtent[1])
  ...
}
----------------------------------
V501 There are identical sub-expressions '(minX > imageViewportSize[0] - 1 && maxX > imageViewportSize[0] - 1)' to the left and to the right of the '||' operator. vtkVolumeRendering vtkfixedpointvolumeraycastmapper.cxx 2184

int vtkFixedPointVolumeRayCastMapper::ComputeRowBounds(....)
{
  if ( ( minX < 0 && maxX < 0 ) ||
       ( minY < 0 && maxY < 0 ) ||
       ( minX > imageViewportSize[0]-1 &&
         maxX > imageViewportSize[0]-1 ) ||
       ( minX > imageViewportSize[0]-1 &&
         maxX > imageViewportSize[0]-1 ) )
  ...
}
----------------------------------
V501 There are identical sub-expressions '(mat[0 * 4 + 3] != 0)' to the left and to the right of the '||' operator. vtkVolumeRendering vtkprojectedtetrahedramapper.cxx 134

template<class point_type>
void vtkProjectedTetrahedraMapperTransformPoints(....)
{
  ...
  if ( (mat[0*4+3] != 0) || (mat[1*4+3] != 0)
      || (mat[0*4+3] != 0) || (mat[1*4+3] != 1) )
  ...
}
----------------------------------
V501 There are identical sub-expressions 'sub->negNsSet->value' to the left and to the right of the '==' operator. vtklibxml2 xmlschemas.c 13873

static int
xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
                          xmlSchemaWildcardPtr super)
{
  ...
  if ((sub->negNsSet != NULL) &&
      (super->negNsSet != NULL) &&
      (sub->negNsSet->value == sub->negNsSet->value))
      return (0);
  ...
}
----------------------------------
V517 The use of 'if (A) {...} else if (A) {...}' pattern was detected. There is a probability of logical error presence. Check lines: 224, 227. lproj lproj.c 224

static void vprocess(FILE *fid) {
  char *s;
  ...
  if (*s == 'I' || *s == 'i') {
    linvers = 1;
    ++s;
  } else if (*s == 'I' || *s == 'i') {
    linvers = 0;
    ++s;
  } else
  ...
}
----------------------------------
V521 Such expressions using the ',' operator are dangerous. Make sure the expression 'this->Internal->TableArrays[i], name' is correct. vtkIO vtksesamereader.cxx 352

int vtkSESAMEReader::GetTableArrayStatus(const char* name)
{
  ...
  for(i=0; i<numArrays; i++)
  {
    if(this->Internal->TableArrays[i], name)
    {
      return this->Internal->TableArrayStatus[i];
    }
  }
  return 0;
}
----------------------------------
V522 Dereferencing of the null pointer 'td' might take place. CommonCxxTests testconditionvariable.cxx 96

VTK_THREAD_RETURN_TYPE vtkTestCondVarThread( void* arg )
{
  ...
  if ( td )
  {
    ...
  }
  else
  {
    cout << "No thread data!\n";
    cout << " Thread " << ( threadId + 1 )
         << " of " << threadCount << " exiting.\n";

    -- td->NumberOfWorkers; // dereferencing of the null pointer!

    cout.flush();
  }
  ...
}
----------------------------------
V523 The 'then' statement is equivalent to the 'else' statement. vtkRendering vtkobjexporter.cxx 324

void vtkOBJExporter::WriteAnActor(....)
{
  ...
  if (i%2)
  {
    i1 = i - 1;
    i2 = i - 2;
  }
  else
  {
    i1 = i - 1;
    i2 = i - 2;
  }
  ...
}
----------------------------------
V528 It is odd that pointer to 'char' type is compared with the '\0' value. Probably meant: *this->GeometryFileName == '\0'. vtkIO vtkbyureader.cxx 109

int vtkBYUReader::RequestData(....)
{
  ...
  if (this->GeometryFileName == NULL ||
      this->GeometryFileName == '\0')
  ...
}
----------------------------------
V530 The return value of function 'empty' is required to be utilized. vtkRendering vtklabelhierarchy.cxx 425

std::vector<int> Path;

void vtkLabelHierarchyFrustumIterator::Next()
{
  ...
  this->Path.empty();
  ...
}

Fix:
this->Path.clear();
----------------------------------
V535 The variable 'i' is being used for this loop and for the outer loop. vtkIO vtklsdynareader.cxx 506

FillBlock(....)
{
  ...
  for (vtkIdType i=0; i<p->Dict["NSURF"]; ++i)
  {
    ...
    for (vtkIdType t=0; t<segSz; ++t, ++currentCell)
    {
      ...
      for ( i=0; i<4; ++i )
      { ... }
      ...
    }
    ...
  }
  ...
}

Also:
V535 The variable 'i' is being used for this loop and for the outer loop. vtklibxml2 xmlregexp.c 590
----------------------------------
V547 Expression is always true. Probably the '&&' operator should be used here. vtkHybrid vtkmniobjectreader.cxx 161

int vtkMNIObjectReader::CanReadFile(const char* fname)
{
  ...
  if (objType == 'P' || objType != 'L' ||
      objType == 'M' || objType != 'F' ||
      objType == 'X' || objType != 'Q' ||
      objType == 'T')
  ...
}
----------------------------------
V547 Expression is always true. Probably the '&&' operator should be used here. vtkIO vtknetcdfcfreader.cxx 838

int vtkNetCDFCFReader::RequestDataObject(....)
{
  if ( (preferredDataType != VTK_IMAGE_DATA)
       || (preferredDataType != VTK_RECTILINEAR_GRID) )
  {
  vtkWarningMacro("You have set the OutputType to a data type that"
                  " cannot fully represent the topology of the data."
                  " Some of the topology will be ignored.");
  }
}

Also:
V547 Expression is always true. Probably the '&&' operator should be used here. vtkIO vtknetcdfcfreader.cxx 847
----------------------------------
V557 Array overrun is possible. The '6' index is pointing beyond array bound. vtkGraphics vtkcursor2d.cxx 313

void vtkCursor2D::SetModelBounds(double bounds[6])
{
  this->SetModelBounds(bounds[0], bounds[1], bounds[2],
                       bounds[3], bounds[6], bounds[5]);
}
----------------------------------
Also many V595. I have not studied it.
----------------------------------

Andrey Karpov,
Cand. Sc. (Physics and Mathematics), CTO
OOO "Program Verification Systems" (Co Ltd)
URL: www.viva64.com
E-Mail: karpov@viva64.com
TagsNo tags attached.
ProjectTBD
Typeincorrect functionality
Attached Files

 Relationships

  Notes
(0029167)
David Gobbi (developer)
2012-09-11 00:27

Fixed for VTK 6.0 in the following commits:

67478f3c vtkDataSetAttributesCopyValues
d326b094 vtkTransformToGrid
6aa5524e vtkOBJExporter
d6846a9b the rest

 Issue History
Date Modified Username Field Change
2012-08-24 04:29 Andrey New Issue
2012-09-11 00:25 David Gobbi Assigned To => David Gobbi
2012-09-11 00:25 David Gobbi Status backlog => tabled
2012-09-11 00:27 David Gobbi Note Added: 0029167
2012-09-11 00:27 David Gobbi Status tabled => closed
2012-09-11 00:27 David Gobbi Resolution open => fixed


Copyright © 2000 - 2018 MantisBT Team