fix scan coverity issues

This commit is contained in:
wmayer
2018-02-10 14:29:49 +01:00
parent 707bbee6ae
commit 73522c3d10
9 changed files with 44 additions and 19 deletions

View File

@@ -676,8 +676,8 @@ void cLineSegment::SetPoints(Point3D & p1, Point3D & p2)
void cLineSegment::PointAt(float dist, Point3D & retp)
{
retp.x = pStart.x + pDir.x * dist;
retp.x = pStart.y + pDir.y * dist;
retp.x = pStart.z + pDir.z * dist;
retp.y = pStart.y + pDir.y * dist;
retp.z = pStart.z + pDir.z * dist;
}
//************************************************************************************************************
@@ -746,7 +746,7 @@ void cSimTool::InitTool() // pos is 0..1 location along the radius of the tool
}
}
cVolSim::cVolSim()
cVolSim::cVolSim() : stock(nullptr)
{
}

View File

@@ -36,10 +36,10 @@
#define SIM_WALK_RES 0.6 // step size in pixel units (to make sure all pixels in the path are visited)
struct Point3D
{
Point3D() {}
Point3D(float x, float y, float z) : x(x), y(y), z(z) {}
Point3D(Base::Vector3d & vec) : x(vec[0]), y(vec[1]), z(vec[2]) {}
Point3D(Base::Placement & pl) : x(pl.getPosition()[0]), y(pl.getPosition()[1]), z(pl.getPosition()[2]) {}
Point3D() : x(0), y(0), z(0), sina(0), cosa(0) {}
Point3D(float x, float y, float z) : x(x), y(y), z(z), sina(0), cosa(0) {}
Point3D(Base::Vector3d & vec) : x(vec[0]), y(vec[1]), z(vec[2]), sina(0), cosa(0) {}
Point3D(Base::Placement & pl) : x(pl.getPosition()[0]), y(pl.getPosition()[1]), z(pl.getPosition()[2]), sina(0), cosa(0) {}
inline void set(float px, float py, float pz) { x = px; y = py; z = pz; }
inline void Add(Point3D & p) { x += p.x; y += p.y; z += p.z; }
inline void Rotate() { float tx = x; x = x * cosa - y * sina; y = tx * sina + y * cosa; }
@@ -110,7 +110,7 @@ template <class T>
class Array2D
{
public:
Array2D() : data(nullptr) {}
Array2D() : data(nullptr), height(0) {}
~Array2D()
{

View File

@@ -81,6 +81,9 @@ bool CCurve::CheckForArc(const CVertex& prev_vt, std::list<const CVertex*>& migh
}
}
if (mid_vt == NULL)
return false;
// create a circle to test
Point p0(prev_vt.m_p);
Point p1(mid_vt->m_p);

View File

@@ -175,7 +175,7 @@ int PolyTree::Total() const
// PolyNode methods ...
//------------------------------------------------------------------------------
PolyNode::PolyNode(): Childs(), Parent(0), Index(0), m_IsOpen(false)
PolyNode::PolyNode(): Childs(), Parent(0), Index(0), m_IsOpen(false), m_jointype(jtSquare), m_endtype(etClosedPolygon)
{
}
//------------------------------------------------------------------------------
@@ -876,6 +876,8 @@ ClipperBase::ClipperBase() //constructor
{
m_CurrentLM = m_MinimaList.begin(); //begin() == end() here
m_UseFullRange = false;
m_PreserveCollinear = false;
m_HasOpenPaths = false;
}
//------------------------------------------------------------------------------
@@ -1347,6 +1349,10 @@ Clipper::Clipper(int initOptions) : ClipperBase() //constructor
#ifdef use_xyz
m_ZFill = 0;
#endif
m_ClipType = ctIntersection;
m_ClipFillType = pftEvenOdd;
m_SubjFillType = pftEvenOdd;
m_UsingPolyTree = false;
}
//------------------------------------------------------------------------------
@@ -3621,6 +3627,12 @@ ClipperOffset::ClipperOffset(double miterLimit, double arcTolerance)
this->MiterLimit = miterLimit;
this->ArcTolerance = arcTolerance;
m_lowest.X = -1;
m_delta = 0;
m_sinA = 0;
m_sin = 0;
m_cos = 0;
m_miterLim = 0;
m_StepsPerRad = 0;
}
//------------------------------------------------------------------------------

View File

