"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/cfg/qt.cpp" between
cppcheck-1.86.tar.gz and cppcheck-1.87.tar.gz

About: Cppcheck is a static analysis tool for C/C++ code. It checks for memory leaks, mismatching allocation-deallocation, buffer overrun, and many more.

qt.cpp  (cppcheck-1.86):qt.cpp  (cppcheck-1.87)
// Test library configuration for qt.cfg // Test library configuration for qt.cfg
// //
// Usage: // Usage:
// $ cppcheck --check-library --enable=information --inconclusive --error-exitco de=1 --suppress=missingIncludeSystem --inline-suppr --library=qt test/cfg/qt.cpp // $ cppcheck --check-library --enable=information --inconclusive --error-exitco de=1 --suppress=missingIncludeSystem --inline-suppr --library=qt test/cfg/qt.cpp
// => // =>
// No warnings about bad library configuration, unmatched suppressions, etc. exi tcode=0 // No warnings about bad library configuration, unmatched suppressions, etc. exi tcode=0
// //
class QString { #include <QObject>
public: #include <QString>
int size(); #include <QtPlugin>
char &operator[](int pos); #include <QFile>
};
void QString1(QString s) void QString1(QString s)
{ {
for (int i = 0; i <= s.size(); ++i) { for (int i = 0; i <= s.size(); ++i) {
// cppcheck-suppress stlOutOfBounds // cppcheck-suppress stlOutOfBounds
s[i] = 'x'; s[i] = 'x';
} }
} }
int QString2() int QString2()
{ {
QString s; QString s;
// cppcheck-suppress reademptycontainer // FIXME cppcheck-suppress reademptycontainer
return s.size(); return s.size();
} }
// Verify that Qt macros do not result in syntax errors, false positives or othe
r issues.
class MacroTest1: public QObject {
Q_OBJECT
Q_PLUGIN_METADATA(IID "com.foo.bar" FILE "test.json")
public:
explicit MacroTest1(QObject *parent = 0);
~MacroTest1();
};
void validCode(int * pIntPtr)
{
if (QFile::exists("test")) {
}
if (pIntPtr != Q_NULLPTR) {
*pIntPtr = 5;
}
}
void ignoredReturnValue()
{
// cppcheck-suppress ignoredReturnValue
QFile::exists("test");
QFile file1("test");
// cppcheck-suppress ignoredReturnValue
file1.exists();
}
void nullPointer(int * pIntPtr)
{
int * pNullPtr = Q_NULLPTR;
// cppcheck-suppress nullPointer
*pNullPtr = 1;
if (pIntPtr != Q_NULLPTR) {
*pIntPtr = 2;
} else {
// cppcheck-suppress nullPointerRedundantCheck
*pIntPtr = 3;
}
}
 End of changes. 3 change blocks. 
6 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)