+ fixes #0002075: Analysis of FreeCAD by PVS-Studio static analyzer

This commit is contained in:
wmayer
2015-05-01 16:56:31 +02:00
parent d8f63bcfd1
commit dd2b39ddd6
21 changed files with 59 additions and 91 deletions

View File

@@ -78,9 +78,9 @@ SET(Drawing_Templates
)
if(MSVC)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" Drawing_CPP_SRCS ${Drawing_SRCS} ${Features_SRCS} ${DrawingAlgos_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(Drawing PreCompiled.h PreCompiled.cpp Drawing_CPP_SRCS)
#add_definitions(-D_PreComp_)
#GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" Drawing_CPP_SRCS ${Drawing_SRCS} ${Features_SRCS} ${DrawingAlgos_SRCS})
#ADD_MSVC_PRECOMPILED_HEADER(Drawing PreCompiled.h PreCompiled.cpp Drawing_CPP_SRCS)
endif(MSVC)
add_library(Drawing SHARED ${Drawing_SRCS} ${Features_SRCS} ${DrawingAlgos_SRCS})

View File

@@ -81,9 +81,9 @@ SET(DrawingGuiTaskDlgs_SRCS
SOURCE_GROUP("TaskDialogs" FILES ${DrawingGuiTaskDlgs_SRCS})
if(MSVC)
add_definitions(-D_PreComp_)
GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${DrawingGui_SRCS} ${DrawingGuiView_SRCS} ${DrawingGuiViewProvider_SRCS})
ADD_MSVC_PRECOMPILED_HEADER(DrawingGui PreCompiled.h PreCompiled.cpp PCH_SRCS)
#add_definitions(-D_PreComp_)
#GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${DrawingGui_SRCS} ${DrawingGuiView_SRCS} ${DrawingGuiViewProvider_SRCS})
#ADD_MSVC_PRECOMPILED_HEADER(DrawingGui PreCompiled.h PreCompiled.cpp PCH_SRCS)
endif(MSVC)
add_library(DrawingGui SHARED ${DrawingGui_SRCS} ${DrawingGuiView_SRCS} ${DrawingGuiViewProvider_SRCS})

View File

