Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions gui/projectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,9 @@ QString ProjectFile::readString(QXmlStreamReader &reader)

void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
bool allRead = false;
do {
type = reader.readNext();
QXmlStreamReader::TokenType type = reader.readNext();
switch (type) {
case QXmlStreamReader::StartElement:

Expand Down Expand Up @@ -426,10 +425,9 @@ void ProjectFile::readIncludeDirs(QXmlStreamReader &reader)

void ProjectFile::readDefines(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
bool allRead = false;
do {
type = reader.readNext();
QXmlStreamReader::TokenType type = reader.readNext();
switch (type) {
case QXmlStreamReader::StartElement:
// Read define-elements
Expand Down Expand Up @@ -463,10 +461,9 @@ void ProjectFile::readDefines(QXmlStreamReader &reader)

void ProjectFile::readCheckPaths(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
bool allRead = false;
do {
type = reader.readNext();
QXmlStreamReader::TokenType type = reader.readNext();
switch (type) {
case QXmlStreamReader::StartElement:

Expand Down Expand Up @@ -501,10 +498,9 @@ void ProjectFile::readCheckPaths(QXmlStreamReader &reader)

void ProjectFile::readExcludes(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
bool allRead = false;
do {
type = reader.readNext();
QXmlStreamReader::TokenType type = reader.readNext();
switch (type) {
case QXmlStreamReader::StartElement:
// Read exclude-elements
Expand Down Expand Up @@ -547,9 +543,8 @@ void ProjectFile::readExcludes(QXmlStreamReader &reader)

void ProjectFile::readVsConfigurations(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
do {
type = reader.readNext();
QXmlStreamReader::TokenType type = reader.readNext();
switch (type) {
case QXmlStreamReader::StartElement:
// Read library-elements
Expand Down Expand Up @@ -611,9 +606,8 @@ void ProjectFile::readPlatform(QXmlStreamReader &reader)

void ProjectFile::readSuppressions(QXmlStreamReader &reader)
{
QXmlStreamReader::TokenType type;
do {
type = reader.readNext();
QXmlStreamReader::TokenType type = reader.readNext();
switch (type) {
case QXmlStreamReader::StartElement:
// Read library-elements
Expand Down Expand Up @@ -658,9 +652,8 @@ void ProjectFile::readSuppressions(QXmlStreamReader &reader)

void ProjectFile::readTagWarnings(QXmlStreamReader &reader, const QString &tag)
{
QXmlStreamReader::TokenType type;
do {
type = reader.readNext();
QXmlStreamReader::TokenType type = reader.readNext();
switch (type) {
case QXmlStreamReader::StartElement:
// Read library-elements
Expand Down Expand Up @@ -693,10 +686,9 @@ void ProjectFile::readTagWarnings(QXmlStreamReader &reader, const QString &tag)

void ProjectFile::readStringList(QStringList &stringlist, QXmlStreamReader &reader, const char elementname[])
{
QXmlStreamReader::TokenType type;
bool allRead = false;
do {
type = reader.readNext();
QXmlStreamReader::TokenType type = reader.readNext();
switch (type) {
case QXmlStreamReader::StartElement:
// Read library-elements
Expand Down
14 changes: 6 additions & 8 deletions gui/resultstree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,11 @@ bool ResultsTree::addErrorItem(const ErrorItem &item)
line.file = e.file;
line.line = e.line;
line.message = line.summary = e.info;
QStandardItem *child_item;
child_item = addBacktraceFiles(stditem,
line,
hide,
":images/go-down.png",
true);
QStandardItem *child_item = addBacktraceFiles(stditem,
line,
hide,
":images/go-down.png",
true);
if (!child_item)
continue;

Expand Down Expand Up @@ -1140,11 +1139,10 @@ QString ResultsTree::getFilePath(const QStandardItem *target, bool fullPath)
target = target->parent()->child(target->row(), 0);

QVariantMap data = target->data().toMap();
QString pathStr;

//Replace (file) with filename
QString file = data[FILENAME].toString();
pathStr = QDir::toNativeSeparators(file);
QString pathStr = QDir::toNativeSeparators(file);
if (!fullPath) {
QFileInfo fi(pathStr);
pathStr = fi.fileName();
Expand Down
3 changes: 1 addition & 2 deletions gui/statsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,7 @@ void StatsDialog::setProject(const ProjectFile* projectFile)
}
mUI->mLblHistoryFile->setText(tr("File: ") + (statsFile.isEmpty() ? tr("No cppcheck build dir") : statsFile));
if (!statsFile.isEmpty()) {
QChartView *chartView;
chartView = createChart(statsFile, "cppcheck");
QChartView *chartView = createChart(statsFile, "cppcheck");
mUI->mTabHistory->layout()->addWidget(chartView);
if (projectFile->getClangAnalyzer()) {
chartView = createChart(statsFile, CLANG_ANALYZER);
Expand Down
3 changes: 1 addition & 2 deletions lib/checknullpointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@ void CheckNullPointer::nullPointerError(const Token *tok, const std::string &var
} else if (value->defaultArg) {
reportError(errorPath, Severity::warning, "nullPointerDefaultArg", errmsgdefarg, CWE_NULL_POINTER_DEREFERENCE, inconclusive || value->isInconclusive() ? Certainty::inconclusive : Certainty::normal);
} else {
std::string errmsg;
errmsg = std::string(value->isKnown() ? "Null" : "Possible null") + " pointer dereference";
std::string errmsg = std::string(value->isKnown() ? "Null" : "Possible null") + " pointer dereference";
if (!varname.empty())
errmsg = "$symbol:" + varname + '\n' + errmsg + ": $symbol";

Expand Down
3 changes: 1 addition & 2 deletions lib/checkstl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2492,8 +2492,7 @@ void CheckStl::dereferenceInvalidIteratorError(const Token* tok, const ValueFlow
if (value->condition) {
reportError(errorPath, Severity::warning, "derefInvalidIteratorRedundantCheck", errmsgcond, CWE825, (inconclusive || value->isInconclusive()) ? Certainty::inconclusive : Certainty::normal);
} else {
std::string errmsg;
errmsg = std::string(value->isKnown() ? "Dereference" : "Possible dereference") + " of an invalid iterator";
std::string errmsg = std::string(value->isKnown() ? "Dereference" : "Possible dereference") + " of an invalid iterator";
if (!varname.empty())
errmsg = "$symbol:" + varname + '\n' + errmsg + ": $symbol";

Expand Down
4 changes: 1 addition & 3 deletions lib/checkunusedvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,7 @@ void Variables::clearAliases(nonneg int varid)

if (usage) {
// remove usage from all aliases
std::set<nonneg int>::const_iterator i;

for (i = usage->_aliases.cbegin(); i != usage->_aliases.cend(); ++i) {
for (std::set<nonneg int>::const_iterator i = usage->_aliases.cbegin(); i != usage->_aliases.cend(); ++i) {
VariableUsage *temp = find(*i);

if (temp)
Expand Down
4 changes: 1 addition & 3 deletions lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3214,10 +3214,8 @@ void SymbolDatabase::addClassFunction(Scope **scope, const Token **tok, const To
path.insert(0, ":: ");
}

std::list<Scope>::iterator it1;

// search for match
for (it1 = scopeList.begin(); it1 != scopeList.end(); ++it1) {
for (std::list<Scope>::iterator it1 = scopeList.begin(); it1 != scopeList.end(); ++it1) {
Scope *scope1 = &(*it1);

bool match = false;
Expand Down
9 changes: 3 additions & 6 deletions lib/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1889,8 +1889,7 @@ const ValueFlow::Value * Token::getInvalidValue(const Token *ftok, nonneg int ar
if (!mImpl->mValues || !settings)
return nullptr;
const ValueFlow::Value *ret = nullptr;
std::list<ValueFlow::Value>::const_iterator it;
for (it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
for (std::list<ValueFlow::Value>::const_iterator it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
if (it->isImpossible())
continue;
if ((it->isIntValue() && !settings->library.isIntArgValid(ftok, argnr, it->intvalue)) ||
Expand All @@ -1916,8 +1915,7 @@ const Token *Token::getValueTokenMinStrSize(const Settings *settings, MathLib::b
return nullptr;
const Token *ret = nullptr;
int minsize = INT_MAX;
std::list<ValueFlow::Value>::const_iterator it;
for (it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
for (std::list<ValueFlow::Value>::const_iterator it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
if (it->isTokValue() && it->tokvalue && it->tokvalue->tokType() == Token::eString) {
const int size = getStrSize(it->tokvalue, settings);
if (!ret || size < minsize) {
Expand All @@ -1937,8 +1935,7 @@ const Token *Token::getValueTokenMaxStrLength() const
return nullptr;
const Token *ret = nullptr;
int maxlength = 0;
std::list<ValueFlow::Value>::const_iterator it;
for (it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
for (std::list<ValueFlow::Value>::const_iterator it = mImpl->mValues->begin(); it != mImpl->mValues->end(); ++it) {
if (it->isTokValue() && it->tokvalue && it->tokvalue->tokType() == Token::eString) {
const int length = getStrLength(it->tokvalue);
if (!ret || length > maxlength) {
Expand Down