From 785007b6bc1fed0a74dabcd377c6514fcbc5e87d Mon Sep 17 00:00:00 2001 From: Katja Marttila Date: Thu, 3 Nov 2022 13:11:14 +0200 Subject: Fix clang and compiler warnings Added const and reference to function names, removed unused variables etc. Change-Id: I5e3851c13ff3baf1884356198020fc86e69d69b4 Reviewed-by: Arttu Tarkiainen --- src/libs/installer/commandlineparser.cpp | 2 +- src/libs/installer/installercalculator.cpp | 6 +++--- src/libs/installer/installercalculator.h | 2 +- src/libs/installer/loggingutils.cpp | 3 ++- src/libs/installer/loggingutils.h | 2 +- src/libs/installer/metadata.cpp | 2 +- src/libs/installer/metadata.h | 2 +- src/libs/installer/packagemanagercore.cpp | 6 +++--- src/libs/installer/packagemanagercore_p.cpp | 3 ++- src/libs/installer/utils.cpp | 2 +- src/libs/installer/utils.h | 2 +- 11 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/libs/installer/commandlineparser.cpp b/src/libs/installer/commandlineparser.cpp index 937c966ba..a91ab0128 100644 --- a/src/libs/installer/commandlineparser.cpp +++ b/src/libs/installer/commandlineparser.cpp @@ -201,7 +201,7 @@ CommandLineParser::CommandLineParser() QLatin1String("[CLI] Automatically sets the QFileDialog values getExistingDirectory() or getOpenFileName() " "requested by install script. " "Several identifier=value pairs can be given separated with comma, " - "for example --file-query filedialog.id=C:\Temp,filedialog.id2=C:\Temp2"), + "for example --file-query filedialog.id=C:/Temp,filedialog.id2=C:/Temp2"), QLatin1String("identifier=value")), CommandLineOnly); addOptionWithContext(QCommandLineOption(QStringList() << CommandLineOptions::scConfirmCommandShort << CommandLineOptions::scConfirmCommandLong, QLatin1String("[CLI] Confirms starting of " diff --git a/src/libs/installer/installercalculator.cpp b/src/libs/installer/installercalculator.cpp index 83efeb468..f285158f8 100644 --- a/src/libs/installer/installercalculator.cpp +++ b/src/libs/installer/installercalculator.cpp @@ -327,7 +327,7 @@ QSet InstallerCalculator::autodependencyComponents(const bool rever return foundAutoDependOnList; } -void InstallerCalculator::calculateComponentDependencyReferences(const QString dependencyComponentName, const Component *component) +void InstallerCalculator::calculateComponentDependencyReferences(const QString &dependencyComponentName, const Component *component) { Component *dependencyComponent = m_core->componentByName(dependencyComponentName); if (!dependencyComponent || component->autoDependencies().contains(dependencyComponentName)) @@ -338,8 +338,8 @@ void InstallerCalculator::calculateComponentDependencyReferences(const QString d const QStringList dependenciesList = dependencyComponent->currentDependencies(); for (const QString &depComponentName : dependenciesList) { - Component *dependencyComponent = m_core->componentByName(depComponentName); - calculateComponentDependencyReferences(depComponentName, dependencyComponent); + Component *depComponent = m_core->componentByName(depComponentName); + calculateComponentDependencyReferences(depComponentName, depComponent); } } diff --git a/src/libs/installer/installercalculator.h b/src/libs/installer/installercalculator.h index c2fa8761c..bdb8ac404 100644 --- a/src/libs/installer/installercalculator.h +++ b/src/libs/installer/installercalculator.h @@ -71,7 +71,7 @@ private: bool appendComponentToInstall(Component *component, const QString &version, const bool revertFromInstall); QString recursionError(const Component *component) const; QSet autodependencyComponents(const bool revertFromInstall); - void calculateComponentDependencyReferences(const QString dependencyComponentName, const Component *component); + void calculateComponentDependencyReferences(const QString &dependencyComponentName, const Component *component); private: PackageManagerCore *m_core; diff --git a/src/libs/installer/loggingutils.cpp b/src/libs/installer/loggingutils.cpp index 8c542a1d1..189a1d050 100644 --- a/src/libs/installer/loggingutils.cpp +++ b/src/libs/installer/loggingutils.cpp @@ -110,6 +110,7 @@ public: */ LoggingHandler::LoggingHandler() : m_verbLevel(VerbosityLevel::Silent) + , m_outputRedirected(false) { #if defined(Q_OS_UNIX) m_outputRedirected = !isatty(fileno(stdout)); @@ -251,7 +252,7 @@ bool LoggingHandler::outputRedirected() const /*! Prints update information from \a components. */ -void LoggingHandler::printUpdateInformation(const QList components) const +void LoggingHandler::printUpdateInformation(const QList &components) const { QString output; QXmlStreamWriter stream(&output); diff --git a/src/libs/installer/loggingutils.h b/src/libs/installer/loggingutils.h index f41a18663..8bd4217ee 100644 --- a/src/libs/installer/loggingutils.h +++ b/src/libs/installer/loggingutils.h @@ -64,7 +64,7 @@ public: VerbosityLevel verboseLevel() const; bool outputRedirected() const; - void printUpdateInformation(const QList components) const; + void printUpdateInformation(const QList &components) const; void printLocalPackageInformation(const QList &packages) const; void printPackageInformation(const PackagesList &matchedPackages, const LocalPackagesMap &installedPackages) const; diff --git a/src/libs/installer/metadata.cpp b/src/libs/installer/metadata.cpp index b74ffc3f1..0469ed8b1 100644 --- a/src/libs/installer/metadata.cpp +++ b/src/libs/installer/metadata.cpp @@ -189,7 +189,7 @@ Repository Metadata::repository() const is already set, the new one will override the previous one. The metadata becomes associated with the set repository even if it was fetched from another one. */ -void Metadata::setRepository(Repository repository) +void Metadata::setRepository(const Repository &repository) { m_repository = repository; } diff --git a/src/libs/installer/metadata.h b/src/libs/installer/metadata.h index c2afe7df6..af7acf6b9 100644 --- a/src/libs/installer/metadata.h +++ b/src/libs/installer/metadata.h @@ -53,7 +53,7 @@ public: bool obsoletes(CacheableItem *other) override; Repository repository() const; - void setRepository(Repository repository); + void setRepository(const Repository &repository); bool isAvailableFromDefaultRepository() const; void setAvailableFromDefaultRepository(bool defaultRepository); diff --git a/src/libs/installer/packagemanagercore.cpp b/src/libs/installer/packagemanagercore.cpp index 3e19d6b81..45f8864a7 100644 --- a/src/libs/installer/packagemanagercore.cpp +++ b/src/libs/installer/packagemanagercore.cpp @@ -3996,9 +3996,9 @@ bool PackageManagerCore::updateComponentData(struct Data &data, Component *compo if (settings().allowUnstableComponents()) { // Check if there are sha checksum mismatch. Component will still show in install tree // but is unselectable. - foreach (const QString packageName, d->m_metadataJob.shaMismatchPackages()) { - if (packageName == component->name()) { - const QString errorString = QLatin1String("SHA mismatch detected for component ") + packageName; + foreach (const QString pkgName, d->m_metadataJob.shaMismatchPackages()) { + if (pkgName == component->name()) { + const QString errorString = QLatin1String("SHA mismatch detected for component ") + pkgName; d->m_pendingUnstableComponents.insert(component->name(), QPair(Component::ShaMismatch, errorString)); } diff --git a/src/libs/installer/packagemanagercore_p.cpp b/src/libs/installer/packagemanagercore_p.cpp index cbf7813a7..3a30244f2 100644 --- a/src/libs/installer/packagemanagercore_p.cpp +++ b/src/libs/installer/packagemanagercore_p.cpp @@ -1352,6 +1352,8 @@ void PackageManagerCorePrivate::writeMaintenanceToolAppBundle(OperationList &per << (targetAppDirPath + QLatin1String("/../plugins"))); performOperationThreaded(op); } +#else + Q_UNUSED(performedOperations); #endif } @@ -3105,7 +3107,6 @@ void PackageManagerCorePrivate::calculateUninstallComponents() { clearUninstallerCalculator(); const QList componentsToInstallList = installerCalculator()->orderedComponentsToInstall(); - QSet componentsToInstall(componentsToInstallList.begin(), componentsToInstallList.end()); QList selectedComponentsToUninstall; foreach (Component* component, m_core->components(PackageManagerCore::ComponentType::Replacements)) { diff --git a/src/libs/installer/utils.cpp b/src/libs/installer/utils.cpp index e9fb45f2a..f677ba5f0 100644 --- a/src/libs/installer/utils.cpp +++ b/src/libs/installer/utils.cpp @@ -139,7 +139,7 @@ QStringList QInstaller::localeCandidates(const QString &locale_) at least one mutually exclusive pair of options set. Otherwise returns an empty \c QStringList. The options considered mutual are provided with \a options. */ -QStringList QInstaller::checkMutualOptions(CommandLineParser &parser, const QStringList &options) +QStringList QInstaller::checkMutualOptions(const CommandLineParser &parser, const QStringList &options) { QStringList mutual; foreach (const QString &option, options) { diff --git a/src/libs/installer/utils.h b/src/libs/installer/utils.h index 2bf997835..068490cc2 100644 --- a/src/libs/installer/utils.h +++ b/src/libs/installer/utils.h @@ -69,7 +69,7 @@ namespace QInstaller { QStringList INSTALLER_EXPORT localeCandidates(const QString &locale); - QStringList INSTALLER_EXPORT checkMutualOptions(CommandLineParser &parser, const QStringList &options); + QStringList INSTALLER_EXPORT checkMutualOptions(const CommandLineParser &parser, const QStringList &options); INSTALLER_EXPORT std::ostream& operator<<(std::ostream &os, const QString &string); } -- cgit v1.2.3