From 405f61bf85c409a995d67e7cafc3c73619c19c84 Mon Sep 17 00:00:00 2001 From: Alexander Lohnau Date: Fri, 28 Jul 2023 09:11:43 +0200 Subject: [PATCH] Discard unused params more elegantly By commenting out the parameter name, we get compile-time checks Also, we can omit them for slots and Qt will not forward the parameters. In case we had TODOs next to the code, I kept the Q_UNUSED statements for now. --- core/backends/lan/compositeuploadjob.cpp | 12 +++--------- core/backends/lan/compositeuploadjob.h | 4 ++-- core/backends/lan/uploadjob.cpp | 4 +--- core/compositefiletransferjob.cpp | 4 +--- indicator/indicatorhelper.cpp | 4 +--- interfaces/devicesmodel.cpp | 18 +++++------------- interfaces/devicesmodel.h | 3 +-- .../findthisdevice/findthisdeviceplugin.cpp | 4 +--- plugins/lockdevice/lockdeviceplugin.cpp | 4 +--- plugins/mmtelephony/mmtelephonyplugin.cpp | 12 +++--------- plugins/mmtelephony/mmtelephonyplugin.h | 3 +-- plugins/mpriscontrol/mpriscontrolplugin.cpp | 4 +--- .../mprisremoteplayermediaplayer2player.cpp | 7 ++----- plugins/runcommand/runcommand_config.cpp | 3 +-- .../notifyingapplicationmodel.cpp | 1 - smsapp/conversationmodel.cpp | 7 +++---- smsapp/conversationmodel.h | 2 +- smsapp/smshelper.cpp | 5 +---- smsapp/thumbnailsprovider.cpp | 5 +---- 19 files changed, 30 insertions(+), 76 deletions(-) diff --git a/core/backends/lan/compositeuploadjob.cpp b/core/backends/lan/compositeuploadjob.cpp index 76311688d..62044b20e 100644 --- a/core/backends/lan/compositeuploadjob.cpp +++ b/core/backends/lan/compositeuploadjob.cpp @@ -146,10 +146,8 @@ void CompositeUploadJob::socketDisconnected() m_socket->close(); } -void CompositeUploadJob::socketError(QAbstractSocket::SocketError error) +void CompositeUploadJob::socketError() { - Q_UNUSED(error); - // Do not close the socket because when android closes the socket (share is cancelled) closing the socket leads to a cyclic socketError and eventually a // segv setError(SocketError); @@ -158,10 +156,8 @@ void CompositeUploadJob::socketError(QAbstractSocket::SocketError error) m_running = false; } -void CompositeUploadJob::sslError(const QList &errors) +void CompositeUploadJob::sslError() { - Q_UNUSED(errors); - m_socket->close(); setError(SslError); emitResult(); @@ -240,10 +236,8 @@ bool CompositeUploadJob::doKill() return true; } -void CompositeUploadJob::slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount) +void CompositeUploadJob::slotProcessedAmount(KJob * /*job*/, KJob::Unit unit, qulonglong amount) { - Q_UNUSED(job); - m_currentJobSendPayloadSize = amount; quint64 uploaded = m_totalSendPayloadSize + m_currentJobSendPayloadSize; diff --git a/core/backends/lan/compositeuploadjob.h b/core/backends/lan/compositeuploadjob.h index 1bf6810aa..0e066a4c6 100644 --- a/core/backends/lan/compositeuploadjob.h +++ b/core/backends/lan/compositeuploadjob.h @@ -55,8 +55,8 @@ private: private Q_SLOTS: void newConnection(); void socketDisconnected(); - void socketError(QAbstractSocket::SocketError socketError); - void sslError(const QList &errors); + void socketError(); + void sslError(); void encrypted(); void slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount); void slotResult(KJob *job) override; diff --git a/core/backends/lan/uploadjob.cpp b/core/backends/lan/uploadjob.cpp index d3baf685a..01b826d72 100644 --- a/core/backends/lan/uploadjob.cpp +++ b/core/backends/lan/uploadjob.cpp @@ -64,10 +64,8 @@ void UploadJob::uploadNextPacket() } } -void UploadJob::encryptedBytesWritten(qint64 bytes) +void UploadJob::encryptedBytesWritten(qint64 /*bytes*/) { - Q_UNUSED(bytes); - if (m_socket->encryptedBytesToWrite() == 0) { bytesUploaded += bytesUploading; setProcessedAmount(Bytes, bytesUploaded); diff --git a/core/compositefiletransferjob.cpp b/core/compositefiletransferjob.cpp index 64d440ae5..ecb7b9a14 100644 --- a/core/compositefiletransferjob.cpp +++ b/core/compositefiletransferjob.cpp @@ -86,10 +86,8 @@ bool CompositeFileTransferJob::doKill() return true; } -void CompositeFileTransferJob::slotProcessedAmount(KJob *job, KJob::Unit unit, qulonglong amount) +void CompositeFileTransferJob::slotProcessedAmount(KJob * /*job*/, KJob::Unit unit, qulonglong amount) { - Q_UNUSED(job); - m_currentJobSentPayloadSize = amount; const auto totalSent = m_totalSentPayloadSize + m_currentJobSentPayloadSize; diff --git a/indicator/indicatorhelper.cpp b/indicator/indicatorhelper.cpp index b32639ede..312c31b16 100644 --- a/indicator/indicatorhelper.cpp +++ b/indicator/indicatorhelper.cpp @@ -28,10 +28,8 @@ void IndicatorHelper::iconPathHook() { } -int IndicatorHelper::daemonHook(QProcess &kdeconnectd) +int IndicatorHelper::daemonHook(QProcess & /*kdeconnectd*/) { - Q_UNUSED(kdeconnectd); - return 0; } diff --git a/interfaces/devicesmodel.cpp b/interfaces/devicesmodel.cpp index 5caa78231..88a4ba5d8 100644 --- a/interfaces/devicesmodel.cpp +++ b/interfaces/devicesmodel.cpp @@ -94,9 +94,8 @@ void DevicesModel::deviceRemoved(const QString &id) } } -void DevicesModel::deviceUpdated(const QString &id, bool isVisible) +void DevicesModel::deviceUpdated(const QString &id) { - Q_UNUSED(isVisible); int row = rowForDevice(id); if (row < 0) { @@ -179,17 +178,10 @@ void DevicesModel::receivedDeviceList(QDBusPendingCallWatcher *watcher) void DevicesModel::appendDevice(DeviceDbusInterface *dev) { m_deviceList.append(dev); - connect(dev, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, &DevicesModel::nameChanged); -} - -void DevicesModel::nameChanged(const QString &newName) -{ - Q_UNUSED(newName); - DeviceDbusInterface *device = static_cast(sender()); - - Q_ASSERT(rowForDevice(device->id()) >= 0); - - deviceUpdated(device->id(), true); + connect(dev, &OrgKdeKdeconnectDeviceInterface::nameChanged, this, [this, dev]() { + Q_ASSERT(rowForDevice(dev->id()) >= 0); + deviceUpdated(dev->id()); + }); } void DevicesModel::clearDevices() diff --git a/interfaces/devicesmodel.h b/interfaces/devicesmodel.h index e8c08af56..be8168c12 100644 --- a/interfaces/devicesmodel.h +++ b/interfaces/devicesmodel.h @@ -61,10 +61,9 @@ public: private Q_SLOTS: void deviceAdded(const QString &id); void deviceRemoved(const QString &id); - void deviceUpdated(const QString &id, bool isVisible); + void deviceUpdated(const QString &id); void refreshDeviceList(); void receivedDeviceList(QDBusPendingCallWatcher *watcher); - void nameChanged(const QString &newName); Q_SIGNALS: void rowsChanged(); diff --git a/plugins/findthisdevice/findthisdeviceplugin.cpp b/plugins/findthisdevice/findthisdeviceplugin.cpp index 6dba0f009..1db46f828 100644 --- a/plugins/findthisdevice/findthisdeviceplugin.cpp +++ b/plugins/findthisdevice/findthisdeviceplugin.cpp @@ -31,10 +31,8 @@ FindThisDevicePlugin::FindThisDevicePlugin(QObject *parent, const QVariantList & { } -void FindThisDevicePlugin::receivePacket(const NetworkPacket &np) +void FindThisDevicePlugin::receivePacket(const NetworkPacket & /*np*/) { - Q_UNUSED(np); - const QString soundFile = config()->getString(QStringLiteral("ringtone"), defaultSound()); const QUrl soundURL = QUrl::fromLocalFile(soundFile); diff --git a/plugins/lockdevice/lockdeviceplugin.cpp b/plugins/lockdevice/lockdeviceplugin.cpp index 82fc9afac..0002009dc 100644 --- a/plugins/lockdevice/lockdeviceplugin.cpp +++ b/plugins/lockdevice/lockdeviceplugin.cpp @@ -37,9 +37,7 @@ LockDevicePlugin::LockDevicePlugin(QObject *parent, const QVariantList &args) connect(&m_propertiesInterface, &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged, this, - [this](const QString &interface, const QVariantMap &properties, QStringList invalidatedProperties) { - Q_UNUSED(invalidatedProperties); - + [this](const QString &interface, const QVariantMap &properties) { if (interface != QLatin1String("org.freedesktop.login1.Session")) { return; } diff --git a/plugins/mmtelephony/mmtelephonyplugin.cpp b/plugins/mmtelephony/mmtelephonyplugin.cpp index d90fbb7aa..df7e3ae52 100644 --- a/plugins/mmtelephony/mmtelephonyplugin.cpp +++ b/plugins/mmtelephony/mmtelephonyplugin.cpp @@ -52,17 +52,12 @@ void MMTelephonyPlugin::onModemAdded(const QString &path) }); } -void MMTelephonyPlugin::onModemRemoved(const QString &path) -{ - Q_UNUSED(path); -} - void MMTelephonyPlugin::onCallAdded(ModemManager::Call::Ptr call) { qCDebug(KDECONNECT_PLUGIN_MMTELEPHONY) << "Call added" << call->number(); - connect(call.get(), &ModemManager::Call::stateChanged, this, [=](MMCallState newState, MMCallState oldState, MMCallStateReason reason) { - onCallStateChanged(call.get(), newState, oldState, reason); + connect(call.get(), &ModemManager::Call::stateChanged, this, [=](MMCallState newState, MMCallState oldState) { + onCallStateChanged(call.get(), newState, oldState); }); } @@ -91,9 +86,8 @@ QString MMTelephonyPlugin::stateName(MMCallState state) return event; } -void MMTelephonyPlugin::onCallStateChanged(ModemManager::Call *call, MMCallState newState, MMCallState oldState, MMCallStateReason reason) +void MMTelephonyPlugin::onCallStateChanged(ModemManager::Call *call, MMCallState newState, MMCallState oldState) { - Q_UNUSED(reason); auto event = stateName(newState); qCDebug(KDECONNECT_PLUGIN_MMTELEPHONY) << "Call state changed" << call->uni() << event; diff --git a/plugins/mmtelephony/mmtelephonyplugin.h b/plugins/mmtelephony/mmtelephonyplugin.h index 610b7f790..3d9e5a21c 100644 --- a/plugins/mmtelephony/mmtelephonyplugin.h +++ b/plugins/mmtelephony/mmtelephonyplugin.h @@ -42,8 +42,7 @@ private: void onCallAdded(ModemManager::Call::Ptr call); void onCallRemoved(ModemManager::Call::Ptr call); void onModemAdded(const QString &path); - void onModemRemoved(const QString &path); - void onCallStateChanged(ModemManager::Call *call, MMCallState newState, MMCallState oldState, MMCallStateReason reason); + void onCallStateChanged(ModemManager::Call *call, MMCallState newState, MMCallState oldState); void sendMMTelephonyPacket(ModemManager::Call *call, const QString &state); void sendCancelMMTelephonyPacket(ModemManager::Call *call, const QString &lastState); static QString stateName(MMCallState state); diff --git a/plugins/mpriscontrol/mpriscontrolplugin.cpp b/plugins/mpriscontrol/mpriscontrolplugin.cpp index c58851a1b..5519f20cd 100644 --- a/plugins/mpriscontrol/mpriscontrolplugin.cpp +++ b/plugins/mpriscontrol/mpriscontrolplugin.cpp @@ -119,10 +119,8 @@ void MprisControlPlugin::seeked(qlonglong position) sendPacket(np); } -void MprisControlPlugin::propertiesChanged(const QString &propertyInterface, const QVariantMap &properties) +void MprisControlPlugin::propertiesChanged(const QString & /*propertyInterface*/, const QVariantMap &properties) { - Q_UNUSED(propertyInterface); - OrgFreedesktopDBusPropertiesInterface *propertiesInterface = (OrgFreedesktopDBusPropertiesInterface *)sender(); const auto end = playerList.constEnd(); const auto it = std::find_if(playerList.constBegin(), end, [propertiesInterface](const MprisPlayer &player) { diff --git a/plugins/mprisremote/mprisremoteplayermediaplayer2player.cpp b/plugins/mprisremote/mprisremoteplayermediaplayer2player.cpp index ae923cddd..5c4971d64 100644 --- a/plugins/mprisremote/mprisremoteplayermediaplayer2player.cpp +++ b/plugins/mprisremote/mprisremoteplayermediaplayer2player.cpp @@ -159,17 +159,14 @@ void MprisRemotePlayerMediaPlayer2Player::Seek(qlonglong Offset) m_plugin->seek(Offset); } -void MprisRemotePlayerMediaPlayer2Player::SetPosition(QDBusObjectPath TrackId, qlonglong Position) +void MprisRemotePlayerMediaPlayer2Player::SetPosition(QDBusObjectPath /*TrackId*/, qlonglong Position) { - Q_UNUSED(TrackId) - m_plugin->setPlayer(m_parent->identity()); m_plugin->setPosition(Position / 1000); } -void MprisRemotePlayerMediaPlayer2Player::OpenUri(QString Uri) +void MprisRemotePlayerMediaPlayer2Player::OpenUri(QString /*Uri*/) { - Q_UNUSED(Uri) } void MprisRemotePlayerMediaPlayer2Player::controlsChanged() diff --git a/plugins/runcommand/runcommand_config.cpp b/plugins/runcommand/runcommand_config.cpp index 488572845..7c12c5fd0 100644 --- a/plugins/runcommand/runcommand_config.cpp +++ b/plugins/runcommand/runcommand_config.cpp @@ -241,10 +241,9 @@ void RunCommandConfig::insertRow(int i, const QString &name, const QString &comm m_entriesModel->insertRow(i, QList() << newName << newCommand); } -void RunCommandConfig::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight) +void RunCommandConfig::onDataChanged(const QModelIndex & /*topLeft*/, const QModelIndex &bottomRight) { markAsChanged(); - Q_UNUSED(topLeft); if (bottomRight.row() == m_entriesModel->rowCount() - 1) { // TODO check both entries are still empty insertEmptyRow(); diff --git a/plugins/sendnotifications/notifyingapplicationmodel.cpp b/plugins/sendnotifications/notifyingapplicationmodel.cpp index 49634cb66..7969f3d01 100644 --- a/plugins/sendnotifications/notifyingapplicationmodel.cpp +++ b/plugins/sendnotifications/notifyingapplicationmodel.cpp @@ -73,7 +73,6 @@ void NotifyingApplicationModel::clearApplications() QVariant NotifyingApplicationModel::data(const QModelIndex &index, int role) const { - Q_UNUSED(role); if (!index.isValid() || index.row() < 0 || index.row() >= m_apps.size() || index.column() > 3) { return QVariant(); } diff --git a/smsapp/conversationmodel.cpp b/smsapp/conversationmodel.cpp index c0b4d80ea..9a7a3c714 100644 --- a/smsapp/conversationmodel.cpp +++ b/smsapp/conversationmodel.cpp @@ -62,7 +62,7 @@ void ConversationModel::setDeviceId(const QString &deviceId) << "of" << this; if (m_conversationsInterface) { disconnect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdate(QDBusVariant))); - disconnect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64, quint64))); + disconnect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64))); disconnect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleConversationCreated(QDBusVariant))); delete m_conversationsInterface; } @@ -71,7 +71,7 @@ void ConversationModel::setDeviceId(const QString &deviceId) m_conversationsInterface = new DeviceConversationsDbusInterface(deviceId, this); connect(m_conversationsInterface, SIGNAL(conversationUpdated(QDBusVariant)), this, SLOT(handleConversationUpdate(QDBusVariant))); - connect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64, quint64))); + connect(m_conversationsInterface, SIGNAL(conversationLoaded(qint64, quint64)), this, SLOT(handleConversationLoaded(qint64))); connect(m_conversationsInterface, SIGNAL(conversationCreated(QDBusVariant)), this, SLOT(handleConversationCreated(QDBusVariant))); connect(m_conversationsInterface, SIGNAL(attachmentReceived(QString, QString)), this, SIGNAL(filePathReceived(QString, QString))); @@ -205,9 +205,8 @@ void ConversationModel::handleConversationCreated(const QDBusVariant &msg) } } -void ConversationModel::handleConversationLoaded(qint64 threadID, quint64 numMessages) +void ConversationModel::handleConversationLoaded(qint64 threadID) { - Q_UNUSED(numMessages) if (threadID != m_threadId) { return; } diff --git a/smsapp/conversationmodel.h b/smsapp/conversationmodel.h index 399e3e56d..51314f00b 100644 --- a/smsapp/conversationmodel.h +++ b/smsapp/conversationmodel.h @@ -68,7 +68,7 @@ Q_SIGNALS: private Q_SLOTS: void handleConversationUpdate(const QDBusVariant &message); - void handleConversationLoaded(qint64 threadID, quint64 numMessages); + void handleConversationLoaded(qint64 threadID); void handleConversationCreated(const QDBusVariant &message); private: diff --git a/smsapp/smshelper.cpp b/smsapp/smshelper.cpp index fb5bccea9..e9142aa76 100644 --- a/smsapp/smshelper.cpp +++ b/smsapp/smshelper.cpp @@ -26,11 +26,8 @@ #include "smsapp/gsmasciimap.h" #include "smshelper_debug.h" -QObject *SmsHelper::singletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine) +QObject *SmsHelper::singletonProvider(QQmlEngine * /*engine*/, QJSEngine * /*scriptEngine*/) { - Q_UNUSED(engine); - Q_UNUSED(scriptEngine); - return new SmsHelper(); } diff --git a/smsapp/thumbnailsprovider.cpp b/smsapp/thumbnailsprovider.cpp index 1d43ce0c6..1caee1941 100644 --- a/smsapp/thumbnailsprovider.cpp +++ b/smsapp/thumbnailsprovider.cpp @@ -11,11 +11,8 @@ ThumbnailsProvider::ThumbnailsProvider() { } -QImage ThumbnailsProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize) +QImage ThumbnailsProvider::requestImage(const QString &id, QSize * /*size*/, const QSize & /*requestedSize*/) { - Q_UNUSED(size) - Q_UNUSED(requestedSize) - if (m_thumbnails.contains(id)) { return m_thumbnails.value(id); }