From 8ecbb39dc6303fcf3ae36ad033d7e90ea29b9003 Mon Sep 17 00:00:00 2001 From: Loren Burkholder <55629213+LorenDB@users.noreply.github.com> Date: Mon, 3 Oct 2022 17:57:30 -0400 Subject: cppcheck stuff (#1200) * cppcheck stuff * Update src/ui/RoomSettings.cpp Co-authored-by: DeepBlueV7.X * Update src/ui/RoomSettings.cpp Co-authored-by: DeepBlueV7.X * Fix linting Co-authored-by: DeepBlueV7.X --- src/encryption/DeviceVerificationFlow.cpp | 38 ++++++++++++++++--------------- src/encryption/DeviceVerificationFlow.h | 26 ++++++++++++--------- src/encryption/Olm.cpp | 4 ++-- src/encryption/Olm.h | 4 ++-- src/encryption/SelfVerificationStatus.cpp | 4 +++- src/encryption/SelfVerificationStatus.h | 3 ++- 6 files changed, 44 insertions(+), 35 deletions(-) (limited to 'src/encryption') diff --git a/src/encryption/DeviceVerificationFlow.cpp b/src/encryption/DeviceVerificationFlow.cpp index b0e8a73b..df5e0c3e 100644 --- a/src/encryption/DeviceVerificationFlow.cpp +++ b/src/encryption/DeviceVerificationFlow.cpp @@ -31,8 +31,8 @@ key_verification_mac(mtx::crypto::SAS *sas, DeviceVerificationFlow::DeviceVerificationFlow(QObject *, DeviceVerificationFlow::Type flow_type, TimelineModel *model, - QString userID, - std::vector deviceIds_) + const QString &userID, + const std::vector &deviceIds_) : sender(false) , type(flow_type) , deviceIds(std::move(deviceIds_)) @@ -86,12 +86,14 @@ DeviceVerificationFlow::DeviceVerificationFlow(QObject *, }); if (model) { - connect( - this->model_, &TimelineModel::updateFlowEventId, this, [this](std::string event_id_) { - this->relation.rel_type = mtx::common::RelationType::Reference; - this->relation.event_id = event_id_; - this->transaction_id = event_id_; - }); + connect(this->model_, + &TimelineModel::updateFlowEventId, + this, + [this](const std::string &event_id_) { + this->relation.rel_type = mtx::common::RelationType::Reference; + this->relation.event_id = event_id_; + this->transaction_id = event_id_; + }); } connect(timeout, &QTimer::timeout, this, [this]() { @@ -548,7 +550,7 @@ DeviceVerificationFlow::isSelfVerification() const } void -DeviceVerificationFlow::setEventId(std::string event_id_) +DeviceVerificationFlow::setEventId(const std::string &event_id_) { this->relation.rel_type = mtx::common::RelationType::Reference; this->relation.event_id = event_id_; @@ -864,8 +866,8 @@ QSharedPointer DeviceVerificationFlow::NewInRoomVerification(QObject *parent_, TimelineModel *timelineModel_, const mtx::events::msg::KeyVerificationRequest &msg, - QString other_user_, - QString event_id_) + const QString &other_user_, + const QString &event_id_) { QSharedPointer flow( new DeviceVerificationFlow(parent_, @@ -887,8 +889,8 @@ DeviceVerificationFlow::NewInRoomVerification(QObject *parent_, QSharedPointer DeviceVerificationFlow::NewToDeviceVerification(QObject *parent_, const mtx::events::msg::KeyVerificationRequest &msg, - QString other_user_, - QString txn_id_) + const QString &other_user_, + const QString &txn_id_) { QSharedPointer flow(new DeviceVerificationFlow( parent_, Type::ToDevice, nullptr, other_user_, {QString::fromStdString(msg.from_device)})); @@ -905,8 +907,8 @@ DeviceVerificationFlow::NewToDeviceVerification(QObject *parent_, QSharedPointer DeviceVerificationFlow::NewToDeviceVerification(QObject *parent_, const mtx::events::msg::KeyVerificationStart &msg, - QString other_user_, - QString txn_id_) + const QString &other_user_, + const QString &txn_id_) { QSharedPointer flow(new DeviceVerificationFlow( parent_, Type::ToDevice, nullptr, other_user_, {QString::fromStdString(msg.from_device)})); @@ -919,7 +921,7 @@ DeviceVerificationFlow::NewToDeviceVerification(QObject *parent_, QSharedPointer DeviceVerificationFlow::InitiateUserVerification(QObject *parent_, TimelineModel *timelineModel_, - QString userid) + const QString &userid) { QSharedPointer flow( new DeviceVerificationFlow(parent_, Type::RoomMsg, timelineModel_, userid, {})); @@ -928,8 +930,8 @@ DeviceVerificationFlow::InitiateUserVerification(QObject *parent_, } QSharedPointer DeviceVerificationFlow::InitiateDeviceVerification(QObject *parent_, - QString userid, - std::vector devices) + const QString &userid, + const std::vector &devices) { assert(!devices.empty()); diff --git a/src/encryption/DeviceVerificationFlow.h b/src/encryption/DeviceVerificationFlow.h index a4dce236..afaddb37 100644 --- a/src/encryption/DeviceVerificationFlow.h +++ b/src/encryption/DeviceVerificationFlow.h @@ -110,22 +110,26 @@ public: NewInRoomVerification(QObject *parent_, TimelineModel *timelineModel_, const mtx::events::msg::KeyVerificationRequest &msg, - QString other_user_, - QString event_id_); + const QString &other_user_, + const QString &event_id_); static QSharedPointer NewToDeviceVerification(QObject *parent_, const mtx::events::msg::KeyVerificationRequest &msg, - QString other_user_, - QString txn_id_); + const QString &other_user_, + const QString &txn_id_); static QSharedPointer NewToDeviceVerification(QObject *parent_, const mtx::events::msg::KeyVerificationStart &msg, - QString other_user_, - QString txn_id_); + const QString &other_user_, + const QString &txn_id_); static QSharedPointer - InitiateUserVerification(QObject *parent_, TimelineModel *timelineModel_, QString userid); + InitiateUserVerification(QObject *parent_, + TimelineModel *timelineModel_, + const QString &userid); static QSharedPointer - InitiateDeviceVerification(QObject *parent, QString userid, std::vector devices); + InitiateDeviceVerification(QObject *parent, + const QString &userid, + const std::vector &devices); // getters QString state(); @@ -137,7 +141,7 @@ public: QString transactionId() { return QString::fromStdString(this->transaction_id); } // setters void setDeviceId(QString deviceID); - void setEventId(std::string event_id); + void setEventId(const std::string &event_id); bool isDeviceVerification() const { return this->type == DeviceVerificationFlow::Type::ToDevice; @@ -164,8 +168,8 @@ private: DeviceVerificationFlow(QObject *, DeviceVerificationFlow::Type flow_type, TimelineModel *model, - QString userID, - std::vector deviceIds_); + const QString &userID, + const std::vector &deviceIds_); void setState(State state) { if (state != state_) { diff --git a/src/encryption/Olm.cpp b/src/encryption/Olm.cpp index 6ab55b32..03d0e983 100644 --- a/src/encryption/Olm.cpp +++ b/src/encryption/Olm.cpp @@ -951,7 +951,7 @@ download_full_keybackup() }); } void -lookup_keybackup(const std::string room, const std::string session_id) +lookup_keybackup(const std::string &room, const std::string &session_id) { if (!UserSettings::instance()->useOnlineKeyBackup()) { // Online key backup disabled @@ -1283,7 +1283,7 @@ calculate_trust(const std::string &user_id, const MegolmSessionIndex &index) //! Send encrypted to device messages, targets is a map from userid to device ids or {} for all //! devices void -send_encrypted_to_device_messages(const std::map> targets, +send_encrypted_to_device_messages(const std::map> &targets, const mtx::events::collections::DeviceEvents &event, bool force_new_session) { diff --git a/src/encryption/Olm.h b/src/encryption/Olm.h index 1189fffa..e48fde67 100644 --- a/src/encryption/Olm.h +++ b/src/encryption/Olm.h @@ -72,7 +72,7 @@ void import_inbound_megolm_session( const mtx::events::DeviceEvent &roomKey); void -lookup_keybackup(const std::string room, const std::string session_id); +lookup_keybackup(const std::string &room, const std::string &session_id); void download_full_keybackup(); @@ -119,7 +119,7 @@ send_megolm_key_to_device(const std::string &user_id, //! Send encrypted to device messages, targets is a map from userid to device ids or {} for all //! devices void -send_encrypted_to_device_messages(const std::map> targets, +send_encrypted_to_device_messages(const std::map> &targets, const mtx::events::collections::DeviceEvents &event, bool force_new_session = false); diff --git a/src/encryption/SelfVerificationStatus.cpp b/src/encryption/SelfVerificationStatus.cpp index 86733cee..fac7f6a2 100644 --- a/src/encryption/SelfVerificationStatus.cpp +++ b/src/encryption/SelfVerificationStatus.cpp @@ -33,7 +33,9 @@ SelfVerificationStatus::SelfVerificationStatus(QObject *o) } void -SelfVerificationStatus::setupCrosssigning(bool useSSSS, QString password, bool useOnlineKeyBackup) +SelfVerificationStatus::setupCrosssigning(bool useSSSS, + const QString &password, + bool useOnlineKeyBackup) { nhlog::db()->info("Clicked setup crossigning"); diff --git a/src/encryption/SelfVerificationStatus.h b/src/encryption/SelfVerificationStatus.h index 9e20bd9d..ec80fc6b 100644 --- a/src/encryption/SelfVerificationStatus.h +++ b/src/encryption/SelfVerificationStatus.h @@ -25,7 +25,8 @@ public: }; Q_ENUM(Status) - Q_INVOKABLE void setupCrosssigning(bool useSSSS, QString password, bool useOnlineKeyBackup); + Q_INVOKABLE void + setupCrosssigning(bool useSSSS, const QString &password, bool useOnlineKeyBackup); Q_INVOKABLE void verifyMasterKey(); Q_INVOKABLE void verifyMasterKeyWithPassphrase(); Q_INVOKABLE void verifyUnverifiedDevices(); -- cgit 1.5.1