@@ -164,6 +164,7 @@ void CDxfWrite::WriteEllipse(const double* c, double major_radius, double minor_
CDxfRead::CDxfRead(const char* filepath)
{
m_aci = 0;
// start the file
memset( m_unused_line, '\0', sizeof(m_unused_line) );
m_fail = false;
@@ -177,7 +178,6 @@ CDxfRead::CDxfRead(const char* filepath)
return;
}
m_ifs->imbue(std::locale("C"));
}
CDxfRead::~CDxfRead()
@@ -392,7 +392,7 @@ bool CDxfRead::ReadArc()
double start_angle = 0.0;// in degrees
double end_angle = 0.0;
double radius = 0.0;
double c[3]; // centre
double c[3] = {0,0,0}; // centre
while(!((*m_ifs).eof()))
{
@@ -657,7 +657,7 @@ bool CDxfRead::ReadSpline()
bool CDxfRead::ReadCircle()
{
double radius = 0.0;
double c[3]; // centre
double c[3] = {0,0,0}; // centre
while(!((*m_ifs).eof()))
{
@@ -807,8 +807,8 @@ bool CDxfRead::ReadText()
bool CDxfRead::ReadEllipse()
{
double c[3]; // centre
double m[3]; //major axis point
double c[3]={0,0,0}; // centre
double m[3]={1,0,0}; //major axis point
double ratio=0; //ratio of major to minor axis
double start=0; //start of arc
double end=0; // end of arc

View File

@@ -141,7 +141,7 @@ namespace geoff_geometry {
Point::Point(const Vector2d& v)
{
x = v.getx(); y = v.gety();
x = v.getx(); y = v.gety(); ok = true;
}
Point3d::Point3d(const Vector3d& v) {
@@ -369,6 +369,9 @@ namespace geoff_geometry {
pc = pc0;
radius = p.Dist(pc0);
}
else {
radius = 0;
}
}
Circle::Circle( const Span& sp){
@@ -779,6 +782,7 @@ namespace geoff_geometry {
// constructor plane from point & vector
normal = v;
if(normalise == true) normal.normalise();
ok = (normal != NULL_VECTOR);
d = -(normal * Vector3d(p0));
}
@@ -787,6 +791,7 @@ namespace geoff_geometry {
double mag = normal.normalise();
ok = (normal != NULL_VECTOR);
if(ok) d = dist / mag;
else d = 0;
}
double Plane::Dist(const Point3d& p)const{

View File

@@ -210,7 +210,7 @@ inline bool FNEZ(double a, double tolerance = TIGHT_TOLERANCE) {return fabs(a) >
double y; // y value
// constructors etc...
inline Point(){ ok=false;}; // Point p1
inline Point(){x=0; y=0; ok=false;} // Point p1
inline Point( double xord, double yord, bool okay = true) { // Point p1(10,30);
x = xord; y = yord; ok = okay;}
inline Point( const Point& p ) { // copy constructor Point p1(p2);

View File

@@ -67,8 +67,13 @@ using namespace Part;
TYPESYSTEM_SOURCE(Sketcher::Sketch, Base::Persistence)
Sketch::Sketch()
: SolveTime(0), RecalculateInitialSolutionWhileMovingPoint(false), GCSsys(), ConstraintsCounter(0), isInitMove(false), isFine(true),
defaultSolver(GCS::DogLeg),defaultSolverRedundant(GCS::DogLeg),debugMode(GCS::Minimal)
: SolveTime(0)
, RecalculateInitialSolutionWhileMovingPoint(false)
, GCSsys(), ConstraintsCounter(0)
, isInitMove(false), isFine(true), moveStep(0)
, defaultSolver(GCS::DogLeg)
, defaultSolverRedundant(GCS::DogLeg)
, debugMode(GCS::Minimal)
{
}

View File

@@ -806,7 +806,7 @@ void TaskSketcherConstrains::slotConstraintsChanged(void)
/* Update the states */
ui->listWidgetConstraints->blockSignals(true);
for (int i = 0; i < ui->listWidgetConstraints->count(); ++i) {
ConstraintItem * it = dynamic_cast<ConstraintItem*>(ui->listWidgetConstraints->item(i));
ConstraintItem * it = static_cast<ConstraintItem*>(ui->listWidgetConstraints->item(i));
it->updateVirtualSpaceStatus();
}
ui->listWidgetConstraints->blockSignals(false);