summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatja Marttila <katja.marttila@qt.io>2021-03-05 08:58:04 +0200
committerKatja Marttila <katja.marttila@qt.io>2021-03-09 13:23:44 +0200
commit6fdadf83710c37f70c1d2d621eacb9cbb327b23b (patch)
tree3b0aede467044c529fae34e6c3f5ac654ea9f974
parentabd97626ac2d50e54650a7256b48b7bbc1b2769e (diff)
Cppcheck: Fix local variable shadowing outer variable
Change-Id: Idff9a40c5089b4de7b8afd1c280603601317beda Reviewed-by: Arttu Tarkiainen <arttu.tarkiainen@qt.io>
-rw-r--r--src/libs/ifwtools/binarycreator.cpp10
-rw-r--r--src/libs/ifwtools/repositorygen.cpp8
-rw-r--r--src/libs/installer/componentmodel.cpp6
-rw-r--r--src/libs/installer/installiconsoperation.cpp10
-rw-r--r--src/libs/installer/utils.cpp8
-rw-r--r--src/libs/kdtools/updatesinfo.cpp8
-rw-r--r--tools/devtool/binarydump.cpp6
-rw-r--r--tools/devtool/main.cpp26
8 files changed, 41 insertions, 41 deletions
diff --git a/src/libs/ifwtools/binarycreator.cpp b/src/libs/ifwtools/binarycreator.cpp
index deea01ed7..a813c7f50 100644
--- a/src/libs/ifwtools/binarycreator.cpp
+++ b/src/libs/ifwtools/binarycreator.cpp
@@ -410,9 +410,9 @@ static int assemble(Input input, const QInstaller::Settings &settings, const QSt
collection.setName(info.name.toUtf8());
qDebug() << "Creating resource archive for" << info.name;
- foreach (const QString &file, info.copiedFiles) {
- const QSharedPointer<Resource> resource(new Resource(file));
- qDebug().nospace() << "Appending " << file << " (" << humanReadableSize(resource->size()) << ")";
+ foreach (const QString &copiedFile, info.copiedFiles) {
+ const QSharedPointer<Resource> resource(new Resource(copiedFile));
+ qDebug().nospace() << "Appending " << copiedFile << " (" << humanReadableSize(resource->size()) << ")";
collection.appendResource(resource);
}
input.manager.insertCollection(collection);
@@ -610,8 +610,8 @@ void QInstallerTools::copyConfigData(const QString &configFile, const QString &t
if (tagName == QLatin1String("ProductImages")) {
const QDomNodeList childNodes = domElement.childNodes();
- for (int i = 0; i < childNodes.count(); ++i) {
- const QDomElement childElement = childNodes.at(i).toElement();
+ for (int index = 0; index < childNodes.count(); ++index) {
+ const QDomElement childElement = childNodes.at(index).toElement();
const QString childName = childElement.tagName();
if (childName != QLatin1String("Image"))
continue;
diff --git a/src/libs/ifwtools/repositorygen.cpp b/src/libs/ifwtools/repositorygen.cpp
index 842d4f9cb..863b5655b 100644
--- a/src/libs/ifwtools/repositorygen.cpp
+++ b/src/libs/ifwtools/repositorygen.cpp
@@ -777,14 +777,14 @@ QStringList QInstallerTools::unifyMetadata(const QString &repoDir, const QString
QFile archiveFile(existingRepoDir);
QInstaller::openForRead(&archiveFile);
Lib7z::extractArchive(&archiveFile, existingRepoTemp);
- QDir dir(existingRepoTemp);
- QStringList existingRepoEntries = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
+ QDir dir2(existingRepoTemp);
+ QStringList existingRepoEntries = dir2.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
foreach (const QString existingRepoEntry, existingRepoEntries) {
if (entryList.contains(existingRepoEntry)) {
continue;
} else {
- dir.cd(existingRepoEntry);
- const QString absPath = dir.absolutePath();
+ dir2.cd(existingRepoEntry);
+ const QString absPath = dir2.absolutePath();
absPaths.append(absPath);
}
}
diff --git a/src/libs/installer/componentmodel.cpp b/src/libs/installer/componentmodel.cpp
index aab487b45..642828ad7 100644
--- a/src/libs/installer/componentmodel.cpp
+++ b/src/libs/installer/componentmodel.cpp
@@ -260,9 +260,9 @@ bool ComponentModel::setData(const QModelIndex &index, const QVariant &value, in
newValue = (oldValue == Qt::Checked) ? Qt::Unchecked : Qt::Checked;
}
QSet<QModelIndex> changed = updateCheckedState(nodes << component, newValue);
- foreach (const QModelIndex &index, changed) {
- emit dataChanged(index, index);
- emit checkStateChanged(index);
+ foreach (const QModelIndex &changedIndex, changed) {
+ emit dataChanged(changedIndex, changedIndex);
+ emit checkStateChanged(changedIndex);
}
updateAndEmitModelState(); // update the internal state
} else {
diff --git a/src/libs/installer/installiconsoperation.cpp b/src/libs/installer/installiconsoperation.cpp
index 9443b7f71..de1ddcc4f 100644
--- a/src/libs/installer/installiconsoperation.cpp
+++ b/src/libs/installer/installiconsoperation.cpp
@@ -134,8 +134,8 @@ bool InstallIconsOperation::performOperation()
if (status == PackageManagerCore::Canceled || status == PackageManagerCore::Failure)
return true;
- const QString &source = it.next();
- QString target = targetDir.absoluteFilePath(sourceDir.relativeFilePath(source));
+ const QString &source2 = it.next();
+ QString target = targetDir.absoluteFilePath(sourceDir.relativeFilePath(source2));
emit outputTextChanged(target);
@@ -185,7 +185,7 @@ bool InstallIconsOperation::performOperation()
}
// copy the file to its new location
- QFile cf(source);
+ QFile cf(source2);
if (!cf.copy(target)) {
setError(UserDefinedError);
setErrorString(tr("Failed to copy file \"%1\": %2").arg(
@@ -193,8 +193,8 @@ bool InstallIconsOperation::performOperation()
undoOperation();
return false;
}
- deleteFileNowOrLater(source);
- files.push_back(source);
+ deleteFileNowOrLater(source2);
+ files.push_back(source2);
files.push_back(target);
setValue(QLatin1String("files"), files);
} else if (fi.isDir() && !QDir(target).exists()) {
diff --git a/src/libs/installer/utils.cpp b/src/libs/installer/utils.cpp
index 59be2171b..7506a13fe 100644
--- a/src/libs/installer/utils.cpp
+++ b/src/libs/installer/utils.cpp
@@ -351,12 +351,12 @@ static QString qt_create_commandline(const QString &program, const QStringList &
// as escaping the quote -- rather put the \ behind the quote: e.g.
// rather use "foo"\ than "foo\"
QString endQuote(QLatin1Char('\"'));
- int i = tmp.length();
- while (i > 0 && tmp.at(i - 1) == QLatin1Char('\\')) {
- --i;
+ int j = tmp.length();
+ while (j > 0 && tmp.at(j - 1) == QLatin1Char('\\')) {
+ --j;
endQuote += QLatin1Char('\\');
}
- args += QLatin1String(" \"") + tmp.left(i) + endQuote;
+ args += QLatin1String(" \"") + tmp.left(j) + endQuote;
} else {
args += QLatin1Char(' ') + tmp;
}
diff --git a/src/libs/kdtools/updatesinfo.cpp b/src/libs/kdtools/updatesinfo.cpp
index 3119b6240..eaa9b039e 100644
--- a/src/libs/kdtools/updatesinfo.cpp
+++ b/src/libs/kdtools/updatesinfo.cpp
@@ -125,8 +125,8 @@ bool UpdatesInfoData::parsePackageUpdateElement(const QDomElement &updateE)
} else if (childE.tagName() == QLatin1String("Licenses")) {
QHash<QString, QVariant> licenseHash;
const QDomNodeList licenseNodes = childE.childNodes();
- for (int i = 0; i < licenseNodes.count(); ++i) {
- const QDomNode licenseNode = licenseNodes.at(i);
+ for (int index = 0; index < licenseNodes.count(); ++index) {
+ const QDomNode licenseNode = licenseNodes.at(index);
if (licenseNode.nodeName() == QLatin1String("License")) {
QDomElement element = licenseNode.toElement();
QVariantMap attributes;
@@ -210,8 +210,8 @@ QVariant UpdatesInfoData::parseOperations(const QDomNodeList &operationNodes)
if (operationNode.nodeName() == QLatin1String("Operation")) {
const QDomNodeList argumentNodes = operationNode.childNodes();
QStringList attributes;
- for (int i = 0; i < argumentNodes.count(); ++i) {
- const QDomNode argumentNode = argumentNodes.at(i);
+ for (int index = 0; index < argumentNodes.count(); ++index) {
+ const QDomNode argumentNode = argumentNodes.at(index);
if (argumentNode.nodeName() == QLatin1String("Argument")) {
QDomElement argumentElement = argumentNode.toElement();
attributes.append(argumentElement.text());
diff --git a/tools/devtool/binarydump.cpp b/tools/devtool/binarydump.cpp
index bd8e9053c..bb0700149 100644
--- a/tools/devtool/binarydump.cpp
+++ b/tools/devtool/binarydump.cpp
@@ -117,10 +117,10 @@ int BinaryDump::dump(const QInstaller::ResourceCollectionManager &manager, const
if ((!isOpen) && (!resource->open()))
continue; // TODO: should we throw here?
- QFile target(targetDir.filePath(name) + QDir::separator()
+ QFile targetFile(targetDir.filePath(name) + QDir::separator()
+ QString::fromUtf8(resource->name()));
- QInstaller::openForWrite(&target);
- resource->copyData(&target); // copy the 7z files into the target directory
+ QInstaller::openForWrite(&targetFile);
+ resource->copyData(&targetFile); // copy the 7z files into the target directory
if (!isOpen) // If we reach that point, either the resource was opened already...
resource->close(); // or we did open it and have to close it again.
diff --git a/tools/devtool/main.cpp b/tools/devtool/main.cpp
index 52db7d8b3..8da6dfb75 100644
--- a/tools/devtool/main.cpp
+++ b/tools/devtool/main.cpp
@@ -182,31 +182,31 @@ int main(int argc, char *argv[])
quint64 cookie = QInstaller::BinaryContent::MagicCookie;
try {
{
- QFile tmp(path);
- QInstaller::openForRead(&tmp);
+ QFile tmpFile(path);
+ QInstaller::openForRead(&tmpFile);
- if (!tmp.seek(QInstaller::BinaryContent::findMagicCookie(&tmp, cookie) - sizeof(qint64)))
+ if (!tmpFile.seek(QInstaller::BinaryContent::findMagicCookie(&tmpFile, cookie) - sizeof(qint64)))
throw QInstaller::Error(QLatin1String("Cannot seek to read magic marker."));
QInstaller::BinaryLayout layout;
- layout.magicMarker = QInstaller::retrieveInt64(&tmp);
+ layout.magicMarker = QInstaller::retrieveInt64(&tmpFile);
if (layout.magicMarker == QInstaller::BinaryContent::MagicUninstallerMarker) {
- QFileInfo fi(path);
+ QFileInfo fileInfo(path);
- QInstaller::isInBundle(fi.absoluteFilePath(), &bundlePath);
- fi.setFile(bundlePath);
+ QInstaller::isInBundle(fileInfo.absoluteFilePath(), &bundlePath);
+ fileInfo.setFile(bundlePath);
- path = fi.absolutePath() + QLatin1Char('/') + fi.baseName() + QLatin1String(".dat");
+ path = fileInfo.absolutePath() + QLatin1Char('/') + fileInfo.baseName() + QLatin1String(".dat");
- tmp.close();
- tmp.setFileName(path);
- QInstaller::openForRead(&tmp);
+ tmpFile.close();
+ tmpFile.setFileName(path);
+ QInstaller::openForRead(&tmpFile);
cookie = QInstaller::BinaryContent::MagicCookieDat;
}
- layout = QInstaller::BinaryContent::binaryLayout(&tmp, cookie);
- tmp.close();
+ layout = QInstaller::BinaryContent::binaryLayout(&tmpFile, cookie);
+ tmpFile.close();
if (command == QLatin1String("update")) {
BinaryReplace br(layout); // To update the binary we do not need any mapping.