From 03b6ce08cc5522232b17ac07ee8fe7e4938b1a29 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 19 Oct 2015 09:10:39 +0300 Subject: [PATCH] Coverity scan. --HG-- branch : develop --- src/app/tape/mapplication.cpp | 1 + src/libs/vdxf/dxflib/dl_dxf.cpp | 12 ++++++++++++ .../toollinepoint/vtoolcurveintersectaxis.cpp | 2 +- .../toolpoint/toolsinglepoint/vtoolsinglepoint.cpp | 2 +- src/test/ValentinaTest/tst_measurementregexp.cpp | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/app/tape/mapplication.cpp b/src/app/tape/mapplication.cpp index 538b0aaa6..3951dc374 100644 --- a/src/app/tape/mapplication.cpp +++ b/src/app/tape/mapplication.cpp @@ -144,6 +144,7 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con break; #endif case QtDebugMsg: + Q_UNREACHABLE(); default: break; } diff --git a/src/libs/vdxf/dxflib/dl_dxf.cpp b/src/libs/vdxf/dxflib/dl_dxf.cpp index b4d79c966..a6a00fbfc 100644 --- a/src/libs/vdxf/dxflib/dl_dxf.cpp +++ b/src/libs/vdxf/dxflib/dl_dxf.cpp @@ -316,6 +316,12 @@ bool DL_Dxf::getStrippedLine(std::string &s, unsigned int size, */ bool DL_Dxf::stripWhiteSpace(char** s) { + // No need to check if string is null + if (not (*s)) + { + return false; + } + // last non-NULL char: int lastChar = static_cast(strlen(*s) - 1); @@ -5927,6 +5933,12 @@ void DL_Dxf::test() stripWhiteSpace(&buf6); std::cout << "2 buf6: '" << buf6 << "'\n"; + delete[] buf1; + delete[] buf2; + delete[] buf3; + delete[] buf4; + delete[] buf5; + delete[] buf6; } diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp index c24bc4dc9..03478cf1e 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/toollinepoint/vtoolcurveintersectaxis.cpp @@ -146,7 +146,7 @@ QPointF VToolCurveIntersectAxis::FindPoint(const QPointF &point, qreal angle, const QSharedPointer &curve) { QRectF rec = QRectF(0, 0, INT_MAX, INT_MAX); - rec.translate(static_cast(-INT_MAX/2), static_cast(-INT_MAX/2)); + rec.translate(-INT_MAX/2.0, -INT_MAX/2.0); const QLineF axis = VGObject::BuildAxis(point, angle, rec); QVector points = curve->IntersectLine(axis); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 8c3cd0662..65aca2dc7 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -114,7 +114,7 @@ void VToolSinglePoint::NameChangePosition(const QPointF &pos) */ void VToolSinglePoint::UpdateNamePosition(quint32 id) { - VPointF *point = new VPointF(*VAbstractTool::data.GeometricObject(id)); + const QSharedPointer point = VAbstractTool::data.GeometricObject(id); MoveLabel *moveLabel = new MoveLabel(doc, point->mx(), point->my(), id, this->scene()); connect(moveLabel, &MoveLabel::NeedLiteParsing, doc, &VAbstractPattern::LiteParseTree); qApp->getUndoStack()->push(moveLabel); diff --git a/src/test/ValentinaTest/tst_measurementregexp.cpp b/src/test/ValentinaTest/tst_measurementregexp.cpp index c7b2f94b0..b459d1862 100644 --- a/src/test/ValentinaTest/tst_measurementregexp.cpp +++ b/src/test/ValentinaTest/tst_measurementregexp.cpp @@ -132,6 +132,7 @@ void TST_MeasurementRegExp::TestMeasurementRegExp() } delete pmsTranslator; } + break; } default: QWARN("Unexpected state");