summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@pelagicore.com>2017-02-27 12:05:19 +0100
committerRobert Griebl <robert.griebl@pelagicore.com>2017-02-27 14:13:20 +0000
commitae5ea61408819e5a3b01b6b99703f6e9ee7ea3da (patch)
treea9e3e41558d19247a454880c6a6f42d6332f04bb
parent6a84942013e141cca137866bf33fe496ebe06cba (diff)
Fix for clazy and clang static code analysis findings
Change-Id: I97b29073903f0d7bab6c9e1cc4cc5eacf5357393 Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
-rw-r--r--examples/softwarecontainer-plugin/softwarecontainer-plugin.pro2
-rw-r--r--examples/softwarecontainer-plugin/softwarecontainer.cpp18
-rw-r--r--src/common-lib/utilities.cpp2
-rw-r--r--src/installer-lib/applicationinstaller.cpp2
-rw-r--r--src/launcher-lib/applicationmanagerwindow.cpp6
-rw-r--r--src/launcher-lib/ipcwrapperobject.h2
-rw-r--r--src/launcher-lib/qmlapplicationinterface.h2
-rw-r--r--src/launcher-lib/qmlnotification.h2
-rw-r--r--src/launchers/qml/main.cpp4
-rw-r--r--src/manager-lib/applicationipcinterface_p.h4
-rw-r--r--src/manager-lib/processcontainer.h2
-rw-r--r--src/manager-lib/qmlinprocessapplicationinterface.h2
-rw-r--r--src/manager-lib/qmlinprocessruntime.cpp4
-rw-r--r--src/manager-lib/quicklauncher.cpp2
-rw-r--r--src/manager-lib/systemmonitor.cpp2
-rw-r--r--src/manager/main.cpp2
-rw-r--r--src/tools/controller/main.cpp7
-rw-r--r--src/tools/dumpqmltypes/main.cpp2
-rw-r--r--src/window-lib/waylandcompositor.h2
-rw-r--r--tests/packageextractor/tst_packageextractor.cpp2
20 files changed, 36 insertions, 35 deletions
diff --git a/examples/softwarecontainer-plugin/softwarecontainer-plugin.pro b/examples/softwarecontainer-plugin/softwarecontainer-plugin.pro
index fbad18e5..01e17555 100644
--- a/examples/softwarecontainer-plugin/softwarecontainer-plugin.pro
+++ b/examples/softwarecontainer-plugin/softwarecontainer-plugin.pro
@@ -1,7 +1,7 @@
requires(linux:!android)
TEMPLATE = lib
-CONFIG += plugin
+CONFIG += plugin c++11
TARGET = softwarecontainer-plugin
QT = core dbus appman_common-private appman_plugininterfaces-private
diff --git a/examples/softwarecontainer-plugin/softwarecontainer.cpp b/examples/softwarecontainer-plugin/softwarecontainer.cpp
index 35098697..4a72a019 100644
--- a/examples/softwarecontainer-plugin/softwarecontainer.cpp
+++ b/examples/softwarecontainer-plugin/softwarecontainer.cpp
@@ -167,8 +167,8 @@ ContainerInterface *SoftwareContainerManager::create(const QVector<int> &stdioRe
return nullptr;
}
- int containerId = reply.arguments().at(0).value<int>();
- bool success = reply.arguments().at(1).value<bool>();
+ int containerId = reply.arguments().at(0).toInt();
+ bool success = reply.arguments().at(1).toBool();
if (!success) {
qWarning() << "SoftwareContainer failed to create a new container. (config was:" << config << ")";
@@ -309,7 +309,7 @@ bool SoftwareContainer::start(const QStringList &arguments, const QProcessEnviro
return false;
}
- if (!reply.arguments().at(0).value<bool>()) {
+ if (!reply.arguments().at(0).toBool()) {
qWarning() << "SoftwareContainer failed to set capabilities to" << capabilities;
return false;
}
@@ -322,7 +322,7 @@ bool SoftwareContainer::start(const QStringList &arguments, const QProcessEnviro
QFileInfo fontCacheInfo(qSL("/var/cache/fontconfig"));
- QList<std::tuple<QString, QString, bool>> bindMounts; // bool == isReadOnly
+ QVector<std::tuple<QString, QString, bool>> bindMounts; // bool == isReadOnly
// the private P2P D-Bus
bindMounts.append(std::make_tuple(dbusP2PInfo.absoluteFilePath(), dbusP2PInfo.absoluteFilePath(), false));
@@ -342,7 +342,7 @@ bool SoftwareContainer::start(const QStringList &arguments, const QProcessEnviro
for (auto it = bindMounts.cbegin(); it != bindMounts.cend(); ++it)
bindMountResults << iface->asyncCall("BindMount", m_id, std::get<0>(*it), std::get<1>(*it), std::get<2>(*it));
- for (auto pending : qAsConst(bindMountResults))
+ for (const auto &pending : qAsConst(bindMountResults))
QDBusPendingCallWatcher(pending).waitForFinished();
for (int i = 0; i < bindMounts.size(); ++i) {
@@ -386,7 +386,7 @@ bool SoftwareContainer::start(const QStringList &arguments, const QProcessEnviro
sn->setEnabled(false);
return;
} else if (bytesRead > 0) {
- QT_WRITE(outputFd, buffer.constData(), bytesRead);
+ (void) QT_WRITE(outputFd, buffer.constData(), bytesRead);
bytesAvailable -= bytesRead;
}
}
@@ -419,7 +419,7 @@ bool SoftwareContainer::start(const QStringList &arguments, const QProcessEnviro
// SC expects a plain string instead of individual args
QString cmdLine;
- for (const auto &part : command) {
+ for (const auto &part : qAsConst(command)) {
if (!cmdLine.isEmpty())
cmdLine.append(QLatin1Char(' '));
cmdLine.append(QLatin1Char('\"'));
@@ -470,7 +470,7 @@ bool SoftwareContainer::start(const QStringList &arguments, const QProcessEnviro
return false;
}
- if (!reply.arguments().at(1).value<bool>()) {
+ if (!reply.arguments().at(1).toBool()) {
qWarning() << "SoftwareContainer failed to execute application" << m_id << "in directory" << m_containerPath << "in the container.";
return false;
}
@@ -510,7 +510,7 @@ void SoftwareContainer::kill()
qWarning() << "SoftwareContainer failed to destroy container" << reply.errorMessage();
}
- if (!reply.arguments().at(0).value<bool>()) {
+ if (!reply.arguments().at(0).toBool()) {
qWarning() << "SoftwareContainer failed to destroy container.";
}
}
diff --git a/src/common-lib/utilities.cpp b/src/common-lib/utilities.cpp
index 601be271..ff8dde1c 100644
--- a/src/common-lib/utilities.cpp
+++ b/src/common-lib/utilities.cpp
@@ -129,7 +129,7 @@ bool ensureCorrectLocale()
return true;
// now the time-consuming part: trying to switch to a well-known UTF-8 locale
- const char *locales[] = { "C.UTF-8", "en_US.UTF-8" };
+ const char *locales[] = { "C.UTF-8", "en_US.UTF-8", nullptr };
for (const char **loc = locales; *loc; ++loc) {
if (const char *old = setlocale(LC_CTYPE, *loc)) {
if (checkUtf()) {
diff --git a/src/installer-lib/applicationinstaller.cpp b/src/installer-lib/applicationinstaller.cpp
index 6426f27e..20d3ad02 100644
--- a/src/installer-lib/applicationinstaller.cpp
+++ b/src/installer-lib/applicationinstaller.cpp
@@ -811,7 +811,7 @@ int ApplicationInstaller::compareVersions(const QString &version1, const QString
// this is a simple helper class - we need this to be able to run the filesystem (un)mounting
// in a separate thread to avoid blocking the UI and D-Bus
-class ActivationHelper : public QObject
+class ActivationHelper : public QObject // clazy:exclude=missing-qobject-macro
{
public:
enum Mode { Activate, Deactivate, IsActivated };
diff --git a/src/launcher-lib/applicationmanagerwindow.cpp b/src/launcher-lib/applicationmanagerwindow.cpp
index 6ea01df6..98380517 100644
--- a/src/launcher-lib/applicationmanagerwindow.cpp
+++ b/src/launcher-lib/applicationmanagerwindow.cpp
@@ -160,7 +160,7 @@ void ApplicationManagerWindow::onWindowPropertyChangedInternal(QPlatformWindow *
*/
bool ApplicationManagerWindow::setWindowProperty(const QString &name, const QVariant &value)
{
- if (!d->platformNativeInterface && !d->platformWindow)
+ if (!d->platformNativeInterface || !d->platformWindow)
return false;
d->platformNativeInterface->setWindowProperty(d->platformWindow, name, value);
return true;
@@ -175,7 +175,7 @@ bool ApplicationManagerWindow::setWindowProperty(const QString &name, const QVar
*/
QVariant ApplicationManagerWindow::windowProperty(const QString &name) const
{
- if (!d->platformNativeInterface && !d->platformWindow)
+ if (!d->platformNativeInterface || !d->platformWindow)
return QVariant();
return d->platformNativeInterface->windowProperty(d->platformWindow, name);
}
@@ -189,7 +189,7 @@ QVariant ApplicationManagerWindow::windowProperty(const QString &name) const
*/
QVariantMap ApplicationManagerWindow::windowProperties() const
{
- if (!d->platformNativeInterface && !d->platformWindow)
+ if (!d->platformNativeInterface || !d->platformWindow)
return QVariantMap();
return d->platformNativeInterface->windowProperties(d->platformWindow);
}
diff --git a/src/launcher-lib/ipcwrapperobject.h b/src/launcher-lib/ipcwrapperobject.h
index 6b94f875..245e7c59 100644
--- a/src/launcher-lib/ipcwrapperobject.h
+++ b/src/launcher-lib/ipcwrapperobject.h
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE_AM
class IpcWrapperSignalRelay;
-class IpcWrapperObject : public QObject
+class IpcWrapperObject : public QObject // clazy:exclude=missing-qobject-macro
{
public:
IpcWrapperObject(const QString &service, const QString &path, const QString &interface,
diff --git a/src/launcher-lib/qmlapplicationinterface.h b/src/launcher-lib/qmlapplicationinterface.h
index eaf4fe01..c130577a 100644
--- a/src/launcher-lib/qmlapplicationinterface.h
+++ b/src/launcher-lib/qmlapplicationinterface.h
@@ -75,7 +75,7 @@ public:
QVariantMap applicationProperties() const override;
Q_INVOKABLE QT_PREPEND_NAMESPACE_AM(Notification *) createNotification();
Q_INVOKABLE void acknowledgeQuit() const;
- Q_INVOKABLE void finishedInitialization();
+ Q_INVOKABLE void finishedInitialization() override;
private slots:
void notificationClosed(uint notificationId, uint reason);
diff --git a/src/launcher-lib/qmlnotification.h b/src/launcher-lib/qmlnotification.h
index 3e93c26a..7bb52fce 100644
--- a/src/launcher-lib/qmlnotification.h
+++ b/src/launcher-lib/qmlnotification.h
@@ -48,7 +48,7 @@ QT_BEGIN_NAMESPACE_AM
class QmlApplicationInterface;
-class QmlNotification : public Notification
+class QmlNotification : public Notification // clazy:exclude=missing-qobject-macro
{
public:
QmlNotification(QObject *parent = 0, Notification::ConstructionMode mode = Notification::Declarative);
diff --git a/src/launchers/qml/main.cpp b/src/launchers/qml/main.cpp
index f7698419..c6dac50b 100644
--- a/src/launchers/qml/main.cpp
+++ b/src/launchers/qml/main.cpp
@@ -157,7 +157,7 @@ bool setProcessTitle(const QByteArray &title)
}
// maybe make this configurable for specific workloads?
-class HeadlessIncubationController : public QObject, public QQmlIncubationController
+class HeadlessIncubationController : public QObject, public QQmlIncubationController // clazy:exclude=missing-qobject-macro
{
public:
HeadlessIncubationController(QObject *parent)
@@ -588,7 +588,7 @@ void Controller::startApplication(const QString &baseDir, const QString &qmlFile
startupTimer.createReport(application.value("id").toString());
if (!document.isEmpty() && m_applicationInterface)
- m_applicationInterface->openDocument(document, mimeType);
+ emit m_applicationInterface->openDocument(document, mimeType);
}
#include "main.moc"
diff --git a/src/manager-lib/applicationipcinterface_p.h b/src/manager-lib/applicationipcinterface_p.h
index 95a9887d..0d1e63b7 100644
--- a/src/manager-lib/applicationipcinterface_p.h
+++ b/src/manager-lib/applicationipcinterface_p.h
@@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE_AM
class Application;
class IpcProxySignalRelay;
-class IpcProxyObject
+class IpcProxyObject // clazy:exclude=missing-qobject-macro
#if defined(QT_DBUS_LIB)
: protected QDBusVirtualObject
#else
@@ -116,7 +116,7 @@ private:
friend class ApplicationIPCInterfaceAttached;
};
-class IpcProxySignalRelay : public QObject
+class IpcProxySignalRelay : public QObject // clazy:exclude=missing-qobject-macro
{
public:
IpcProxySignalRelay(IpcProxyObject *proxyObject);
diff --git a/src/manager-lib/processcontainer.h b/src/manager-lib/processcontainer.h
index 6effbbf3..f11c8f61 100644
--- a/src/manager-lib/processcontainer.h
+++ b/src/manager-lib/processcontainer.h
@@ -85,7 +85,7 @@ public slots:
void setStopBeforeExec(bool stopBeforeExec);
private:
- class MyQProcess : public QProcess
+ class MyQProcess : public QProcess // clazy:exclude=missing-qobject-macro
{
protected:
void setupChildProcess() override;
diff --git a/src/manager-lib/qmlinprocessapplicationinterface.h b/src/manager-lib/qmlinprocessapplicationinterface.h
index 883916c0..2fe0d4b3 100644
--- a/src/manager-lib/qmlinprocessapplicationinterface.h
+++ b/src/manager-lib/qmlinprocessapplicationinterface.h
@@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE_AM
class QmlInProcessRuntime;
-class QmlInProcessNotification : public Notification
+class QmlInProcessNotification : public Notification // clazy:exclude=missing-qobject-macro
{
public:
QmlInProcessNotification(QObject *parent = 0, ConstructionMode mode = Declarative);
diff --git a/src/manager-lib/qmlinprocessruntime.cpp b/src/manager-lib/qmlinprocessruntime.cpp
index 3ed2e061..ca650e27 100644
--- a/src/manager-lib/qmlinprocessruntime.cpp
+++ b/src/manager-lib/qmlinprocessruntime.cpp
@@ -186,7 +186,7 @@ bool QmlInProcessRuntime::start()
QTimer::singleShot(0, this, [component, this]() {
component->completeCreate();
if (!m_document.isEmpty())
- emit openDocument(m_document, QString());
+ openDocument(m_document, QString());
setState(Active);
delete component;
});
@@ -292,7 +292,7 @@ void QmlInProcessRuntime::openDocument(const QString &document, const QString &m
{
m_document = document;
if (m_applicationIf)
- m_applicationIf->openDocument(document, mimeType);
+ emit m_applicationIf->openDocument(document, mimeType);
}
qint64 QmlInProcessRuntime::applicationProcessId() const
diff --git a/src/manager-lib/quicklauncher.cpp b/src/manager-lib/quicklauncher.cpp
index da649677..5fbfc5ae 100644
--- a/src/manager-lib/quicklauncher.cpp
+++ b/src/manager-lib/quicklauncher.cpp
@@ -216,7 +216,7 @@ QPair<AbstractContainer *, AbstractRuntime *> QuickLauncher::take(const QString
void QuickLauncher::killAll()
{
for (auto entry = m_quickLaunchPool.begin(); entry != m_quickLaunchPool.end(); ++entry) {
- for (const auto &car : entry->m_containersAndRuntimes) {
+ for (const auto &car : qAsConst(entry->m_containersAndRuntimes)) {
if (car.second) {
car.second->stop(true);
delete car.second;
diff --git a/src/manager-lib/systemmonitor.cpp b/src/manager-lib/systemmonitor.cpp
index 5109a734..49fd6997 100644
--- a/src/manager-lib/systemmonitor.cpp
+++ b/src/manager-lib/systemmonitor.cpp
@@ -349,7 +349,7 @@ const qreal FrameTimer::MicrosInSec = qreal(1000 * 1000);
}
-class SystemMonitorPrivate : public QObject
+class SystemMonitorPrivate : public QObject // clazy:exclude=missing-qobject-macro
{
public:
SystemMonitorPrivate(SystemMonitor *q)
diff --git a/src/manager/main.cpp b/src/manager/main.cpp
index 3b6c7893..5bc31672 100644
--- a/src/manager/main.cpp
+++ b/src/manager/main.cpp
@@ -604,7 +604,7 @@ int main(int argc, char *argv[])
#if defined(QT_DBUS_LIB)
if (Q_UNLIKELY(configuration->dbusStartSessionBus())) {
- class DBusDaemonProcess : public QProcess
+ class DBusDaemonProcess : public QProcess // clazy:exclude=missing-qobject-macro
{
public:
DBusDaemonProcess(QObject *parent = 0)
diff --git a/src/tools/controller/main.cpp b/src/tools/controller/main.cpp
index 7e144d2f..6d0141be 100644
--- a/src/tools/controller/main.cpp
+++ b/src/tools/controller/main.cpp
@@ -53,7 +53,8 @@
QT_USE_NAMESPACE_AM
-class DBus : public QObject {
+class DBus : public QObject // clazy:exclude=missing-qobject-macro
+{
public:
DBus()
{
@@ -180,7 +181,7 @@ static void removePackage(const QString &package, bool keepDocuments, bool force
static void listInstallationLocations();
static void showInstallationLocation(const QString &location);
-class ThrowingApplication : public QCoreApplication
+class ThrowingApplication : public QCoreApplication // clazy:exclude=missing-qobject-macro
{
public:
ThrowingApplication(int &argc, char **argv)
@@ -445,7 +446,7 @@ void startOrDebugApplication(const QString &debugWrapper, const QString &appId,
#if defined(POLLRDHUP)
// ssh does not forward Ctrl+C, but we can detect a hangup condition on stdin
- class HupThread : public QThread
+ class HupThread : public QThread // clazy:exclude=missing-qobject-macro
{
public:
HupThread(QCoreApplication *parent)
diff --git a/src/tools/dumpqmltypes/main.cpp b/src/tools/dumpqmltypes/main.cpp
index c015e079..2123ae9a 100644
--- a/src/tools/dumpqmltypes/main.cpp
+++ b/src/tools/dumpqmltypes/main.cpp
@@ -245,7 +245,7 @@ int main(int argc, char **argv)
<< &QmlApplicationInterfaceExtension::staticMetaObject
<< &ApplicationManagerWindow::staticMetaObject;
- for (const auto &mo : all)
+ for (const auto &mo : qAsConst(all))
out << qmlTypeForMetaObect(mo, 1, true);
out << footer;
diff --git a/src/window-lib/waylandcompositor.h b/src/window-lib/waylandcompositor.h
index 15f393d8..9cc77ddb 100644
--- a/src/window-lib/waylandcompositor.h
+++ b/src/window-lib/waylandcompositor.h
@@ -125,7 +125,7 @@ private:
friend class WaylandCompositor;
};
-class WaylandCompositor : public QWaylandQuickCompositor
+class WaylandCompositor : public QWaylandQuickCompositor // clazy:exclude=missing-qobject-macro
{
public:
WaylandCompositor(QQuickWindow* window, const QString &waylandSocketName, WindowManager *manager);
diff --git a/tests/packageextractor/tst_packageextractor.cpp b/tests/packageextractor/tst_packageextractor.cpp
index 02e5643b..39788974 100644
--- a/tests/packageextractor/tst_packageextractor.cpp
+++ b/tests/packageextractor/tst_packageextractor.cpp
@@ -231,7 +231,7 @@ void tst_PackageExtractor::cancelExtraction()
}
}
-class FifoSource : public QThread
+class FifoSource : public QThread // clazy:exclude=missing-qobject-macro
{
public:
FifoSource(const QString &file)