Cppcheck warnings.

--HG--
branch : release
This commit is contained in:
Roman Telezhynskyi 2016-08-15 21:06:04 +03:00
parent ba36ab3c71
commit dde8f9638e
13 changed files with 60 additions and 52 deletions

View File

@ -219,7 +219,6 @@ inline void noisyFailureMsgHandler(QtMsgType type, const QMessageLogContext &con
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress uninitMemberVar
MApplication::MApplication(int &argc, char **argv) MApplication::MApplication(int &argc, char **argv)
:VAbstractApplication(argc, argv), :VAbstractApplication(argc, argv),
mainWindows(), mainWindows(),

View File

@ -587,9 +587,7 @@ QStringList VApplication::LabelLanguages()
void VApplication::StartLogging() void VApplication::StartLogging()
{ {
CreateLogDir(); CreateLogDir();
// cppcheck-suppress leakReturnValNotUsed
BeginLogging(); BeginLogging();
// cppcheck-suppress leakReturnValNotUsed
ClearOldLogs(); ClearOldLogs();
#if defined(Q_OS_WIN) && defined(Q_CC_GNU) #if defined(Q_OS_WIN) && defined(Q_CC_GNU)
ClearOldReports(); ClearOldReports();
@ -847,7 +845,6 @@ void VApplication::CollectReport(const QString &reportName) const
reportFile.remove(); // Clear after yourself reportFile.remove(); // Clear after yourself
filename = QString("%1/reports/log-%2.log").arg(qApp->applicationDirPath()).arg(timestamp); filename = QString("%1/reports/log-%2.log").arg(qApp->applicationDirPath()).arg(timestamp);
// cppcheck-suppress leakReturnValNotUsed
GatherLogs(); GatherLogs();
QFile logFile(QString("%1/valentina.log").arg(LogDirPath())); QFile logFile(QString("%1/valentina.log").arg(LogDirPath()));
logFile.copy(filename); // Collect log logFile.copy(filename); // Collect log
@ -911,7 +908,6 @@ void VApplication::SendReport(const QString &reportName) const
content.append(QString("\r\n-------------------------------\r\n")); content.append(QString("\r\n-------------------------------\r\n"));
content.append(QString("Log:")+"\r\n"); content.append(QString("Log:")+"\r\n");
// cppcheck-suppress leakReturnValNotUsed
GatherLogs(); GatherLogs();
QFile logFile(QString("%1/valentina.log").arg(LogDirPath())); QFile logFile(QString("%1/valentina.log").arg(LogDirPath()));
if (logFile.open(QIODevice::ReadOnly | QIODevice::Text)) if (logFile.open(QIODevice::ReadOnly | QIODevice::Text))

View File

@ -379,7 +379,7 @@ quint32 VDomDocument::GetParametrId(const QDomElement &domElement) const
try try
{ {
id = GetParametrUInt(domElement, VDomDocument::AttrId, NULL_ID_STR); id = GetParametrUInt(domElement, VDomDocument::AttrId, NULL_ID_STR);
if (id <= 0) if (id == 0)
{ {
throw VExceptionWrongId(message, domElement); throw VExceptionWrongId(message, domElement);
} }
@ -467,6 +467,7 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
{ {
qCDebug(vXML, "Validation xml file %s.", qUtf8Printable(fileName)); qCDebug(vXML, "Validation xml file %s.", qUtf8Printable(fileName));
QFile pattern(fileName); QFile pattern(fileName);
// cppcheck-suppress ConfigurationNotChecked
if (pattern.open(QIODevice::ReadOnly) == false) if (pattern.open(QIODevice::ReadOnly) == false)
{ {
const QString errorMsg(tr("Can't open file %1:\n%2.").arg(fileName).arg(pattern.errorString())); const QString errorMsg(tr("Can't open file %1:\n%2.").arg(fileName).arg(pattern.errorString()));
@ -474,6 +475,7 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
} }
QFile fileSchema(schema); QFile fileSchema(schema);
// cppcheck-suppress ConfigurationNotChecked
if (fileSchema.open(QIODevice::ReadOnly) == false) if (fileSchema.open(QIODevice::ReadOnly) == false)
{ {
pattern.close(); pattern.close();
@ -524,6 +526,7 @@ void VDomDocument::ValidateXML(const QString &schema, const QString &fileName)
void VDomDocument::setXMLContent(const QString &fileName) void VDomDocument::setXMLContent(const QString &fileName)
{ {
QFile file(fileName); QFile file(fileName);
// cppcheck-suppress ConfigurationNotChecked
if (file.open(QIODevice::ReadOnly) == false) if (file.open(QIODevice::ReadOnly) == false)
{ {
const QString errorMsg(tr("Can't open file %1:\n%2.").arg(fileName).arg(file.errorString())); const QString errorMsg(tr("Can't open file %1:\n%2.").arg(fileName).arg(file.errorString()));
@ -662,6 +665,7 @@ bool VDomDocument::SaveDocument(const QString &fileName, QString &error) const
} }
bool success = false; bool success = false;
QSaveFile file(fileName); QSaveFile file(fileName);
// cppcheck-suppress ConfigurationNotChecked
if (file.open(QIODevice::WriteOnly)) if (file.open(QIODevice::WriteOnly))
{ {
const int indent = 4; const int indent = 4;
@ -790,6 +794,7 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
QTemporaryFile destFile(destination + QLatin1Literal(".XXXXXX")); QTemporaryFile destFile(destination + QLatin1Literal(".XXXXXX"));
destFile.setAutoRemove(false); destFile.setAutoRemove(false);
// cppcheck-suppress ConfigurationNotChecked
if (not destFile.open()) if (not destFile.open())
{ {
error = destFile.errorString(); error = destFile.errorString();
@ -798,6 +803,7 @@ bool VDomDocument::SafeCopy(const QString &source, const QString &destination, Q
else else
{ {
QFile sourceFile(source); QFile sourceFile(source);
// cppcheck-suppress ConfigurationNotChecked
if (sourceFile.open(QIODevice::ReadOnly)) if (sourceFile.open(QIODevice::ReadOnly))
{ {
result = true; result = true;

View File

@ -50,7 +50,7 @@ class QMUPARSERSHARED_EXPORT QmuParserTester : public QObject // final
public: public:
typedef int ( QmuParserTester::*testfun_type ) (); typedef int ( QmuParserTester::*testfun_type ) ();
QmuParserTester(QObject *parent = nullptr); explicit QmuParserTester(QObject *parent = nullptr);
public slots: public slots:
void Run(); void Run();

View File

@ -172,6 +172,7 @@ bool DL_Dxf::in(std::stringstream& stream,
*/ */
bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface) bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface)
{ {
// cppcheck-suppress variableScope
static int line = 1; static int line = 1;
// Read one group of the DXF file and strip the lines: // Read one group of the DXF file and strip the lines:
@ -196,6 +197,7 @@ bool DL_Dxf::readDxfGroups(FILE *fp, DL_CreationInterface* creationInterface)
bool DL_Dxf::readDxfGroups(std::stringstream& stream, bool DL_Dxf::readDxfGroups(std::stringstream& stream,
DL_CreationInterface* creationInterface) DL_CreationInterface* creationInterface)
{ {
// cppcheck-suppress variableScope
static int line = 1; static int line = 1;
// Read one group of the DXF file and chop the lines: // Read one group of the DXF file and chop the lines:

View File

@ -53,8 +53,8 @@ VArc::VArc ()
* @param f1 start angle (degree). * @param f1 start angle (degree).
* @param f2 end angle (degree). * @param f2 end angle (degree).
*/ */
VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, VArc::VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
QString formulaF2, quint32 idObject, Draw mode) qreal f2, const QString &formulaF2, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::Arc, idObject, mode), : VAbstractCurve(GOType::Arc, idObject, mode),
d (new VArcData(center, radius, formulaRadius, f1, formulaF1, f2, formulaF2)) d (new VArcData(center, radius, formulaRadius, f1, formulaF1, f2, formulaF2))
{ {
@ -62,15 +62,15 @@ VArc::VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QStri
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::VArc(VPointF center, qreal radius, qreal f1, qreal f2) VArc::VArc(const VPointF &center, qreal radius, qreal f1, qreal f2)
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1, f2)) : VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1, f2))
{ {
ArcName(); ArcName();
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::VArc(qreal length, QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1, VArc::VArc(qreal length, const QString &formulaLength, const VPointF &center, qreal radius,
QString formulaF1, quint32 idObject, Draw mode) const QString &formulaRadius, qreal f1, const QString &formulaF1, quint32 idObject, Draw mode)
: VAbstractCurve(GOType::Arc, idObject, mode), : VAbstractCurve(GOType::Arc, idObject, mode),
d (new VArcData(formulaLength, center, radius, formulaRadius, f1, formulaF1)) d (new VArcData(formulaLength, center, radius, formulaRadius, f1, formulaF1))
{ {
@ -79,7 +79,7 @@ VArc::VArc(qreal length, QString formulaLength, VPointF center, qreal radius, QS
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
VArc::VArc(qreal length, VPointF center, qreal radius, qreal f1) VArc::VArc(qreal length, const VPointF &center, qreal radius, qreal f1)
: VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1)) : VAbstractCurve(GOType::Arc, NULL_ID, Draw::Calculation), d (new VArcData(center, radius, f1))
{ {
ArcName(); ArcName();

View File

@ -44,12 +44,12 @@ class VArc: public VAbstractCurve
Q_DECLARE_TR_FUNCTIONS(VArc) Q_DECLARE_TR_FUNCTIONS(VArc)
public: public:
VArc (); VArc ();
VArc (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, VArc (const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1, const QString &formulaF1,
QString formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation); qreal f2, const QString &formulaF2, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (VPointF center, qreal radius, qreal f1, qreal f2); VArc (const VPointF &center, qreal radius, qreal f1, qreal f2);
VArc (qreal length, QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1, VArc (qreal length, const QString &formulaLength, const VPointF &center, qreal radius, const QString &formulaRadius,
QString formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation); qreal f1, const QString &formulaF1, quint32 idObject = 0, Draw mode = Draw::Calculation);
VArc (qreal length, VPointF center, qreal radius, qreal f1); VArc (qreal length, const VPointF &center, qreal radius, qreal f1);
VArc(const VArc &arc); VArc(const VArc &arc);
VArc& operator= (const VArc &arc); VArc& operator= (const VArc &arc);
virtual ~VArc() Q_DECL_OVERRIDE; virtual ~VArc() Q_DECL_OVERRIDE;

View File

@ -47,23 +47,24 @@ public:
center(VPointF()), isFlipped(false), formulaLength() center(VPointF()), isFlipped(false), formulaLength()
{} {}
VArcData (VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1, qreal f2, VArcData (const VPointF &center, qreal radius,const QString &formulaRadius, qreal f1, const QString &formulaF1,
QString formulaF2) qreal f2, const QString &formulaF2)
: f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius), : f1(f1), formulaF1(formulaF1), f2(f2), formulaF2(formulaF2), radius(radius), formulaRadius(formulaRadius),
center(center), isFlipped(false), formulaLength() center(center), isFlipped(false), formulaLength()
{} {}
VArcData(VPointF center, qreal radius, qreal f1, qreal f2) VArcData(const VPointF &center, qreal radius, qreal f1, qreal f2)
: f1(f1), formulaF1(QString("%1").arg(f1)), f2(f2), formulaF2(QString("%1").arg(f2)), radius(radius), : f1(f1), formulaF1(QString("%1").arg(f1)), f2(f2), formulaF2(QString("%1").arg(f2)), radius(radius),
formulaRadius(QString("%1").arg(radius)), center(center), isFlipped(false), formulaLength() formulaRadius(QString("%1").arg(radius)), center(center), isFlipped(false), formulaLength()
{} {}
VArcData (QString formulaLength, VPointF center, qreal radius, QString formulaRadius, qreal f1, QString formulaF1 ) VArcData (const QString &formulaLength, const VPointF &center, qreal radius, const QString &formulaRadius, qreal f1,
QString formulaF1 )
: f1(f1), formulaF1(formulaF1), f2(0), formulaF2("0"), radius(radius), formulaRadius(formulaRadius), : f1(f1), formulaF1(formulaF1), f2(0), formulaF2("0"), radius(radius), formulaRadius(formulaRadius),
center(center), isFlipped(false), formulaLength(formulaLength) center(center), isFlipped(false), formulaLength(formulaLength)
{} {}
VArcData(VPointF center, qreal radius, qreal f1) VArcData(const VPointF &center, qreal radius, qreal f1)
: f1(f1), formulaF1(QString("%1").arg(f1)), f2(0), formulaF2("0"), radius(radius), : f1(f1), formulaF1(QString("%1").arg(f1)), f2(0), formulaF2("0"), radius(radius),
formulaRadius(QString("%1").arg(radius)), center(center), isFlipped(false), formulaLength() formulaRadius(QString("%1").arg(radius)), center(center), isFlipped(false), formulaLength()
{} {}

View File

@ -60,8 +60,8 @@ VSpline::VSpline ( const VSpline & spline )
* @param kAsm1 coefficient of length first control line. * @param kAsm1 coefficient of length first control line.
* @param kAsm2 coefficient of length second control line. * @param kAsm2 coefficient of length second control line.
*/ */
VSpline::VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, VSpline::VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
quint32 idObject, Draw mode) qreal kCurve, quint32 idObject, Draw mode)
:VAbstractCurve(GOType::Spline, idObject, mode), d(new VSplineData(p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve)) :VAbstractCurve(GOType::Spline, idObject, mode), d(new VSplineData(p1, p4, angle1, angle2, kAsm1, kAsm2, kCurve))
{ {
CreateName(); CreateName();
@ -75,7 +75,8 @@ VSpline::VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm
* @param p3 second control point. * @param p3 second control point.
* @param p4 second point spline. * @param p4 second point spline.
*/ */
VSpline::VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, quint32 idObject, Draw mode) VSpline::VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, qreal kCurve,
quint32 idObject, Draw mode)
:VAbstractCurve(GOType::Spline, idObject, mode), d(new VSplineData(p1, p2, p3, p4, kCurve)) :VAbstractCurve(GOType::Spline, idObject, mode), d(new VSplineData(p1, p2, p3, p4, kCurve))
{ {
CreateName(); CreateName();

View File

@ -47,10 +47,10 @@ class VSpline :public VAbstractCurve
public: public:
VSpline(); VSpline();
VSpline (const VSpline &spline ); VSpline (const VSpline &spline );
VSpline (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve, VSpline (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve,
quint32 idObject = 0, Draw mode = Draw::Calculation);
VSpline (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, qreal kCurve,
quint32 idObject = 0, Draw mode = Draw::Calculation); quint32 idObject = 0, Draw mode = Draw::Calculation);
VSpline (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve, quint32 idObject = 0,
Draw mode = Draw::Calculation);
virtual ~VSpline() Q_DECL_OVERRIDE; virtual ~VSpline() Q_DECL_OVERRIDE;
VSpline &operator=(const VSpline &spl); VSpline &operator=(const VSpline &spl);
VPointF GetP1 () const; VPointF GetP1 () const;

View File

@ -51,7 +51,8 @@ public:
angle2(spline.angle2), kAsm1(spline.kAsm1), kAsm2(spline.kAsm2), kCurve(spline.kCurve) angle2(spline.angle2), kAsm1(spline.kAsm1), kAsm2(spline.kAsm2), kCurve(spline.kCurve)
{} {}
VSplineData (VPointF p1, VPointF p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2, qreal kCurve) VSplineData (const VPointF &p1, const VPointF &p4, qreal angle1, qreal angle2, qreal kAsm1, qreal kAsm2,
qreal kCurve)
:p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2), :p1(p1), p2(QPointF()), p3(QPointF()), p4(p4), angle1(angle1), angle2(angle2), kAsm1(kAsm1), kAsm2(kAsm2),
kCurve(kCurve) kCurve(kCurve)
{ {
@ -68,7 +69,7 @@ public:
this->p3 = p4p3.p2(); this->p3 = p4p3.p2();
} }
VSplineData (VPointF p1, QPointF p2, QPointF p3, VPointF p4, qreal kCurve) VSplineData (const VPointF &p1, const QPointF &p2, const QPointF &p3, const VPointF &p4, qreal kCurve)
:p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1) :p1(p1), p2(p2), p3(p3), p4(p4), angle1(0), angle2(0), kAsm1(1), kAsm2(1), kCurve(1)
{ {
this->angle1 = QLineF ( this->p1.toQPointF(), this->p2 ).angle(); this->angle1 = QLineF ( this->p1.toQPointF(), this->p2 ).angle();

View File

@ -44,13 +44,13 @@ QString compilerString()
#if defined(Q_CC_INTEL) // must be before GNU, Clang and MSVC because ICC/ICL claim to be them #if defined(Q_CC_INTEL) // must be before GNU, Clang and MSVC because ICC/ICL claim to be them
QString iccCompact; QString iccCompact;
#ifdef __INTEL_CLANG_COMPILER #ifdef __INTEL_CLANG_COMPILER
iccCompact = QLatin1Literal("Clang"); iccCompact = QLatin1String("Clang");
#elif defined(__INTEL_MS_COMPAT_LEVEL) #elif defined(__INTEL_MS_COMPAT_LEVEL)
iccCompact = QLatin1Literal("Microsoft"); iccCompact = QLatin1String("Microsoft");
#elif defined(__GNUC__) #elif defined(__GNUC__)
iccCompact = QLatin1Literal("GCC"); iccCompact = QLatin1String("GCC");
#else #else
iccCompact = QLatin1Literal("no"); iccCompact = QLatin1String("no");
#endif #endif
QString iccVersion; QString iccVersion;
if (__INTEL_COMPILER >= 1300) if (__INTEL_COMPILER >= 1300)
@ -88,8 +88,9 @@ QString compilerString()
{ {
return QLatin1String("MSVC ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15)); return QLatin1String("MSVC ") + QString::number(2008 + 2 * ((_MSC_VER / 100) - 15));
} }
#else
return QStringLiteral("<unknown compiler>");
#endif #endif
return QLatin1String("<unknown compiler>");
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -134,6 +134,7 @@ static point2d_t* point_alloc()
p = (point2d_t*)malloc(sizeof(point2d_t)); p = (point2d_t*)malloc(sizeof(point2d_t));
assert( p != NULL ); assert( p != NULL );
// cppcheck-suppress memsetClassFloat
memset(p, 0, sizeof(point2d_t)); memset(p, 0, sizeof(point2d_t));
return p; return p;