@@ -689,9 +689,10 @@ void ViewProviderFEMMeshBuilder::buildNodes(const App::Property* prop, std::vect
inline void insEdgeVec(std::map<int,std::set<int> > &map, int n1, int n2)
{
if(n1<n2)
map[n2].insert(n1);
else
//FIXME: The if-else distinction doesn't make sense
//if (n1<n2)
// map[n2].insert(n1);
//else
map[n2].insert(n1);
};

View File

@@ -1053,11 +1053,11 @@ void ViewProviderMesh::boxZoom(const SbBox2s& box, const SbViewportRegion & vp,
float scaleX = (float)sizeX/(float)size[0];
float scaleY = (float)sizeY/(float)size[1];
float scale = std::max<float>(scaleX, scaleY);
if (cam && cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
if (cam->getTypeId() == SoOrthographicCamera::getClassTypeId()) {
float height = static_cast<SoOrthographicCamera*>(cam)->height.getValue() * scale;
static_cast<SoOrthographicCamera*>(cam)->height = height;
}
else if (cam && cam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) {
else if (cam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) {
float height = static_cast<SoPerspectiveCamera*>(cam)->heightAngle.getValue() / 2.0f;
height = 2.0f * atan(tan(height) * scale);
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = height;

View File

@@ -777,7 +777,7 @@ bool FaceTypedBSpline::isEqual(const TopoDS_Face &faceOne, const TopoDS_Face &fa
return false;
if (surfaceOne->IsURational() != surfaceTwo->IsURational()) return false;
if (surfaceTwo->IsVRational() != surfaceTwo->IsVRational()) return false;
if (surfaceOne->IsVRational() != surfaceTwo->IsVRational()) return false;
if (surfaceOne->IsUPeriodic() != surfaceTwo->IsUPeriodic()) return false;
if (surfaceOne->IsVPeriodic() != surfaceTwo->IsVPeriodic()) return false;
if (surfaceOne->IsUClosed() != surfaceTwo->IsUClosed()) return false;

View File

@@ -183,10 +183,10 @@ ResultEntry::ResultEntry()
ResultEntry::~ResultEntry()
{
if (boxSep)
if (boxSep && viewProviderRoot)
viewProviderRoot->removeChild(boxSep);
if (viewProviderRoot)
viewProviderRoot->unref();
viewProviderRoot->unref();
qDeleteAll(children);
}

View File

@@ -225,10 +225,11 @@ Py::Int WaypointPy::getTool(void) const
void WaypointPy::setTool(Py::Int arg)
{
if((int)arg.operator long() > 0)
getWaypointPtr()->Tool = (int)arg.operator long();
long value = static_cast<long>(arg);
if (value >= 0)
getWaypointPtr()->Tool = value;
else
Base::Exception("negativ tool not allowed!");
throw Py::ValueError("negative tool not allowed!");
}
Py::Int WaypointPy::getBase(void) const
@@ -238,10 +239,11 @@ Py::Int WaypointPy::getBase(void) const
void WaypointPy::setBase(Py::Int arg)
{
if((int)arg.operator long() > 0)
getWaypointPtr()->Base = (int)arg.operator long();
long value = static_cast<long>(arg);
if (value >= 0)
getWaypointPtr()->Base = value;
else
Base::Exception("negativ base not allowed!");
throw Py::ValueError("negative base not allowed!");
}
PyObject *WaypointPy::getCustomAttributes(const char* /*attr*/) const

View File

@@ -206,9 +206,9 @@ void ViewProviderRobotObject::updateData(const App::Property* prop)
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
std::string typeName = (const char*)node->getTypeId().getName();
Axis1Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 2
@@ -219,9 +219,9 @@ void ViewProviderRobotObject::updateData(const App::Property* prop)
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
std::string typeName = (const char*)node->getTypeId().getName();
Axis2Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 3
@@ -232,9 +232,9 @@ void ViewProviderRobotObject::updateData(const App::Property* prop)
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
std::string typeName = (const char*)node->getTypeId().getName();
Axis3Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 4
@@ -245,9 +245,9 @@ void ViewProviderRobotObject::updateData(const App::Property* prop)
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
std::string typeName = (const char*)node->getTypeId().getName();
Axis4Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 5
@@ -258,9 +258,9 @@ void ViewProviderRobotObject::updateData(const App::Property* prop)
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
std::string typeName = (const char*)node->getTypeId().getName();
Axis5Node = static_cast<SoVRMLTransform *>(node);
}
// Axis 6
@@ -271,9 +271,9 @@ void ViewProviderRobotObject::updateData(const App::Property* prop)
path = searchAction.getPath();
if(path){
SoNode* node = path->getTail();
std::string typeName = (const char*)node->getTypeId().getName();
if (!node || node->getTypeId() != SoVRMLTransform::getClassTypeId())
throw; // should not happen
std::string typeName = (const char*)node->getTypeId().getName();
Axis6Node = static_cast<SoVRMLTransform *>(node);
}
if(Axis1Node)

View File

@@ -182,8 +182,7 @@ int Sketch::addGeometry(const Part::Geometry *geo, bool fixed)
// create the definition struct for that geom
return addArcOfEllipse(*aoe, fixed);
} else {
Base::Exception("Sketch::addGeometry(): Unknown or unsupported type added to a sketch");
return 0;
throw Base::TypeError("Sketch::addGeometry(): Unknown or unsupported type added to a sketch");
}
}

View File

@@ -89,7 +89,7 @@ namespace GCS
class Curve //a base class for all curve-based objects (line, circle/arc, ellipse/arc)
{
public:
virtual ~Curve(){}
//returns normal vector. The vector should point to the left when one
// walks along the curve from start to end. Ellipses and circles are
// assumed to be walked counterclockwise, so the vector should point
@@ -111,6 +111,7 @@ namespace GCS
{
public:
Line(){}
virtual ~Line(){}
Point p1;
Point p2;
DeriVector2 CalculateNormal(Point &p, double* derivparam = 0);
@@ -123,6 +124,7 @@ namespace GCS
{
public:
Circle(){rad = 0;}
virtual ~Circle(){}
Point center;
double *rad;
DeriVector2 CalculateNormal(Point &p, double* derivparam = 0);
@@ -135,6 +137,7 @@ namespace GCS
{
public:
Arc(){startAngle=0;endAngle=0;rad=0;}
virtual ~Arc(){}
double *startAngle;
double *endAngle;
//double *rad; //inherited
@@ -150,6 +153,7 @@ namespace GCS
{
public:
Ellipse(){ radmin = 0;}
virtual ~Ellipse(){}
Point center;
Point focus1;
double *radmin;
@@ -166,6 +170,7 @@ namespace GCS
{
public:
ArcOfEllipse(){startAngle=0;endAngle=0;radmin = 0;}
virtual ~ArcOfEllipse(){}
double *startAngle;
double *endAngle;
//double *radmin; //inherited

View File

@@ -992,7 +992,7 @@ void PropertySheet::recomputeDependants(const Property *prop)
assert(name != 0);
if (owner && name) {
if (name) {
const char * docName = owner->getDocument()->Label.getValue();
const char * nameInDoc = owner->getNameInDocument();